We provide a full suite of APIs that allow you to process and manage PayPal transactions, along with simple consolidated reporting of all your payment methods through Ecommerce Portal. Specific requests to initiate, execute, capture and refund PayPal transactions are supported.
For direct API integration, the standard flow for a PayPal transaction works like this:
Each PayPal transaction consists of at least two messages, but the full lifecycle of a PayPal transaction might consist of five or more requests, including capturing amounts and refunding transactions (for more information, see the API Reference for PayPal). To complete authentication and transaction authorization, the customer must be redirected to PayPal. This must be completed between initiation and execution of the transaction.
All PayPal request messages have a similar structure, with the message broken up into five sections. We subject all inbound request messages to validation to ensure that they are structurally correct. The order of fields in the message is important – where mandatory fields are included out of order, the transaction may be rejected.
payment-set (initiation) and payment-do (execution) API requests are required to complete all PayPal transactions.payment-set request, redirect the customer to PayPal to facilitate authentication.payment-get (retrieval) is optional, and may be used to retrieve additional data about the customer (such as their shipping address).payment-settle and payment-void may only be used with transactions which have not been automatically settled (captured) by the payment-set request.payment-credit can be used with any existing transaction to return funds to customers.The payment-set request is used to advise PayPal of the details of a new transaction and to retrieve the necessary details required to facilitate authentication. The response will contain a token that your application can use when redirecting your customer to PayPal.
A successful PayPal transaction will return a 00 success code, even though standard non-card transactions usually return a 01 success code.
<?xml version= "1.0" encoding= "UTF-8"?>
<request type="payment-set" timestamp="20180802120019">
<merchantid>MerchantId</merchantid>
<account>internet</account>
<amount currency="EUR">1001</amount>
<autosettle flag="1"/>
<orderid>IgGjoyQSRXqRyIvG30S5zQ</orderid>
<paymentmethod>paypal</paymentmethod>
<paymentmethoddetails>
<ReturnURL>https://www.example.com/success</ReturnURL>
<CancelURL>https://www.example.com/failure</CancelURL>
</paymentmethoddetails>
<sha1hash>2d630f0d401ee62c711db6ab37b79f2ad43f201e</sha1hash>
</request>The next step is to redirect the customer to PayPal to facilitate authentication. The token returned in the payment-set response must be included in the URL.
On the PayPal website, after authentication, the customer can proceed in two ways:
ReturnURL. Also returned will be the PayerID, which you must include in the final request.CancelURL. The result code will be 110.<!DOCTYPE html>
<html>
<head>
<title>Sample PayPal Redirect</title>
<meta charset="UTF-8">
</head>
<body>
<script>
window.location = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN";
<!-- Production URL https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<token> -->
</script>
</body>
</html>The response from PayPal for a completed transaction will encode additional transaction data in the URL query string, which you'll need for the next request.
https://<ReturnURL>?pasref=<pasref>&token=<token>&PayerID=<PayerID>
<!-- Sample -->
https://www.example.com/success?pasref=14627849160897986&token=EC-1RR24128VW167394F&PayerID=LPLWNMTBWMFAYReturnURL | Provided in the payment-set request |
pasref | Unique reference we assign for the transaction |
token | PayPal transaction token |
PayerID | Unique identifier for the customer returned by PayPal |
The final step is the payment-do request, which is used to execute a successfully authenticated and authorized transaction. The Order ID, Payments Reference, token, and PayerID from the previous steps must be submitted.
<?xml version="1.0" encoding="UTF-8"?>
<request type="payment-do" timestamp="20180802120019">
<merchantid>MerchantId</merchantid>
<account>internet</account>
<amount currency="EUR">1001</amount>
<orderid>IgGjoyQSRXqRyIvG30S5zQ</orderid>
<pasref>14627849160897986</pasref>
<paymentmethod>paypal</paymentmethod>
<paymentmethoddetails>
<Token>EC-8U990772BK865951U</Token>
<PayerID>RR2X8...GE4YY</PayerID>
</paymentmethoddetails>
<sha1hash>1f670bb08e62cb33e42ec69dd1c0e8809a129db7</sha1hash>
</request>Explore more functionality to enrich your application.