You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Fundraising/Data and flow/PSP integrations/PayPal Express

From Wikitech-static
Jump to navigation Jump to search
paypal
Original Name PayPal
Our Name paypal
Current Name paypal
Payment Methods PayPal
Countries ?
Documentation ?
Production Console paypal.com
Test Console sandbox.paypal.com
Contact ?


Overview

Our PayPal Express Checkout integration first requests a token from PayPal, then uses that token to send the donor immediately to the PayPal login page. PayPal returns them to our site and we ask for the payment status, then decide whether to capture the payment.

Accounts

paypal.com -> developer.paypal.com

API calls

All API calls are made via simple name/value pair POSTS - that is, old-fashioned form data encoded with http_build_query rather than JSON. All calls hit the same endpoint (differing only between sandbox and production). Different API calls are differentiated by the METHOD parameter. Authentication is performed via an SSL certificate on the request. All responses have an ACK parameter which should be Success or SuccessWithWarning if the call succeeded.

Initial payment setup

Our first call uses METHOD=SetExpressCheckout and sends the amount, currency, description, and return and cancel URLs to PayPal. We read the TOKEN parameter from the response. We save the TOKEN as our gateway_session_id and use it to create a redirect URL to send the donor to the PayPal login page.

Payment status request

When the donor returns to our site, we make an API call with METHOD=GetExpressCheckoutDetails. We send the gateway_session_id back (as the TOKEN parameter) and read donor details and payment status from the response. The PAYERID from this response is required (along with the TOKEN) to capture the payment in the next step.

There is a SmashPig maintenance script that you can use to perform this request from the command line.

php PaymentProviders/PayPal/Maintenance/GetPaymentStatus.php <TOKEN>

Payment capture

TODO finish

METHOD=DoExpressCheckoutPayment

Recurring payment setup

TODO finish

METHOD=CreateRecurringPaymentsProfile

IPN Listener

https://wikitech.wikimedia.org/wiki/Fundraising/Data_and_flow/IPN_listener#PayPal