开发者

Parse response to SetExpressCheckout for digital goods with AJAX (integrating PayPal Digital Goods for Express Checkout)?

开发者 https://www.devze.com 2023-02-15 04:56 出处:网络
The documentation for PayPal is a little unclear. How are we supposed to parse the response to SetExpressCheckout for digital goods, which involves an iFrame overlaid on you开发者_如何学运维r web sit

The documentation for PayPal is a little unclear.

How are we supposed to parse the response to SetExpressCheckout for digital goods, which involves an iFrame overlaid on you开发者_如何学运维r web site? The digital goods experience allows the user to remain on your site, essentially, by displaying the PayPal payment pages in an overlay -- if I understand the documentation properly.

However, we're confused about how you're supposed to communicate with the PayPal servers since there do not appear to be JSON responses provided by PayPal. Are we supposed to post a form and on the backend monitor for an IPN? Or can this all be done from the frontend via AJAX/JSON?

Here is the PayPal page on digital goods and Express Checkout: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_IntroducingExpressCheckoutDG

We're using Rails.


One important point to keep in mind is that you shouldn't be running API calls using AJAX -- API calls should always be done on your backend. This way, you don't risk exposing your API credentials to everyone and their dog. The API call itself is just a simple post and response -- you post your call to PayPal's API servers, and PayPal responds back in real-time.

I'd suggest checking out my demo to get an idea of how the whole process is supposed to work: https://www.x.com/blogs/matt/2011/02/15/another-digital-goods-demo .


There's an example on GitHub of request/response using PayPal's Name-Value Pair API. This ought to move you down the road some. Essentially you send a hash with the NVPs for the SetExpressCheckout operation and get one back. A little parsing (split on the &'s and ='s) and you can do things like check if (response["ACK"]=="Success").

The PayPal NVP API guide describes the name-value pairs in requests and responses. Page 21 describes what successful and unsuccessful responses look like.

0

精彩评论

暂无评论...
验证码 换一张
取 消