Hello,

I've built myself a nice, simple little store to sell some stuff I've got laying around and some nice jewelry I got last week. I would like to give users the option to pay with PayPal exclusively (since it will also process CC's I figure that's all I really need). The problem is that the paypal website has crap for instructions, very unclear without proper examples or code samples or anything. It's been very frustrating for me.

So I think I've got a general idea of how the API works and now I am at the first step of my code where I am just trying to get anything to work with the API. I keep getting ACK=Failure.

For testing purposes I am using CURL :)

$url = "https://api-3t.sandbox.paypal.com/nvp";

$post = "METHOD=SetExpressCheckout&";
$post .= "VERSION=53.0&";
$post .= "USER=sdk-three_api1.sdk.com&"; // sandbox info
$post .= "PWD=QFZCWN5HZM8VBG7Q&"; // sandbox info
$post .= "SIGNATURE=A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU&"; // sandbox info
$post .= "PAYMENTREQUEST_0_AMT=10.00&";
$post .= "PAYMENTREQUEST_0_CURRENCYCODE=USD&";
$post .= "RETURNURL=".$settings['site']['url'].urlencode("?page=cart&msg=completed")."&";
$post .= "CANCELURL=".$settings['site']['url'].urlencode("?page=cart&msg=canceled")."&";
$post .= "PAYMENTREQUEST_0_PAYMENTACTION=Sale&";
$post .= "TOTALORDER=10.00&";

// Here is my custom CURL function in which returns the results of the post to the API
echo "<pre>".urldecode(str_replace("&","<br />",getpage($url,$post,"cookie.txt")))."</pre>";

I formatted this for easy reading, but here is what it returns:

TIMESTAMP=2011-12-05T06:45:59Z
CORRELATIONID=aa7d4da682fdf
ACK=Failure
VERSION=53.0
BUILD=2271164
L_ERRORCODE0=10400
L_SHORTMESSAGE0=Transaction refused because of an invalid argument. See additional error messages for details.
L_LONGMESSAGE0=Order total is missing.
L_SEVERITYCODE0=Error


I looked up error 10400 and it just says "Total Order is missing" with no other explanation. Clearly Total Order is there, so I don't know what to do. I'd call Paypal but there isn't anyone there ATM.

I've followed the instructions on PayPals "Getting started with Express Checkout" (https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted), clearly there is something missing.


If you have any experience with PayPal API I'd appreciate your input. I'd like to get this finished by tomorrow so I can (hopefully) make some money for rent. Kind of in a hard place right and need to get this going as I've people waiting to buy!

Thank you!!

Even the other code samples they have return errors:

USER,PWD and SIGNATURE are required for sandbox testing and were not part of the example.

Post Info:

VERSION=53.0
USER=sdk-three_api1.sdk.com
PWD=QFZCWN5HZM8VBG7Q
SIGNATURE=A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU
METHOD=SetExpressCheckout
PAYMENTREQUEST_0_PAYMENTACTION=Sale
L_PAYMENTREQUEST_0_NAME0=10% Decaf Kona Blend Coffee
L_PAYMENTREQUEST_0_NUMBER0=623083
L_PAYMENTREQUEST_0_DESC0=Size: 8.8-oz
L_PAYMENTREQUEST_0_AMT0=9.95
L_PAYMENTREQUEST_0_QTY0=2
L_PAYMENTREQUEST_0_NAME1=Coffee Filter bags
L_PAYMENTREQUEST_0_NUMBER1=623084
L_PAYMENTREQUEST_0_DESC1=Size: Two 24-piece boxes
L_PAYMENTREQUEST_0_AMT1=39.70
L_PAYMENTREQUEST_0_QTY1=2
PAYMENTREQUEST_0_ITEMAMT=99.30
PAYMENTREQUEST_0_TAXAMT=2.58
PAYMENTREQUEST_0_SHIPPINGAMT=3.00
PAYMENTREQUEST_0_HANDLINGAMT=2.99
PAYMENTREQUEST_0_SHIPDISCAMT=-3.00
PAYMENTREQUEST_0_INSURANCEAMT=1.00
PAYMENTREQUEST_0_AMT=105.87
PAYMENTREQUEST_0_CURRENCYCODE=USD
ALLOWNOTE=1

Return:

TIMESTAMP=2011-12-05T07:01:36Z
CORRELATIONID=82d871b69fda1
ACK=Failure
VERSION=53.0
BUILD=2271164
L_ERRORCODE0=10400
L_SHORTMESSAGE0=Transaction refused because of an invalid argument. See additional error messages for details.
L_LONGMESSAGE0=Order total is missing.
L_SEVERITYCODE0=Error

I got it to work, though I still need to make some changes to it. I changed the "VERSION=53.0" to "VERSION=65.0". I don't know how many version they have. This whole entire process is not documented very well, many things are elusive and unclear.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.