Airwallex logo

Manually capturing payments - PayPal

Copy for LLMView as Markdown

This feature is only available for businesses registered in the US.

Step 1. Initialize a Payment Intent

Create a PaymentIntent object with a request_id, amount, currency, and a merchant_order_id from your backend server.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/create \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "amount": 100,
7 "currency": "USD",
8 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",
9 "return_url": "https://www.airwallex.com"
10 }'

Step 2. Redirect to PayPal to authorize payment

Call the Confirm a Payment Intent API API to get a redirect URL. Make sure to pass in the auto_capture: false parameter.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/confirm \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "auto_capture": "false",
7 "payment_method": {
8 "type": "paypal",
9 "paypal": {
10 "flow": "qrcode"
11 }
12 },
13 "payment_method_options": {
14 "paypal": {
15 "auto_capture": false
16 }
17 }
18 }'

Sample response:

JSON
1{
2 // ... other fields omitted
3 "next_action": {
4 "type": "redirect",
5 "method": "GET",
6 "url": "https://api.airwallex.com/pa/redirect/hk/hkpd4p9fqhglbzo0wd4_zbgpkh?checksum=6efc881f3ff5"
7 }
8}

Redirect the shopper to the URL provided in the next_action.url field to authorize the payment on PayPal.

Step 3. Manually capture the payment

After the shopper has authorized the payment on PayPal, call the Capture a PaymentIntent API API to capture the payment.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/capture \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "amount": 0.5
7 }'
Was this page helpful?