Airwallex logo
Airwallex logo

PayPal recurring payments

When processing a payment for the first time

Step 1: Create a Customer

Create a customer with the Create a Customer API API if the customer is new. Otherwise, this step is optional.

Step 2 : Create a Consent

Create a Payment Consent with the Create a Payment Conset API API.

POST /api/v1/pa/payment_consents/create

JSON
1{
2 "request_id": "11f408ba-cf3c-4bef-8897-69a16410a01e",
3 "customer_id": "cus_uspd6m9zph9g2fjvn1r",
4 "next_triggered_by": "merchant",
5 "merchant_trigger_reason": "unscheduled",
6 "requires_cvc": false
7}

Step 3 : Authorize the Consent

You have 2 authorization options, either by collecting the consent first or collecting the consent together with the first payment.

Option 1 : Authorize by Verify the Consent

Verify the consent with Verify a PaymentConsent API.

POST /api/v1/pa/payment_consents/{id}/verify

JSON
1{
2 "request_id": "139b8ee8-e306-47d6-8d6a-fa586967e5a9",
3 "payment_method": {
4 "type": "paypal"
5 },
6 "return_url": "http://return.url"
7}

Option 2 : Authorize by Pay the Order

Step 1 : Create an Intent

Create a Payment Intent with the Create a Payment Intent API API.

POST /api/v1/pa/payment_intents/create

JSON
1{
2 "request_id": "2c343609-5561-4c39-b055-bdaf89176555",
3 "amount": "79.65",
4 "email": "[email protected]",
5 "phone": "+8617601215499",
6 "currency": "USD",
7 "merchant_order_id":"order_id",
8 "order": {
9 "type": "v_goods",
10 "products": [
11 {
12 "code": "3414314111",
13 "name": "qqhtest0002",
14 "quantity": 1,
15 "sku": "piece",
16 "type": "physical",
17 "unit_price": 79.65,
18 "url": "test_url",
19 "desc": "test desc",
20 "effective_start_at": "2023-08-01T12:00:00Z",
21 "effective_end_at": "2023-08-01T12:00:00Z"
22 }
23 ],
24 "shipping": {
25 "first_name":"violet",
26 "last_name":"client",
27 "shipping_method": "sameday",
28 "address": {
29 "country_code": "DE",
30 "state": "Shanghai",
31 "city": "Shanghai",
32 "street": "Pudong District",
33 "postcode": "291201"
34 }
35 }
36 },
37 "return_url": "https://www.airwallex.com/",
38 "descriptor":"vip8888"
39}

step 2 : Confirm the Intent

Confirm the Intent with the Confirm a Payment Intent API API.

POST /api/v1/pa/payment_intents/{id}/confirm

JSON
1{
2 "request_id": "ccee1d83-329a-413a-bf18-2a322d981b11",
3 "payment_consent_id" : "cst_sgstpsvvwh90r3ooo4n",
4 "payment_method": {
5 "type": "paypal",
6 "paypal": {
7 "country_code": "US",
8 "shopper_name": "Amy"
9 }
10 },
11 "payment_method_options": {
12 "paypal": {
13 "auto_capture": "true"
14 }
15 }
16}

Once the shopper completes the payment or authorize the consent, the Payment Consent will be verified automatically, and Airwallex will notify you of the Payment Consent status asynchronously via the webhook. Please refer to the webhook documentation to set up your webhook accordingly.

When initiating a subsequent transaction

Step 1: Initialize a Payment Intent

When you are ready to process the subsequent recurring payment, create a Payment Intent with the Create a Payment Intent API API.

Step 2. Complete payment with verified consent

Confirm the subsequent payment with the verified Payment Consent by calling the Confirm a Payment Intent API API.

POST /api/v1/pa/payment_intents/{id}/confirm

JSON
1{
2 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
3 "payment_consent_id": "cst_sgstjgzhsh7hhmj8hr0",
4 "payment_method_options": {
5 "paypal": {
6 "auto_capture": "true"
7 }
8 }
9}
Was this page helpful?