Integrate EPS using the Orders API
Last updated: Feb 18th, 10:38pm
Render payment buttons and process payments with the Orders API.
Know before you code
- Request approval to enable EPS by visiting these sandbox and live links:
- Sandbox: https://www.sandbox.paypal.com/bizsignup/entry?product=eps&capabilities=EPS&country.x=<merchant's country>
- Live: https://www.paypal.com/bizsignup/add-product?product=eps&capabilities=EPS&country.x=<merchant's country>
- Partners: Be sure to onboard your merchants upfront, before they accept payments. Onboarding after making payments, specifically Progressive Onboarding, isn't supported for alternative payment methods.
Note: The integration steps for implementing alternative payment methods are similar. If you've integrated another alternative payment method before, you can reuse that code with adjustments for this payment method.
- Make sure you're subscribed to the following webhook events:
PAYMENT.CAPTURE.COMPLETED
- This webhook notifies about a successful order capture.PAYMENT.CAPTURE.DENIED
- This webhook tells you when an order capture fails.
- Make sure your preference for receiving payments in your PayPal business or merchant account is set to accept and convert to the currency in your account. In your profile, select Account Settings > Payment preferences > Block payments and click Update to mark this preference.
- When processing EPS payments, you don't need to capture payment for the order.
Offer EPS on the checkout page
You'll need to create the user interface to offer EPS and collect the buyer's information, then you'll use the API calls described in the remainder of this topic to:
- Create the order with buyer's
full_name,
country_code
and EPS as the payment source. - Redirect the buyer to EPS.
Refer to Payment method icons for icons you can use and download locations.
Create an order
Use the buyer information you captured from your user interface to create an order with EPS as the payment source.
API endpoint used: Create order
- Sample request
- Sample response
1curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders \2-H 'PayPal-Request-Id: <PayPal-Request-Id>' \3-H 'Authorization: Bearer <Access-Token>' \4-H "Content-Type: application/json" \5-d '{6 "intent": "CAPTURE",7 "payment_source": {8 "eps": {9 "country_code": "AT",10 "name": "John Doe"11 }12 },13 "processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",14 "purchase_units": [15 {16 "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",17 "amount": {18 "currency_code": "EUR",19 "value": "1.00"20 }21 }22 ],23 "application_context": {24 "locale": "en-AT",25 "return_url": "https://example.com/returnUrl",26 "cancel_url": "https://example.com/cancelUrl"27 }28 }'
Modify the code
After you copy the code in the sample request, modify the following:
Access-Token
- Your access token.PayPal-Request-Id
- Replace the sample ID with a unique ID you generate. This ID helps prevent duplicate authorizations in the event that the API call is disrupted. See also: API idempotencyintent
- To use an alternative payment method, this parameter must be set toCAPTURE
as it is in this sample code.payment_source
- Specifyeps
as the payment method and include the country code and account holder's full name.purchase_units: amount
- Pass the amount of the order and the currency code.processing_instruction
- Set this value toORDER_COMPLETE_ON_PAYMENT_APPROVAL
as it is in this sample code.application_context
- Specify the preferred language for returned errors, the URL the buyer is returned to after approving the purchase with their selected payment method, and the URL the buyer is returned to after canceling an approval with their selected payment method. Whilereturn_url
andcancel_url
are optional fields, this integration requires you specify them to handle the handoff from the payment method back to your site. You can use thecancel_url
to redirect buyers when an error occurs while they're on the payment method's site, so make sure your cancel URL works for that situation as well as an actual cancellation by the buyer.
Note: Change or add other parameters in the Create order request body to create an order that reflects the actual order details.
Step result
A successful request results in the following:
- A return status code of HTTP
200 OK
. - A JSON response body that contains the order ID. You'll use the order ID and
payer-action
HATEOAS URL in the next step. See also: HATEOAS links.
Redirect buyer for purchase approval
In your user interface, attach the payer-action
redirect URL returned in the Create Order
response to the EPS payment button. This sends the buyer to their bank to approve the purchase. Once the buyer approves the purchase, the payment is automatically captured.
In the sample, the redirect URL is: "https://www.sandbox.paypal.com/payment/eps?token=1BV95196WW992540E"
Step result
After successfully completing the bank approval:
- The buyer is redirected to the
return_url
mentioned in the Create Order request. - The
PAYMENT.CAPTURE.COMPLETED
webhook event is triggered, which indicates that payment capture was successful.
After unsuccessful bank approval:
- The buyer is redirected to the
cancel_url
mentioned in the Create Order request.
Listen to webhooks for payment status
Listen to the following webhooks to get the result of order capture:
- The
PAYMENT.CAPTURE.COMPLETED
webhook event indicates a successful order capture. - The
PAYMENT.CAPTURE.DENIED
webhook events indicate a failed order capture. - Optional: Use Show order details endpoint to determine the status of an order.
- The
up
HATEOAS link indicates the order associated with this capture.
- The
See Subscribe to checkout webhooks for more information.
Here are some additional resources as you create webhook handler code:
- Webhook Management API - Manage webhooks, list event notifications, and more.
- Webhook events
- Checkout webhook events - Checkout buyer approval-related webhooks.
- Order webhook events - Other order-related webhooks.
- Show order details endpoint - Determine the status of an order.
Sample webhook payloads
- Sample PAYMENT.CAPTURE.COMPLETED
- Sample PAYMENT.CAPTURE.DENIED
- Sample CHECKOUT.ORDER.DECLINED
1{2 "id": "WH-2B342482FC0449155-12X09416XP387753C",3 "event_version": "1.0",4 "create_time": "2022-04-05T10:37:05Z",5 "resource_type": "capture",6 "resource_version": "2.0",7 "event_type": "PAYMENT.CAPTURE.COMPLETED",8 "summary": "Payment completed for EUR 1.00 EUR",9 "resource": {10 "amount": {11 "value": "1.00",12 "currency_code": "EUR"13 },14 "supplementary_data": {15 "related_ids": {16 "order_id": "1BV95196WW992540E"17 }18 },19 "create_time": "2022-04-05T10:37:05Z",20 "update_time": "2022-04-05T10:37:05Z",21 "final_capture": true,22 "seller_receivable_breakdown": {23 "paypal_fee": {24 "value": "0.20",25 "currency_code": "EUR"26 },27 "gross_amount": {28 "value": "1.00",29 "currency_code": "EUR"30 },31 "net_amount": {32 "value": "0.80",33 "currency_code": "EUR"34 }35 },36 "custom_id": "Custom-1234",37 "invoice_id": "Invoice-12345",38 "links": [39 {40 "method": "GET",41 "rel": "self",42 "href": "https://api-m.sandbox.paypal.com/v2/payments/captures/56U00550J8319094C"43 },44 {45 "method": "POST",46 "rel": "refund",47 "href": "https://api-m.sandbox.paypal.com/v2/payments/captures/56U00550J8319094C/refund"48 },49 {50 "method": "GET",51 "rel": "up",52 "href": "https://api-m.sandbox.paypal.com/v2/checkout/orders/1BV95196WW992540E"53 }54 ],55 "id": "56U00550J8319094C",56 "status": "COMPLETED"57 },58 "links": [59 {60 "href": "https://api-m.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2B342482FC0449155-12X09416XP387753C",61 "rel": "self",62 "method": "GET"63 },64 {65 "href": "https://api-m.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2B342482FC0449155-12X09416XP387753C/resend",66 "rel": "resend",67 "method": "POST"68 }69 ]70}
- The order ID from Step 2 should match the
resource.supplementary_data.related_ids.order_id
parameter in the webhook payload. - When an order is declined,
Sample CHECKOUT.ORDER.DECLINED
webhook passes the error code and message in the most_recent_error parameter of the purchase_unit object.
Alternatively, you can get the order capture result from the Show order details endpoint.
- Sample request
- Sample response
1curl -v -X GET https://api-m.sandbox.paypal.com/v2/checkout/orders/1BV95196WW992540E \2 -H "Content-Type: application/json" \3 -H "Authorization: Bearer <Access-Token>"
Step result
A successful request returns the HTTP 200 OK
status code with a JSON response body that returns a COMPLETED
status.
A successfully captured order has the following:
- The order status as
COMPLETED
, which means the order was captured successfully. - A capture with
COMPLETED
status is present in the response parameterpurchase_units[0].payments.captures[0]
. - The
up
HATEOAS link indicates the order associated with this capture.
Notify buyer of payment success
After a successful payment, notify the buyer of a successful transaction. You can do this by sending a confirmation email.