PayPal API Error - Error Processing Payment
I know this is a pretty specific question but I managed to get some great help before. I have already posted this on PayPal's developer site (www.x.com) however have not yet had a responce.
I have been attempting to create a PayNow button using the BMCreateButton API via NVP. I receive the success message and the button code, however whenever anyone clicks the button they are instantly displaying the message:
"Error Processing Payment
Your payment can't be processed. Please contact the merchant directly with this code."The code I am using to generate the button is as follows:
$sendData = array(
"METHOD" => "BMCreateButton",
"VERSION" => "65.2",
"USER" => "[username]",
"PWD" => "[password]",
"SIGNATURE" => "[signature]",
"BUTTONCODE" => "ENCRYPTED",
"BUTTONTYPE" => "PAYMENT",
"BUTTONSUBTYPE" => "SERVICES",
"BUTTONCOUNTRY" => "GB",
"BUTTONIMAGE" => "reg",
"L_BUTTONVAR1" => "item_number=$userID",
"L_BUTTONVAR2" => "item_name=$invoiceID",
"L_BUTTONVAR3" => "subtotal=$invoiceTotal",
开发者_Python百科 "L_BUTTONVAR4" => "currency_code=GBP",
"L_BUTTONVAR5" => "no_shipping=1",
"L_BUTTONVAR6" => "no_note=1",
"L_BUTTONVAR7" => "notify_url=[full url to ipn]",
"L_BUTTONVAR8" => "cancel_return=[full url to cancel]",
"L_BUTTONVAR9" => "return=[full url to return]"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp?'.http_build_query($sendData));
$nvpReturn = curl_exec($curl);
curl_close($curl);
The outcome I really want is so that I am able to create a button on the fly for each of our users invoices which can vary in amount (i.e. with late fees, adddons etc).
Just wondering if anyone with some PayPal NVP API experience can spot the issue.
Thanks :)
I actually found the answer by messing with values for hours until finally one worked. This was eventually confirmed by PayPal on www.x.com.
The following changes were made:
"BUTTONTYPE" => "PAYMENT",
to
"BUTTONTYPE" => "BUYNOW",
and
"L_BUTTONVAR3" => "subtotal=$invoiceTotal",
to
"L_BUTTONVAR3" => "amount=$invoiceTotal",
Apparently the options I had used were for their hosted payment / cart payment methods (not that these are mentioned anywhere in their documentation).
Never mind, got there in the end.
I was looking into this very issue myself, after a lot of searching I came across a script similar to this. I can't find the original post, but the script appears to do the same thing.
https://www.x.com/blogs/magarvin/2011/02/25/bmcreatebutton-api-example--create-buttons-on-the-fly
Hope this helps.
精彩评论