Skip to content

Instantly share code, notes, and snippets.

@jeffharrell
Created July 18, 2012 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffharrell/3134368 to your computer and use it in GitHub Desktop.
Save jeffharrell/3134368 to your computer and use it in GitHub Desktop.
The one page PayPal Express Checkout guide (using cURL)

One page PayPal Express Checkout guide using cURL

To integrate with Express Checkout have your API credentials ready and read on.

Step 1 - Send your transaction data to PayPal (your API credentials are required for safety):

curl https://api-3t.paypal.com/nvp \
  -d method=SetExpressCheckout \
  -d amt=1.00 \
  -d returnurl=http://example.com/success \
  -d cancelurl=http://example.com/cancel \
  -d version=92.0 \
  -d user=${API_USER} \
  -d pwd=${API_PWD} \
  -d signature=${API_SIGNATURE} 

Step 2 - A query string formatted response will be returned, e.g.:

TOKEN=EC-6V0052576B2719609&TIMESTAMP=2012-07-18T03:44:53Z&CORRELATIONID=1b1f2f903d3e7&ACK=Success&VERSION=47.0&BUILD=3300093

Step 3 - Copy the token value from the response, add it to the following URL, then redirect your browser there:

https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=

PayPal will send the browser back to the redirecturl you originally provided. URL parameters for PayerId and Token are appended as query params. Save these!

Step 4 - Using the token and payerid you can request the transaction details:

curl https://api-3t.sandbox.paypal.com/nvp \
  -d method=GetExpressCheckoutDetails \
  -d token=${RETURNED_TOKEN} \
  -d payerid=${RETURNED_PAYERID} \
  -d user=${API_USER} \
  -d pwd=${API_PWD} \
  -d signature=${API_SIGNATURE}

Step 5 - Finally, commit the transaction and you've completed your payment:

curl https://api-3t.sandbox.paypal.com/nvp \
  -d method=DoExpressCheckoutPayment \
  -d token=${RETURNED_TOKEN} \
  -d payerid=${RETURNED_PAYERID} \
  -d amt=1.00 \
  -d paymentaction=Sale \
  -d version=92.0 \
  -d user=${API_USER} \
  -d pwd=${API_PWD} \
  -d signature=${API_SIGNATURE}

That's it! You've just completed a basic transaction with Express Checkout. Now see what you can do with all of the advanced settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment