Set up one-time payments

DocsLimited

Last updated: Apr 10th, 8:12pm

To set up one-time payments using Google Pay on the Web, integrate Google Pay as a payment method on the checkout page. Refer to the Google Pay API Documentation to learn more about adding Google Pay as a payment option.

After buyers authorize the payment, set up your client-side code to invoke the createOrder function in your server-side code to create an order and capture the payment.

Create a new order and capture payment

To indicate Google Pay as the payment method, include the google_pay object in the payment_source of the POST v2/checkout/orders request body.

  1. Sample request
  2. Sample response
1curl -v -k -X POST 'https://api-m.paypal.com:18824/v2/checkout/orders' \
2 -H 'Authorization: Bearer ACCESS-TOKEN' \
3 -H 'PayPal-Partner-Attribution-Id: PARTNER-ATTRIBUTION-ID' \
4 -H 'prefer: return=representation' \
5 -H 'PayPal-Request-Id: REQUEST-ID' \
6 -H 'Content-Type: application/json' \
7 -d '{
8 "intent": "AUTHORIZE",
9 "purchase_units": [
10 {
11 "reference_id": "REFID-000-1001",
12 "amount": {
13 "currency_code": "USD",
14 "value": "10.00"
15 },
16 "payee": {
17 "merchant_id": "123456789"
18 },
19 "shipping": {
20 "name": {
21 "full_name": "Firstname Lastname"
22 },
23 "email_address": "[email protected]",
24 "address": {
25 "address_line_1": "123 Main St",
26 "admin_area_2": "Anytown",
27 "admin_area_1": "CA",
28 "postal_code": "12345",
29 "country_code": "US"
30 }
31 }
32 }
33 ],
34 "payment_source": {
35 "google_pay": {
36 "name": "Firstname Lastname",
37 "email_address": "[email protected]",
38 "phone_number": {
39 "national_number": "5555555555"
40 },
41 "shipping": {
42 "name": {
43 "full_name": "Firstname Lastname"
44 },
45 "address": {
46 "address_line_1": "123 Main St",
47 "admin_area_2": "Anytown",
48 "admin_area_1": "CA",
49 "postal_code": "12345",
50 "country_code": "US"
51 }
52 },
53 "token": "TOKEN",
54 "card": {
55 "name": "Firstname Lastname",
56 "last_digits": "1111",
57 "brand": "VISA",
58 "type": "CREDIT",
59 "billing_address": {
60 "address_line_1": "123 Main St",
61 "admin_area_2": "Anytown",
62 "admin_area_1": "CA",
63 "postal_code": "12345",
64 "country_code": "US"
65 }
66 },
67 "assurance_details": {
68 "account_verified": true,
69 "card_holder_authenticated": true
70 },
71 "attributes": {
72 "verification": {
73 "method": "SCA_WHEN_REQUIRED"
74 }
75 }
76 }
77 }
78}'

Create a new order and capture payment with a funding primary account number

This use case shows a successful call to the Orders V2 API using a Funding Primary Account Number (FPAN), such as the actual card number with a decrypted payload.

  1. Sample request
  2. Sample response
1curl -v -k -X POST 'https://api-m.paypal.com:18824/v2/checkout/orders' \
2 -H 'Authorization: Bearer A21_A.AAdrxdkiuRbBELxKnxkD8iFRC915fLjE8XT6A9vhvArtOje7XLAYMzS-zmtNZ4ncmAnooSUs1eYuApRp7woIQpUNNd9lYg' \
3 -H 'PayPal-Partner-Attribution-Id: ABC_PLATFORM_PARTNER' \
4 -H 'prefer: return=representation' \
5 -H 'PayPal-Request-Id: 5e87b9b8-aa48-4278-ab99-ace6c5524da7' \
6 -H 'Content-Type: application/json' \
7 -d '{
8 "intent": "CAPTURE",
9 "purchase_units": [
10 {
11 "reference_id": "REFID-000-1001",
12 "amount": {
13 "currency_code": "USD",
14 "value": "10.00"
15 },
16 "payee": {
17 "merchant_id": "123456789"
18 },
19 "shipping": {
20 "name": {
21 "full_name": "Firstname Lastname"
22 },
23 "email_address": "[email protected]",
24 "address": {
25 "address_line_1": "123 Main St",
26 "admin_area_2": "Anytown",
27 "admin_area_1": "CA",
28 "postal_code": "12345",
29 "country_code": "US"
30 }
31 }
32 }
33 ],
34 "payment_source": {
35 "google_pay": {
36 "name": "Firstname Lastname",
37 "email_address": "[email protected]",
38 "phone_number": {
39 "national_number": "5555555555"
40 },
41 "shipping": {
42 "name": {
43 "full_name": "Firstname Lastname"
44 },
45 "address": {
46 "address_line_1": "123 Main St",
47 "admin_area_2": "Anytown",
48 "admin_area_1": "CA",
49 "postal_code": "12345",
50 "country_code": "US"
51 }
52 },
53 "decrypted_token": {
54 "message_id": "cJpaRj8xrSaDA0G37wP6VF9ZC",
55 "message_expiration": "1979502243000",
56 "payment_method": "CARD",
57 "card": {
58 "name": "Firstname Lastname",
59 "number": "1111111111111111",
60 "expiry": "2025-12"
61 },
62 "authentication_method": "PAN_ONLY"
63 },
64 "assurance_details": {
65 "account_verified": true,
66 "card_holder_authenticated": false
67 },
68 "attributes": {
69 "verification": {
70 "method": "SCA_WHEN_REQUIRED"
71 }
72 }
73 }
74 }
75}'

Create a new order and capture payment with a tokenized primary account number

This use case shows a successful call to the Orders V2 API using a Tokenized Primary Account Number (TPAN), such as the actual card number with a decrypted payload.

  1. Sample request
  2. Sample response
1curl -v -k -X POST 'https://api-m.paypal.com:18824/v2/checkout/orders' \
2 -H 'Authorization: Bearer A21_A.AAdrxdkiuRbBELxKnxkD8iFRC915fLjE8XT6A9vhvArtOje7XLAYMzS-zmtNZ4ncmAnooSUs1eYuApRp7woIQpUNNd9lYg' \
3 -H 'PayPal-Partner-Attribution-Id: ABC_PLATFORM_PARTNER' \
4 -H 'prefer: return=representation' \
5 -H 'PayPal-Request-Id: 5e87b9b8-aa48-4278-ab99-ace6c5524da7' \
6 -H 'Content-Type: application/json' \
7 -d '{
8 "intent": "CAPTURE",
9 "purchase_units": [
10 {
11 "reference_id": "REFID-000-1001",
12 "amount": {
13 "currency_code": "USD",
14 "value": "10.00"
15 },
16 "payee": {
17 "merchant_id": "123456789"
18 },
19 "shipping": {
20 "name": {
21 "full_name": "Firstname Lastname"
22 },
23 "email_address": "[email protected]",
24 "address": {
25 "address_line_1": "123 Main St",
26 "admin_area_2": "Anytown",
27 "admin_area_1": "CA",
28 "postal_code": "12345",
29 "country_code": "US"
30 }
31 }
32 }
33 ],
34 "payment_source": {
35 "google_pay": {
36 "name": "Firstname Lastname",
37 "email_address": "[email protected]",
38 "phone_number": {
39 "national_number": "5555555555"
40 },
41 "decrypted_token": {
42 "message_id": "cJpaRj8xrSaDA0G37wP6VF9ZC",
43 "message_expiration": "1979502243000",
44 "payment_method": "CARD",
45 "card": {
46 "name": "Firstname Lastname",
47 "number": "1111111111111111",
48 "expiry": "2025-12"
49 },
50 "authentication_method": "CRYPTOGRAM_3DS",
51 "cryptogram": "SaDA0Gw9cR37j8xrZP6VFCJpa",
52 "eci_indicator": "07"
53 },
54 "assurance_details": {
55 "account_verified": true,
56 "card_holder_authenticated": false
57 },
58 "attributes": {
59 "verification": {
60 "method": "SCA_WHEN_REQUIRED"
61 }
62 }
63 }
64 }
65}'

Create a new order with 3D Secure

This use case shows a successful call to the Orders V2 API that returns PAYER_ACTION_REQUIRED because Google Pay requires 3D Secure validation.

  1. Sample request
  2. Sample response
1curl -v -k -X POST 'https://api-m.paypal.com:18824/v2/checkout/orders' \
2 -H 'Authorization: Bearer A21_A.AAdrxdkiuRbBELxKnxkD8iFRC915fLjE8XT6A9vhvArtOje7XLAYMzS-zmtNZ4ncmAnooSUs1eYuApRp7woIQpUNNd9lYg' \
3 -H 'PayPal-Partner-Attribution-Id: ABC_PLATFORM_PARTNER' \
4 -H 'prefer: return=representation' \
5 -H 'PayPal-Request-Id: 5e87b9b8-aa48-4278-ab99-ace6c5524da7' \
6 -H 'Content-Type: application/json' \
7 -d '{
8 "intent": "CAPTURE",
9 "purchase_units": [
10 {
11 "amount": {
12 "currency_code": "USD",
13 "value": "10.00"
14 },
15 "payee": {
16 "merchant_id": "123456789"
17 },
18 "shipping": {
19 "name": {
20 "full_name": "Firstname Lastname"
21 },
22 "email_address": "[email protected]",
23 "address": {
24 "address_line_1": "123 Main St",
25 "admin_area_2": "Anytown",
26 "admin_area_1": "CA",
27 "postal_code": "12345",
28 "country_code": "US"
29 }
30 }
31 }
32 ],
33 "payment_source": {
34 "google_pay": {
35 "name": "Firstname Lastname",
36 "email_address": "[email protected]",
37 "phone_number": {
38 "national_number": "5555555555"
39 },
40 "decrypted_token": {
41 "message_id": "cJpaRj8xrSaDA0G37wP6VF9ZC",
42 "message_expiration": "1979502243000",
43 "payment_method": "CARD",
44 "card": {
45 "name": "Firstname Lastname",
46 "number": "1111111111111111",
47 "expiry": "2025-02"
48 },
49 "authentication_method": "PAN_ONLY"
50 },
51 "assurance_details": {
52 "account_verified": true,
53 "card_holder_authenticated": false
54 },
55 "attributes": {
56 "verification": {
57 "method": "SCA_ALWAYS"
58 }
59 }
60 }
61 }
62}'