PayPal PayFlow API 错误

PayPal PayFlow API Error

我们正在使用 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;

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

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

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

文档还指出 AmountOPTIONALTRX=A 时被忽略,这正是您正在做的事情。

Note: Do not specify an amount when OPTIONALTRX=A. The amount is ignored.

因此,删除可选参数。