Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the Paypal Sandbox not processing payments?

I'm making an e-commerce site and the paypal integration is seemingly working. I have a shopping cart, that totals up all the items inside, adds the shipping price and then sends that number off to paypal with these lines.

string address = "https://api-3t.sandbox.paypal.com/nvp?USER=<username>&PWD=<password>&VERSION=71.0&SIGNATURE=<signature>&METHOD=SetExpressCheckout&PAYMENTREQUEST_0_AMT=" + lblTotal.Text + "&PAYMENTREQUEST_0_CURRENCYCODE=USD&RETURNURL=http://www.secretskeletonminiatures.com/checkout.aspx&CANCELURL=http://www.secretskeletonminiatures.com/cart.aspx&PAYMENTREQUEST_0_PAYMENTACTION=Sale";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);

Then I pull in the response from paypal with a HTTPWebResponse and parse out the token and redirect users to

Response.Redirect("https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=" + token);

When the user gets to paypal then log in and hit the "Pay Now" button and get redirected to the checkout page of my site.

So everything seems ok. But when I check the sandbox accounts, none of the money is actually getting transferred.

The most common cause is the useraction=commit parameter being missing from the redirect url but it's there so that isn't the problem.

like image 390
Brian Green Avatar asked Jul 02 '11 03:07

Brian Green


1 Answers

To anyone else who stumbles on this question later. I did solve it. Once the user returns to your site after confirming the payment on paypal you still have to send a DoExpressCheckoutPayment request to the paypal servers to get the payment to process.

You would supply the PayerID and TOKEN to DoExpressCheckoutPayment to process it. The PayerID is appended in the URL of your RETURNURL, or can be retrieved by calling GetExpressCheckoutDetails with the TOKEN.

like image 82
Brian Green Avatar answered Sep 20 '22 12:09

Brian Green