PayPal
Last updated: August 14, 2024
Information
PayPal is also available through Flow. Flow enables you to accept payments on your website using Checkout.com's global network of payment methods with a single integration.
PayPal enables customers to make online payments securely using any credit or debit card connected to their PayPal account.
PayPal supports the following checkout experiences:
- Pay Now: final payment page experience.
Customers complete the payment on the PayPal pop-up. - Continue: item and basket page experience.
Customers complete the payment on the merchant's order review page - Pay Later payments
Additionally, it supports automatic and manual capture of the payment:
- use auto capture if your goods or services are available immediately after purchase – for example, digital goods or tickets
- use manual capture if your goods or services are not available immediately after purchase – for example, shipped goods
Information
To enable PayPal payments on your account, contact your Account Manager or [email protected].
Model | Gateway |
---|---|
Payment flow | Direct |
Auto capture | Payments are captured immediately after authorization by default. |
Manual capture | Full and Partial capture. |
Refund | Full and Partial capture. |
Disputes | All disputes are handled directly via PayPal. |
Chargeback | All chargebacks are handled directly via PayPal. |
Recurring payment |
The payment flow varies depending on the payment experience you want to offer and how you capture the payment. As a general guide, you should:
- Configure the front-end PayPal JS SDK.
- Request a Checkout.com payment context.
- Open the PayPal pop-up.
- If you offer a Continue payment experience, you must get the latest customer data from PayPal to create an order review page.
- Request a payment.
- If you are using a manual capture payment, you must also capture the payment.
You can use the JavaScript SDK to render the buttons and payment method icons in any page of your store.
- Initialize the PayPal JS SDK by adding it in a
<script>
tag:
<script src="https://www.paypal.com/sdk/js?client-id={YOUR_CKO_ENV_CLIENT_ID}&merchant-id={YOUR_PAYPAL_MERCHANT_ID}&disable-funding=credit,card,sepa&commit=false" data-partner-attribution-id="CheckoutLtd_PSP"></script>
The PayPal JS SDK accepts the following query parameters:
Query parameter | Description |
---|---|
| The client ID for the Checkout.com environment you are configuring the SDK for. If you are configuring your Test environment, use the value: If you are configuring your Live environment, use the value: |
| Your PayPal merchant ID. Checkout.com will provide you with your ID during your integration. |
| Specifies which funding sources to disable for the transaction. Checkout.com only supports PayPal Direct Payment. You must set this query parameter to |
| Specifies which funding sources to enable for the transaction. To enable the PayPal Pay Later option, this value must be set to
|
| Specifies which checkout experience button to display in the PayPal pop-up:
|
Additionally, you must configure the following script parameter as follows:
Script parameters | Value |
---|---|
|
|
| The country the customer is located in, which is used to determine the funding sources they are eligible for. If you do not provide a value, this defaults to their IP geolocation. |
| The currency for the transaction. If you do not provide a value, this defaults to USD. |
- Place a
<div>
wrapper on the page you want to render the PayPal button:
1<div id="paypal-button-container"></div>
- Add a
<script>
wrapper under the<div>
buttons call and configure the actions for the buttons:
1<script>2paypal3.Buttons({4createOrder() {5// your custom handler to return the order_id string6return getOrderId();7},8onApprove: async function (data) {9// your custom handler to continue after the user approval of the transaction10handlePaymentApproval();11},12})13.render('#paypal-button-container');14</script>
The PayPal JavaScript configuration documentation provides additional information.
A Checkout.com payment context request will return an order_id
, which is required when you configure subsequent requests.
To make it easier to reconcile the payment at a later date, include the following fields in your request:
reference
processing.invoice_id
Information
The Payment Contexts API supports idempotency. You can safely retry API requests without the risk of duplicate requests.
post
https://api.checkout.com/payment-contexts
1{2"source": {3"type": "paypal"4},5"currency": "USD",6"amount": 2000,7"capture": false,8"items": [9{10"name": "laptop",11"unit_price": 2000,12"quantity": 113}14],15"processing": {16"invoice_id": "12345",17"user_action": "pay_now"18},19"processing_channel_id": "{{PayPal-processingChannel-personal}}",20"success_url": "http://www.example.com/success.html",21"failure_url": "http://www.example.com/failure.html"22}
You can find the full list, as well as complete request and response examples, in our API reference.
If you receive a 201 Created
success status response code your request was successful.
In the response, you'll receive an order ID in the partner_metadata
field. You can pass this order ID to the PayPal SDK's createOrder()
method.
1{2"id": "pct_ckjrpk7vux4ejhghe6ssgkoy2y",3"partner_metadata": {4"order_id": "7YP86878G2990415D"5},6"_links": {7"self": {8"href": "https://api.checkout.com/payment-contexts/pct_ckjrpk7vux4ejhghe6ssgkoy2y"9}10}11}
Use the Pay Now checkout experience if you know the final payment amount when you initiate the payment flow:
- Set the
user_action
field topay_now
in the request. - Include
commit=true
in the JS script URL to display a Complete purchase button in the flow.
When the customer selects Complete purchase, the payment is completed without requiring any further action from them.
Use the Continue checkout experience if you want to present PayPal as an option upfront for a faster checkout experience and higher conversion rates.
- Set the
user_action
field tocontinue
in the request. - Include
commit=false
in the JS script URL to display a Continue to Review Order button in the flow.
Information
If you do not specify the user_action
field in your request, the Continue payment flow is used by default.
When the customer selects Continue to Review Order, they will be redirected to the PayPal payment page. There, customers can edit their shipping address or adjust their shipping option before submitting the order.
While the customer is on the PayPal page, you can update their shopping cart to include additional shipping costs. PayPal provides shipping configuration in the shipping_preference
field using the following values:
no_shipping
- shipping does not have to be defined, usually for digital goods and services where physical delivery is not required.set_provided_address
- the customer uses the merchant-provided address; the customer can only update the address if you do not provide one.get_from_file
- Collects the shipping details from the PayPal widget. This is the default value.
Information
If you set "shipping_preference": "set_provided_address"
, the following fields are mandatory:
address_line1
country
, as a two-character country code
Manage the order via the PayPal JS SDK:
a. In the
createOrder()
handler of your script, use theorder_id
returned from the payment context request.b. Use the
onApprove()
handler to continue to the next step in your payment flow after your customer transaction is approved.
If you implement a Continue checkout experience, you must:
- Retrieve the latest customer data after the customer confirms payment in PayPal pop-up.
- Display this information on the Review Order page.
You can use the updated information from the payment context when you request a payment later.
In the front end, once the customer confirms the payment in the PayPal pop-up, you can use the onApprove()
callback function to get information from the user’s session on PayPal’s side. The response will contain all fields required to create the payment.
get
https://api.checkout.com/payment-contexts/{id}
1{2"payment_request": {3"source": {4"type": "paypal"5},6"amount": 2000,7"currency": "USD",8"payment_type": "Regular",9"authorization_type": "Final",10"capture": false,11"customer": {12"name": "Toby Smith",13"email": "[email protected]"14},15"shipping": {16"first_name": "Toby",17"last_name": "Smith",18"address": {19"address_line1": "1 Main St",20"city": "San Jose",21"state": "CA",22"zip": "95131",23"country": "US"24}25},26"items": [27{28"name": "laptop",29"quantity": 1,30"unit_price": 200031}32],33"success_url": "http://www.example.com/success.html",34"failure_url": "http://www.example.com/failure.html",35"processing_channel_id": "pc_zmcw5ppbvr3ullkdlza6u4teoi"36},37"partner_metadata": {38"customer_id": "WDB9U9PV7Y2KY",39"order_id": "7YP86878G2990415D"40}41}
post
https://api.checkout.com/payments
On the final order review page, the customer has the option to update the following details, which may affect the total payment amount:
- shipping address
- shipping method
If the customer does not make any changes, you can use the following request example:
1{2"payment_context_id":"pct_ckjrpk7vux4ejhghe6ssgkoy2y",3"processing_channel_id": "{{NAS-processingChannel-personal}}"4}
If the customer updates either of the shipping details, you must provide updated values in your payment request. Your request should only include the fields impacted by the customer's update to the shipping details. For example:
- the new
shipping.address
- the new
amount
, to reflect the change in shipping method or address
1{2"payment_context_id":"pct_ckjrpk7vux4ejhghe6ssgkoy2y",3"shipping": {4"first_name": "Toby",5"last_name": "Arden",6"address": {7"address_line1": "1 Main St",8"city": "San Jose",9"state": "CA",10"zip": "95131",11"country": "US"12},13"processing_channel_id": "{{NAS-processingChannel-personal}}"14}15}
Your request was successful if you receive a 202 Success
response code which contains the status
field set to Pending
.
1{2"id": "pay_z7wmqrxtmkouzlhhvyxuc3ecxq",3"status": "Pending",4"customer": {5"id": "cus_qypaijolqf5enei2y5b5men32m",6"email": "[email protected]",7"name": "John Doe"8},9"processing": {10"partner_order_id": "7YP86878G2990415D"11},12"_links": {13"self": {14"href": "https://api.checkout.com/payments/pay_z7wmqrxtmkouzlhhvyxuc3ecxq"15}16}17}
You can choose to automatically capture the payment, or capture it manually at a later time. By default, PayPal is configured to auto capture the payment.
- to automatically capture the payment: set
"capture": true
in the payment context request - to manually capture the payment: set
"capture": false
in the payment context request and set&intent=authorize
query parameter in the JS SDK call:<script src="https://www.paypal.com/sdk/js?client-id=ASLqLf4pnWuBshW8Qh8z_DRUbIv2Cgs3Ft8aauLm9Z-MO9FZx1INSo38nW109o_Xvu88P3tly88XbJMR&merchant-id={YOUR_PAYPAL_MERCHANT_ID}&intent=authorize&disable-funding=credit,card,sepa&commit=false" data-partner-attribution-id="CheckoutLtd_PSP">
A successful authorization places a hold on the customer's funds. With the manual capture flow, you can capture the funds at a later point in time. For example, if you need to verify that the item the customer purchased is still in stock.
Information
Manual capture should be triggered when you ship the items.
Checkout.com can perform full and multiple partial captures for the payment.
Information
If the capture amount is equal to the authorized amount, we will consider the capture final
If the capture amount is less than the authorized amount, but you send a capture request with "capture_type": "final"
, we'll consider the capture final and release the remaining authorized amount. If you do not specify a capture_type
in your request, final
is used by default.
For more information on capturing a payment, see the Capture a payment page.
If you want to use full capture, pass the payment_id
in the request.
post
https://api.checkout.com/payments/{id}/captures
Response example
If you receive a 202 Success
response, your request was successful.
1{2"action_id": "act_y3oqhf46pyzuxjbcn2giaqnb44",3"_links": {4"payment": {5"href": "https://api.sandbox.checkout.com/payments/pay_y3oqhf46pyzuxjbcn2giaqnb44"6}7}8}
To perform multiple partial capture, pass "capture_type": NonFinal
in the capture request.
You can also use "capture_type": Final
.
post
https://api.checkout.com/payments/{id}/captures
Request example
1{2"amount": 1000,3"capture_type": "NonFinal"4}
Response example
If you receive a 202 Success
response containing the Action ID, your request was successful.
1{2"action_id": "act_y3oqhf46pyzuxjbcn2giaqnb44",3"_links": {4"payment": {5"href": "https://api.sandbox.checkout.com/payments/pay_y3oqhf46pyzuxjbcn2giaqnb44"6}7}8}
A billing agreement between you and PayPal is required to allow recurring payments.
To configure recurring payments you must:
- make the initial payment using auto capture.
- configure your payment context requests to include the following fields and values:
capture
set totrue
payment_type
set torecurring
processing.plan.type
set to one of the values from the following table:
Plan type | Description |
---|---|
| Recommended as default. If an existing agreement is found, PayPal returns the same billing agreement ID that was issued previously. Customers will only see one agreement with the same merchant. |
| A new agreement ID is issued for each onboarding customer. |
| Refers to partner hosted agreements. These are no longer allowed within the EU. |
| Refers to partner hosted agreements. These are no longer allowed within the EU. |
You can find complete lists of all required and optional fields in our API reference.
post
https://api.checkout.com/payment-contexts
1{2"source": {3"type": "paypal"4},5"currency": "USD",6"amount": 2000,7"capture": true,8"payment_type": "Recurring",9"items": [10{11"name": "laptop",12"unit_price": 2000,13"quantity": 114}15],16"processing": {17"plan": {18"type": "merchant_initiated_billing"19}20},21"processing_channel_id": "{{NAS-processingChannel-personal}}",22"success_url": "http://www.example.com/success.html",23"failure_url": "http://www.example.com/failure.html"24}
201 Created
success status response code with an order id your request was successful.
1{2"id": "pct_pn3qgabosnjefd5mqhvnwkgeyq",3"partner_metadata": {4"order_id": "BA-2MT22297HW5277538"5},6"_links": {7"self": {8"href": "https://api.checkout.com/payment-contexts/pct_pn3qgabosnjefd5mqhvnwkgeyq"9}10}11}
Ensure you keep the payment ID (source.id
) from this response as you will need it to set up the subsequent payment requests.
Once the initial payment is successfully captured, you can trigger subsequent payments based on your schedule.
- Add
&intent=tokenize
and&vault=true
to the JS SDK script if the payment is set as recurring:
1<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&merchant-id=YOUR_Merchant_ID&vault=true"></script>
- Replace the
createOrder()
function in the SDK code withcreateBillingAgreement()
.
post
https://api.checkout.com/payments/
Use this request only if the customer did not make any changes in the final review page.
1{2"payment_context_id":"pct_ckjrpk7vux4ejhghe6ssgkoy2y",3"processing_channel_id": "{{NAS-processingChannel-personal}}"4}
Your request was successful if you receive a 202 Success
status response code which contains a status
field set to Pending
, and an id
field.
You must store the source.id
from this response to use it in subsequent requests.
1{2"id": "pay_myvk2vuj3dgeffho6iuretryfm",3"status": "Pending",4"source": {5"id": "src_fkhtu6spgqfelnndfqcjpsnaae",6"type": "paypal"7},8"processing": {9"partner_order_id": "7GU48395JD5519252"10},11"_links": {12"self": {13"href": "https://api.checkout.com/payments/pay_myvk2vuj3dgeffho6iuretryfm"14}15}16}
To set up subsequent payment requests:
- Your customer must accept the billing agreement in the PayPal pop-up widget.
- The initial payment status must be
Captured
. - You must use the
source.id
from the initial payment response to initiate subsequent payment requests.
post
https://api.checkout.com/payments/
1{2"source": {3"type": "id",4"id": "src_fkhtu6spgqfelnndfqcjpsnaae"5},6"merchant_initiated": true,7"currency": "USD",8"amount": 2000,9"items": [10{11"name": "laptop",12"unit_price": 2000,13"quantity": 114}15],16"processing_channel_id": "{{NAS-processingChannel-personal}}",17"success_url": "http://www.example.com/success.html",18"failure_url": "http://www.example.com/failure.html",19"payment_type": "recurring"20}
Your request was successful if you receive a 202 Success
response with the status
field set to Pending
.
1{2"id": "pay_ok7yhvutuylevnatk3x3dxviq4",3"status": "Captured",4"source": {5"id": "src_fkhtu6spgqfelnndfqcjpsnaae",6"type": "paypal"7},8"processing": {9"partner_order_id": "83U53060E16713839"10},11"_links": {12"self": {13"href": "https://api.checkout.com/payments/pay_ok7yhvutuylevnatk3x3dxviq4"14}15}16}
PayPal's Seller Protection program can help protect you in the event of claims, chargebacks, or reversals raised due to an unauthorized transaction or missing items.
Information
For more information on your eligibility and what the Seller Protection program covers, refer to PayPal's documentation.
You must provide the customer's full name and address in the payment context request for a transaction to be eligible for Seller Protection.
Typically, digital goods only benefit from Seller Protection if you have an explicit agreement with PayPal. If you have an agreement, you must also provide the processing.partner_customer_risk_data
field in your payment context request.
When you perform an eligible test payment, the transaction will be marked as Seller Protection-eligible in the sandbox environment. Contact your Account Manager for more information.
PayPal offers customers the option to pay for their purchase over multiple short-term, interest-free payments with the Pay Later checkout experience.
To be eligible to offer your customers the Pay Later option on the checkout page, you must:
- be based in Australia, France, Germany, Italy, Spain, or the United States
- have a publicly available website in the country you're offering the Pay Later option in
- perform transactions in the local currency
- offer the Pay Now or Continue checkout experiences alongside the Pay Later option
- adhere to the PayPal Acceptable Use Policy
The installment options available to your customers depend on the country in which you're offering the Pay Later option and the purchase amount:
Country | Pay Later option | Installments | Payment schedule | Purchase amount |
---|---|---|---|---|
Australia | Pay in 4 | 4 | The first payment is due at the time of the transaction. Subsequent payments are due every two weeks. | 30 - 2,000 AUD |
France | Pay in 4 | 4 | The first payment is due at the time of the transaction. Subsequent payments are due every month. | 30 - 2,000 EUR |
Germany | PayPal Ratenzahlung | 3, 6, 12, or 24 | Monthly | 99 - 5,000 EUR |
Pay in 30 | 1 | After 30 days of purchase | 1 - 1000 EUR | |
Italy | Pay in 3 | 3 | The first payment is due at the time of the transaction. Subsequent payments are due every month. | 30 - 2,000 EUR |
Spain | Pay in 3 | 3 | The first payment is due at the time of the transaction. Subsequent payments are due every month. | 30 - 2,000 EUR |
United States | Pay in 4 | 4 | Every two weeks | 30 - 1,500 USD |
Pay Monthly | 6, 12, or 24 | Monthly | 169 - 10,000 USD |
To display the Pay Later button, you must configure the following query parameters in your JS SDK call:
enable-funding
set topaylater
buyer-country
set to one of the supported countriescurrency
set to the local currency for the selected country
For example, to configure Pay Later in the United States, your <script>
tag should look as follows:
<script src="https://www.paypal.com/sdk/js?{YOUR_CKO_ENV_CLIENT_ID}&merchant-id={YOUR_PAYPAL_MERCHANT_ID}&enable-funding=paylater¤cy=USD&buyer-country=US" data-partner-attribution-id="CheckoutLtd_PSP"></script>
After you requested the payment. you can use the payment_id
found in the payment response to retrieve details about the payment.
For more details, see our API reference.
PayPal supports both partial and full refunds. PayPal refunds are based on the capture and not on the payment. You must specify the capture_action_id
in your refund request if you perform multiple captures.
You can refund payment through the dashboard or using the Refund API.
Information
If you refund or void a transaction directly via PayPal instead of using our API or Dashboard, the payment status will not sync back with Checkout.com.
post
https://api.checkout.com/payments/{id}/refunds
1{2"amount": 1003}
1{2"actionId": "act_cxpffngdvouvabegyy3asiuou",3"_links": {4"payment": {5"href": "https://api.checkout.com/payments/pay_ok7yhvutuylevnatk3x3dxviq4"6}7}8}
If you perform multiple partial captures, you must make a partial or full refund on the specific capture based on the capture ID assigned to it. You do this by specifying the capture_action_id
and amount
fields in your refund request.
Information
If you perform multiple partial captures, the refund amount cannot exceed the amount of that specific capture. You can see the capture amount and the capture action id using our GET action endpoint.
post
https://api.checkout.com/payments/{id}/refunds
1{2"amount": 1000,3"capture_action_id" : "act_d2on4akgfwfexg3ye65la3udtq"4}
1{2"actionId": "act_d2on4akgfwfexg3ye65la3udtq",3"reference": "ORD-5023-4E89",4"_links": {5"payment": {6"href": "https://api.checkout.com/payments/pay_jwvjl5tin54ubn7x2stvmunske"7}8}9}
When you create a payment using the auto capture payment flow, you cannot void it.
If you wish to reverse a payment in progress, wait for the payment_captured
webhook and then process a refund. See the webhooks section for more information about the webhooks you may receive.
A payment can be fully voided if it has been authorized but not yet captured. PayPal does not support partial voids.
post
https://api.checkout.com/payments/{id}/voids
1{2"action_id": "act_y3oqhf46pyzuxjbcn2giaqnb44",3"reference": "ORD-5023-4E89",4"_links": {5"payment": {6"href": "https://api.sandbox.checkout.com/payments/pay_y3oqhf46pyzuxjbcn2giaqnb44"7}8}9}
To test your integration, you'll need a PayPal developer account.
With your developer account, you can create:
- a PayPal sandbox environment
- a PayPal Business sandbox account
- a PayPal Personal sandbox account to test payments
- Create a PayPal developer account, if you do not already have one.
- Using your developer account, create PayPal Business and Personal sandbox accounts.
Information
To see your test payments, you must create your sandbox accounts using your PayPal developer account.
For more details, see the PayPal sandbox testing guide.
The following table provides an overview of the PayPal accounts required for your test integration:
Account type | Description | Purpose |
---|---|---|
Developer | PayPal developer account. | Access the PayPal developer dashboard, create and manage Business and Personal sandbox accounts. |
Business | PayPal sandbox Business account. For example, with an email address ending in | Add PayPal as a payment method in your test Customer Area. Provide the Merchant ID and email address of this account. |
Personal | PayPal sandbox Personal account. For example, with an email address ending in | Test payments from a customer's side. |
After you created a PayPal developer and sandbox accounts, you're ready to start testing:
- Reach out to your Account Manager or [email protected] to activate PayPal payments in the sandbox environment.
- Create a PayPal transaction, by following the PayPal Payment flow and using either an Auto-capture, Manual-capture, or Recurring payment flow.
- Log in to the test customer's PayPal account.
You will then be redirected to your predefined success URL.
Information
We strongly recommend that you use a generic company email address for your live PayPal Business account instead of a personal email address. This is to prevent having to configure a new account for your business if the personal email address is no longer in use in the future.
Log in to PayPal with your live Business account.
Follow PayPal's Merchant Account Admin Guide on granting third-party permissions. Under Permissions, select the following items:
- Use Express Checkout to process payments
- Issue a refund for a specific transaction
- Process your shopper's credit or debit card payments
- Authorize and capture your PayPal transactions
- Obtain information about a single transaction
- Obtain authorization for pre-approved payments and initiate pre-approved transactions
- Generate consolidated reports for all accounts - if available in your region
- Use Express Checkout to process mobile payments - if you plan on supporting mobile payments
If you're using PayPal for recurring payments, also select the following boxes:
- Charge an existing customer based on a prior transaction
- Create and manage Recurring Payments
Using the processing.airline_data
field, airlines must provide additional information about the ticket, passenger, and flight in their payment context request:
1{2"processing": {3"airline_data": [4{5"ticket": {6"number": "045-21351455613",7"issue_date": "2023-05-20",8"issuing_carrier_code": "AI",9"travel_agency_name": "World Tours",10"travel_agency_code": "01"11}12},13{14"passenger": [15{16"first_name": "Toby",17"last_name": "Smith",18"date_of_birth": "1990-05-26",19"address": {20"country": "US"21}22}23]24},25{26"flight_leg_details": [27{28"flight_number": "101",29"carrier_code": "BA",30"class_of_travelling": "J",31"departure_airport": "LHR",32"departure_date": "2023-06-19",33"departure_time": "15:30",34"arrival_airport": "LAX",35"stop_over_code": "X",36"fare_basis_code": "SPRSVR"37},38{39"flight_number": "103",40"carrier_code": "BA",41"class_of_travelling": "J",42"departure_airport": "LAX",43"departure_date": "2023-06-23",44"departure_time": "15:30",45"arrival_airport": "LHR",46"stop_over_code": "X",47"fare_basis_code": "SPRSVR"48}49]50}51]52}53}
Webhook | Description |
---|---|
| Sent when a payment request has been successfully initiated. |
| Sent when payment is approved by the customer. |
| Sent when the payment has been successfully captured. |
| Sent when a payment request has been rejected. |
| Sent when a payment request has been rejected. |
| Occurs when a payment reached its expiry date without being captured |
| Sent when payment is voided after authorization. |
| Sent when void request is declined. |
| Sent when the payment has been (fully or partially) refunded. |
| Sent when a refund has been declined. |