【问题标题】:PayPal PayFlow API ErrorPayPal PayFlow API 错误
【发布时间】:2017-05-06 18:33:50
【问题描述】:

我们正在使用 PayFlow PayPal API 进行定期付款,这给我们带来了问题。

我们向 API 发送了 29 美元的金额,但在 PayPal 日志中仅显示 1 美元。当我们要求 PayPal 对此提供支持时,他们说您发送的是 1 美元。

请帮助我们。下面是我们设置的代码:

<?php

$payflow_partner    =   'PayPal';
$payflow_vender     =   'xxxxxxxxxxxxx';
$payflow_user       =   'xxxxxxxxxxxx';
$payflow_pwd        =   'XXXXXXXXX';
$payflow_url        =   'https://pilot-payflowpro.paypal.com';

$first_name     =   'First Name';
$last_name      =   'Last Name';
$profile_name   =   $first_name.$last_name;
$plan_amount    =   29.00;
$card_number    =   '4111111111111111';
$expiry_month   =   '05';
$expiry_year    =   '21';
$expiry         =   $expiry_month.$expiry_year; 
$user_email     =   'test@example.com';
$start_date     =   '01202017';                 

$post_list  =   'TRXTYPE=R&TENDER=C&PARTNER='.$payflow_partner.'&VENDOR='.$payflow_vender.'&USER='.$payflow_user.'&PWD='.$payflow_pwd.'&ACTION=A&PROFILENAME='.$profile_name.'&AMT='.$plan_amount.'&CURRENCY=USD&ACCT='.$card_number.'&EXPDATE='.$expiry.'&START='.$start_date.'&PAYPERIOD=MONT&TERM=0&EMAIL='.$user_email.'&OPTIONALTRX=A&OPTIONALTRXAMT='.$plan_amount.'&COMMENT1=First-time-customer&STREET=sector-7-malviya-nagar&ZIP=302017&CITY=jaipur&STATE=rajasthan&COUNTRY=india&FIRSTNAME='.$first_name.'&MIDDLENAME='.$last_name.'&LASTNAME='.$last_name;

$headers = array();  
$headers[] = "Content-Type: text/namevalue"; //or maybe text/xml
$headers[] = "X-VPS-Timeout: 3000";
$headers[] = "X-VPS-VIT-OS-Name: Linux";  // Name of your OS
$headers[] = "X-VPS-VIT-OS-Version: RHEL 4";  // OS Version
$headers[] = "X-VPS-VIT-Client-Type: PHP/cURL";  // What you are using
$headers[] = "X-VPS-VIT-Client-Version: 0.01";  // For your info
$headers[] = "X-VPS-VIT-Client-Architecture: x86";  // For your info
$headers[] = "X-VPS-VIT-Client-Certification-Id:13fda2433fc2123d8b191d2d011b7fdc";
$headers[] = "X-VPS-VIT-Integration-Product: MyApplication";  // For your info, would populate with application name
$headers[] = "X-VPS-VIT-Integration-Version: 0.01"; // Application version

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $payflow_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 45); // times out after 45 secs
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_list); //adding POST data
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); //verifies ssl certificate
curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done 
curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST 
$result = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);

echo $result;

【问题讨论】:

    标签: paypal recurring-billing


    【解决方案1】:

    在您的帖子数据中,您发送这两个值:

    AMT='.$plan_amount
    OPTIONALTRXAMT='.$plan_amount
    

    PayPal 的 documentation 声明 OPTIONALTRXAMT 仅应在 OPTIONALTRX=S 时使用,而您的情况并非如此。

    该文档还指出,OPTIONALTRX=AAmount 被忽略,这就是你正在做的事情。

    注意:当 OPTIONALTRX=A 时不要指定数量。金额被忽略。

    所以,去掉可选参数。

    【讨论】:

    • 谢谢 Sikander...您的解决方案就像一个魅力...非常感谢...
    猜你喜欢
    • 2012-12-03
    • 2014-11-13
    • 2012-11-07
    • 2012-05-31
    • 2012-08-23
    • 1970-01-01
    • 2016-01-03
    • 2017-04-06
    • 2016-09-28
    相关资源
    最近更新 更多