PayPal PayFlow API Error

216 views Asked by At

We are using PayFlow PayPal API for recurring payments, it gives us an issue.

We are sending amount $29 to the API but on PayPal log it is showing $1 only. When we asked PayPal support for this they said you are sending $1.

Please help us. Below is the code we have setup:

<?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     =   '[email protected]';
$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;
1

There are 1 answers

1
sikander On BEST ANSWER

In your post data you are sending these two values:

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

PayPal's documentation states that OPTIONALTRXAMT should only be used when OPTIONALTRX=S, which it is not in your case.

The documentation also states that Amount is ignored when OPTIONALTRX=A, which is what you are doing.

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

So, remove the Optional parameters.