Table of Contents Previous Next Index

Accepting PayPal in Express Checkout

Accepting PayPal in Express Checkout
By choosing Express Checkout, the customer can save time by skipping several checkout steps using the billing and shipping information stored on PayPal.
This section describes how to use Express Checkout to accept payments using PayPal and contains the following topics:
l
l
l
l
l
l
l
l
l
l
l
l
l
l
Basic Checkout with PayPal
See the Express Checkout Integration Guide for details on Express Checkout including page flow, integration points, button placement, and page design.
Express Checkout with PayPal requires the following steps:
1.
2.
3.
4.
In SetExpressCheckout response, you obtain a TOKEN that uniquely identifies this three-step transaction. You pass this TOKEN in the request to GetExpressCheckoutDetails and DoExpressCheckoutPayment. Both GetExpressCheckoutDetails and DoExpressCheckoutPayment return this TOKEN in the response.
This example shows basic checkout using the minimum number of parameters.
1. Starting the Checkout Using SetExpressCheckout
The SetExpressCheckout request method notifies PayPal that you are using Express Checkout to obtain payment from your customer.
You must always include the following parameters in SetExpressCheckout request:
l
l
l
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html
[successResponseFields]&TOKEN=EC-3DJ78083ES565113B
Note:
Save TOKEN for use on the remaining Express Checkout calls.
2. Redirecting the Customer’s Browser to PayPal Login Page
After you receive a successful response from SetExpressCheckout, add the TOKEN from SetExpressCheckout response as a name/value pair to the following URL, and redirect your customer’s browser to it:
https://www.paypal.com/cgi‑bin/webscr?cmd=_express‑checkout&
token=value_from_SetExpressCheckoutResponse
For redirecting the customer’s browser to the PayPal login page, PayPal recommends that you use the HTTPS response 302 “Object Moved” with the URL above as the value of the Location header in the HTTPS response. Ensure that you use an SSL-enabled server to prevent browser warnings about a mix of secure and insecure graphics.
3. Getting Payer Details Using GetExpressCheckoutDetails
The GetExpressCheckoutDetails method returns information about the customer, including name and address stored on PayPal.
You must always include the following parameters in GetExpressCheckoutDetails:
l
TOKEN: use the value from SetExpressCheckout response
The response contains this TOKEN and customer details.
[requiredSecurityParameters]&METHOD=GetExpressCheckoutDetails&
TOKEN=EC-3DJ78083ES565113B
[successResponseFields]&TOKEN=EC-3DJ78083ES565113B&EMAIL=abcdef@anyemail.com&
PAYERID=95HR9CM6D56Q2&PAYERSTATUS=verified&FIRSTNAME=John&
LASTNAME=Smith&COUNTRYCODE=US&
SHIPTONAME=John Smith&SHIPTOSTREET=144+Main+St.&
SHIPTOCITY=San+Jose&SHIPTOSTATE=CA&SHIPTOCOUNTRYCODE=US&
SHIPTOZIP=99221&ADDRESSID=PayPal&
ADDRESSSTATUS=Confirmed
Make sure TOKEN matches the value in SetExpressCheckout response.
Save PAYERID for use on the next call.
4. Making a Sale Using DoExpressCheckoutPayment
Request to obtain payment with PayPal Express Checkout using DoExpressCheckoutPayment request.
By default, you make a final sale with DoExpressCheckoutPayment request. You can also request authorization for later capture of payment. For more information, see “Authorizing for Multiple Captures”.
You must always include the following parameters in DoExpressCheckoutPayment request:
TOKEN: use the value from GetExpressCheckoutDetails response
PAYERID: use the value from GetExpressCheckoutDetails response
PAYMENTACTION: set to Sale. This is the default value in SetExpressCheckout.
AMT: use the same value as in SetExpressCheckout request
Table 3.3
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-0E881823PA052770A&AMT=10.00&
PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale
[successResponseFields]&TOKEN=EC‑0E881823PA052770A&
TRANSACTIONID=8SC56973LM923823H&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-22T20:16:05Z&AMT=10.00&
CURRENCYCODE=USD&FEEAMT=0.59&TAXAMT=0.00&
PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None
Controlling the Shipping Address Using SetExpressCheckout
You can make changes to the behavior of the shipping address with the REQCONFIRMSHIPPING, NOSHIPPING, and ADDROVERRIDE parameters in SetExpressCheckout request.
The shipping address is specified in the SHIPTOxxx parameters.
Requiring a Confirmed Address
To require that the shipping address be a PayPal confirmed address, set REQCONFIRMSHIPPING to 1 in SetExpressCheckout request.
Note:
The value of REQCONFIRMSHIPPING overrides the setting in your Merchant Account Profile
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html
&REQCONFIRMSHIPPING=1
[successResponseFields]&TOKEN=EC-0E881823PA052770A
Suppressing Display of Shipping Address on PayPal
To suppress the display of the customer’s shipping address on the PayPal web pages, set NOSHIPPING to 1 in SetExpressCheckout request. You might want to do this if you are selling a product or service that does not require shipping.
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html
&NOSHIPPING=1
[successResponseFields]&TOKEN=EC-17C76533PL706494P
GetExpressCheckoutDetails does not return the shipping address.
[requiredSecurityParameters]&METHOD=GetExpressCheckoutDetails&
TOKEN=EC-17C76533PL706494P
[successResponseFields]&TOKEN=EC-17C76533PL706494P&EMAIL=abcdef@anycompany.com&PAYERID=95HR9CM6D56Q2&
PAYERSTATUS=verified&FIRSTNAME=John&LASTNAME=Smith&COUNTRYCODE=US&
ADDRESSID=PayPal&ADDRESSSTATUS=None
Overriding the Shipping Address Stored on PayPal
To override the shipping address stored on PayPal, call SetExpressCheckout to set ADDROVERRIDE to 1 and set the shipping address fields (see Table A.11, “Ship to Address (Optional)”).
The customer cannot edit the address if it has been overridden.
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html
&SHIPTONAME=Peter+Smith&SHIPTOSTREET=144+Main+St.&SHIPTOCITY=SAN+JOSE
&SHIPTOSTATE=CA&SHIPTOCOUNTRYCODE=US&SHIPTOZIP=99911&
ADDROVERRIDE=1
[successResponseFields]&TOKEN=EC-17C76533PL706494P
GetExpressCheckoutDetails returns the overridden shipping address.
[requiredSecurityParameters]&METHOD=GetExpressCheckoutDetails&TOKEN=EC-17C76533PL706494P
[successResponseFields]&TOKEN=EC-17C76533PL706494P&
PAYER=abcdef@anycompany.com&PAYERID=95HR9CM6D56Q2&PAYERSTATUS=verified&
FIRSTNAME=John&LASTNAME=Smith&
COUNTRYCODE=US&SHIPTONAME=Peter+Smith&SHIPTOSTREET=144+Main+St.&
SHIPTOCITY=SAN+JOSE&SHIPTOSTATE=CA&SHIPTOCOUNTRYCODE=US&SHIPTOZIP=95112&
ADDRESSID=PayPal&ADDRESSSTATUS=Unconfirmed
Changing the Language on the PayPal Login Page
To change the language displayed on the PayPal login page, set LOCALECODE to one of the allowable values in SetExpressCheckout. For LOCALECODE values, see Table A.10, “SetExpressCheckout Request Parameters”. The following example sets LOCALECODE to French.
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
CURRENCYCODE=EUR&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html
&LOCALECODE=fr_FR
[successResponseFields]&TOKEN=EC-17C76533PL706494P
Changing the Logo on the PayPal Pages
You can modify the logo and other color settings on the PayPal pages in two ways:
l
l
Specifying a Custom Payment Page Style
You can set the Custom Payment Page Style for the PayPal pages by setting the PAGESTYLE parameter in SetExpressCheckout. Set PAGESTYLE to one of the Page Style Names you defined in your Custom Payment Pages on https://www.paypal.com.
The following example sets PAGESTYLE to DesignerFotos-Yellow in the SetExpressCheckout method
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html&
PAGESTYLE=DesignerFotos-Yellow
[successResponseFields]&TOKEN=EC-17C76533PL706494P
Specifying Logo and Color Settings Individually
You can modify the PayPal web pages to look like your own web pages by setting the following parameters in SetExpressCheckout:
l
HDRIMG: specify an image to appear at the top left of the payment page
l
HDRBORDERCOLOR: set the border color around the header of the payment page
l
HDRBACKCOLOR: set the background color for the background of the header of the payment page
l
PAYFLOWCOLOR: set the background color for the payment page
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html&
HDRIMG=https://www.anycompany.com/images/HeaderImage.gif&
HDRBORDERCOLOR=3366FF&HDRBACKCOLOR=D3EFF5&PAYFLOWCOLOR=F8F5F5
[successResponseFields]&TOKEN=EC-17C76533PL706494P
Form-Filling Your Payment Review Page
Use the payer name and shipping address returned by GetExpressCheckoutDetails response to fill in form fields on your payment review page which you display after the customer returns from PayPal.
[requiredSecurityParameters]&METHOD=GetExpressCheckoutDetails&
TOKEN=EC-3DJ78083ES565113B
[successResponseFields]&TOKEN=EC-3DJ78083ES565113B&EMAIL=abcdef@anyemail.com&
PAYERID=95HR9CM6D56Q2&PAYERSTATUS=verified&FIRSTNAME=John&LASTNAME=Smith&
COUNTRYCODE=US&SHIPTONAME=John Smith&SHIPTOSTREET=144+Main+St.&
SHIPTOCITY=San+Jose&SHIPTOSTATE=CA&SHIPTOCOUNTRYCODE=US&SHIPTOZIP=99221&
ADDRESSID=PayPal&ADDRESSSTATUS=Confirmed
Get the payer name from the following parameters in GetExpressCheckoutDetails response:
l
l
l
l
l
Get the shipping address from the following parameters in GetExpressCheckoutDetails response:
l
l
l
l
l
l
l
l
Making a Sale Using DoExpressCheckoutPayment
Use DoExpressCheckoutPayment to make a final sale.
For more information, see “Basic Checkout with PayPal”.
Authorizing for Single Capture
You can authorize payment for final sale by setting PAYMENTACTION to Authorization in SetExpressCheckout and DoExpressCheckoutPayment.
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=10.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html&
PAYMENTACTION=Authorization
[successResponseFields]&
TOKEN=EC-30P862430W113011F
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-30P862430W113011F&PAYERID=95HR9CM6D56Q2&AMT=10.00
PAYMENTACTION=Authorization
[successResponseFields]&TOKEN=EC-30P862430W113011F&
TRANSACTIONID=4D479374VP578364Y&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-22T22:02:42Z&AMT=10.00&
CURRENCYCODE=USD&TAXAMT=0.00&PAYMENTSTATUS=Pending&
PENDINGREASON=authorization&REASONCODE=None
Setting PAYMENTACTION to Order verifies that the customer account exists, but does not hold funds. To authorize the funds, you must additionally call the DoAuthorization API, specifying the amount of be authorized. In most cases, you call DoAuthorization directly after DoExpressCheckout in your payment flow in order to minimize the risk of capture declines.
Use the TRANSACTIONID from the DoExpressCheckoutPayment response as the value of TRANSACTIONID in the DoAuthorization request. Then use the AUTHORIZATIONID contained in the DoAuthorization response in the DoCapture request when capturing against the order. See “Making a Single Capture Using DoCapture” for more information on Authorization and Capture.
Authorizing for Multiple Captures
You can authorize payment for multiple captures by setting PAYMENTACTION to Order in SetExpressCheckout and DoExpressCheckoutPayment.
[requiredSecurityParameters]&METHOD=SetExpressCheckout&AMT=1.00&
RETURNURL=https://www.anycompany.com/orderprocessing/orderreview.html&
CANCELURL=https://www.anycompany.com/orderprocessing/shippinginfo.html&
PAYMENTACTION=Order
[successResponseFields]&TOKEN=EC-8NB10343BA3562027
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-8NB10343BA3562027&PAYERID=95HR9CM6D56Q2&AMT=1.00&
PAYMENTACTION=Order
[successResponseFields]&TOKEN=EC-8NB10343BA3562027&
TRANSACTIONID=O-2YX05090CA6454418&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=None&ORDERTIME=2006-08-22T22:22:03Z&AMT=1.00&
CURRENCYCODE=USD&TAXAMT=0.00&PAYMENTSTATUS=None&PENDINGREASON=order&
REASONCODE=None
Before making a capture against the order, you should first call DoAuthorization to authorize the amount of the tranaction. Use the TRANSACTIONID from DoExpressCheckoutPayment and use it for the value of TRANSACTIONID in DoAuthorization request.If most cases, you should call DoAuthorization directly after DoExpressCheckout in your payment flow.
Use the AUTHORIZATIONID contained in the DoAuthorization response in the DoCapture request when capturing against the order. See “Making Multiple Partial Captures Using DoCapture” for more information on Authorization and Capture.
For information about DoCapture, see “Capturing, Authorizing, Voiding, and Reauthorizing”.
Changing the URL for IPN
You can change the URL for receiving Instant Payment Notification (IPN) about this transaction by setting the NOTIFYURL parameter in DoExpressCheckoutPayment.
If you do not specify this value in the request, the notification URL from your Merchant Profile is used, if one exists.
For more information about IPN, see the Order Management Integration Guide.
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-8AX1275942659774U&PAYERID=95HR9CM6D56Q2&AMT=10.00&
PAYMENTACTION=Sale&NOTIFYURL=https://www.anycompany.com/process-ipn/
[successResponseFields]&TOKEN=EC-8AX1275942659774U&
TRANSACTIONID=1MA55216691247718&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-22T22:39:13Z&AMT=10.00&
CURRENCYCODE=USD&FEEAMT=0.59&TAXAMT=0.00&PAYMENTSTATUS=Completed&
PENDINGREASON=None&REASONCODE=None
Including Line Item Details Using DoExpressCheckoutPayment
You can include line item details by setting the following parameters in DoExpressCheckoutPayment:
l
L_NAMEn: item name or description
l
L_NUMBERn: line item number
l
L_QTYn: item quantity
l
L_TAXAMTn: sales tax for the item
l
L_AMTn: cost of item
You can detail as many items as you want. Beginning with 0, append an index number to the field name and increment that index number by one for each item.
The following example sets line item details for two items. These details are recorded on PayPal.
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-4XH62109C8044521N&PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale&AMT=6.24&
ITEMAMT=5.75&TAXAMT=0.49&L_NUMBER0=1&L_NAME0=A+Tale+of+Two+Cities&L_AMT0=2.50&
L_QTY0=1&L_TAXAMT0=0.21&L_NAME1=Oliver+Twist&L_NUMBER1=2&L_AMT1=3.25&L_QTY1=1&
L_TAXAMT1=0.28
[successResponseFields]&TOKEN=EC-4XH62109C8044521N&
TRANSACTIONID=77U91743M2649930P&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-22T22:49:50Z&AMT=6.24&
CURRENCYCODE=USD&FEEAMT=0.48&TAXAMT=0.28&PAYMENTSTATUS=Completed&
PENDINGREASON=None&REASONCODE=None
If you specify L_AMTn, you must specify the ITEMAMT parameter. The values for L_AMTn and L_QTYn should add up to the ITEMAMT.
If you specify L_TAXAMTn, you must specify the TAXAMT parameter. The values for L_TAXAMTn and L_QTYn should add up to TAXAMT.
Here are examples of ITEMAMT and TAXAMT:
ITEMAMT = (L_AMT0 * L_QTY0) + (L_AMT1 * L_QTY1) + L_AMT2
TAXAMT = (L_TAXAMT0 * L_QTY0) + (L_TAXAMT1 * L_QTY1) + L_TAXAMT2
Note:
If the line item details do not add up to ITEMAMT or TAXAMT, the line item details are discarded, and the transaction is processed using the values of ITEMAMT or TAXAMT. The ACK value in the response is set to SuccessWithWarning.
Including Subtotals Using DoExpressCheckoutPayment
If you want the PayPal user to see subtotals of item cost, shipping charges, handling charges, and sales tax, include the following parameters in DoExpressCheckoutPayment:
l
l
l
l
If you specify values for any of these subtotal amounts, the total of the values must equal the AMT field specified in the request. For example, in the example below, the sum of ITEMAMT, SHIPPINGAMT, HANDLINGAMT, and TAXAMT equals the value for AMT.
If one or more of the subtotals is zero, you can either include the field in the request with a value of zero, pass an empty string, or leave the field out of the request altogether. However, the sum of the remaining subtotal fields, if any are specified, must add up to AMT.
Table 3.19
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment
TOKEN=EC-0EU150885J108392M&PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale&
AMT=192.22&ITEMAMT=176.02&SHIPPINGAMT=14.34&HANDLINGAMT=1.10&TAXAMT=0.76
[successResponseFields]&TOKEN=EC-0EU150885J108392M&TRANSACTIONID=29W817045L6797418&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2006-08-23T16:20:22Z&AMT=192.22&CURRENCYCODE=USD&FEEAMT=5.87&TAXAMT=0.76&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None
Updating Transaction Details With DoExpressCheckoutPayment
You may need to update transaction details on PayPal if the customer makes a change to the transaction after returning to your order review page. If the change causes new values for one or more of the following parameters, you need to update the transaction details on PayPal using DoExpressCheckoutPayment:
l
DESC: item description
l
CUSTOM: field for your own use
l
INVNUM: your invoice or tracking number
These three parameters may have been set in SetExpressCheckout.
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC-5JA9268562132991T&PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale&AMT=10.00&
DESC=Order+for+5+books&CUSTOM=Thank+you+for+your+business!&INVNUM=ABC1234567
[successResponseFields]&TOKEN=EC-5JA9268562132991T&TRANSACTIONID=9JJ517146A732773R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2006-08-23T16:14:54Z&AMT=10.00&CURRENCYCODE=USD&FEEAMT=0.59&TAXAMT=0.00&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None
Updating Shipping Address With DoExpressCheckoutPayment
You may need to update the shipping address on PayPal if the customer updates the shipping address after returning to your order review page. If this happens, you need to update the shipping address for this transaction on PayPal.
You can update the shipping address by setting the following parameters in DoExpressCheckoutPayment:
l
l
l
l
l
l
l
l
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
TOKEN=EC‑47C20533CU265432F&PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale&AMT=10.00&
SHIPTONAME=Michael+Brown&SHIPTOSTREET=22+First+Street&SHIPTOCITY=Chicago&
SHIPTOCOUNTRYCODE=US&SHIPTOSTATE=IL&SHIPTOZIP=60605
[successResponseFields]&TOKEN=EC‑47C20533CU265432F&
TRANSACTIONID=59L39584YA765250B&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-23T16:08:12Z&AMT=10.00&
CURRENCYCODE=USD&FEEAMT=0.59&TAXAMT=0.00&PAYMENTSTATUS=Completed&
PENDINGREASON=None&REASONCODE=None
Express Checkout for eBay Auctions
You can use also use Express Checkout to check out for eBay auctions. You can mix eBay and non-eBay transactions in the same transaction.
If the buyer’s checkout includes eBay auctions, there are additional fields that you must set to control the behavior of Express Checkout.
In the SetExpressCheckout request:
l
PAYMENTACTION must be Sale
l
CHANNELTYPE must be eBayItem
Note:
For eBay auctions, you cannot set PAYMENTACTION to Authorization or Order. You must set PAYMENTACTION to Sale.
In the DoExpressCheckoutPayment request, you must set PAYMENTACTION to Sale. You must also provide line item details for each eBay auction so that the payment is properly reflected in My eBay.
Note:
For each line item, you must provide the following:
L_EBAYITEMNUMBERn and L_EBAYITEMAUCTIONTXNIDn
or
L_EBAYITEMORDERIDn
To properly reflect discounts, you can also supply negative line items, as in the following example.
Note:
The value that you supply for AMT must equal the total of the line item amounts that you supply.
[requiredSecurityParameters]&METHOD=DoExpressCheckoutPayment&
METHOD=DoExpressCheckoutPayment&TOKEN=EC‑47C20533CU265432F&
PAYERID=95HR9CM6D56Q2&PAYMENTACTION=Sale&AMT=14.99&ITEMAMT=14.99&
LNAME0=Item0&LAMT0=19.99&L_EBAYITEMNUMBER0=230128323048&
L_EBAYITEMAUCTIONTXNID0=0&
[successResponseFields]&TOKEN=EC‑47C20533CU265432F&
TRANSACTIONID=59L39584YA765250B&TRANSACTIONTYPE=expresscheckout&
PAYMENTTYPE=instant&ORDERTIME=2006-08-23T16:08:12Z&AMT=14.99&
CURRENCYCODE=USD&FEEAMT=0.00&TAXAMT=0.00&PAYMENTSTATUS=Completed&
PENDINGREASON=None&REASONCODE=None