API reference
Create a paypal payment
How to create a paypal payment via API
To create a new paypal payment, send a POST request to the /api/paypal_payments endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/paypal_payments

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.return_url
string
Required
attributes.cancel_url
string
Required
attributes.note_to_payer
string
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.order
object
Required

Example

Request
Response
The following request creates a new paypal payment:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/paypal_payments' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token' \
5
-H 'Content-Type: application/vnd.api+json' \
6
-d '{
7
"data": {
8
"type": "paypal_payments",
9
"attributes": {
10
"return_url": "https://yourdomain.com/thankyou",
11
"cancel_url": "https://yourdomain.com/checkout/payment"
12
},
13
"relationships": {
14
"order": {
15
"data": {
16
"type": "orders",
17
"id": "QWERtyUpBa"
18
}
19
}
20
}
21
}
22
}'
Copied!
On success, the API responds with a 201 Created status code, returning the created resource object:
1
{
2
"data": {
3
"id": "xYZkjABcde",
4
"type": "paypal_payments",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/paypal_payments/xYZkjABcde"
7
},
8
"attributes": {
9
"return_url": "https://yourdomain.com/thankyou",
10
"cancel_url": "https://yourdomain.com/checkout/payment",
11
"note_to_payer": "Thank you for shopping with us!",
12
"paypal_payer_id": "ABCDEFGHG123456",
13
"name": "ABCDEFGHG123456",
14
"paypal_id": "1234567890",
15
"status": "created",
16
"approval_url": "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1234567890ABCDEFGHG",
17
"mismatched_amounts": false,
18
"intent_amount_cents": 1000,
19
"intent_amount_float": 10.0,
20
"formatted_intent_amount": "€10,00",
21
"created_at": "2018-01-01T12:00:00.000Z",
22
"updated_at": "2018-01-01T12:00:00.000Z",
23
"reference": "ANY-EXTERNAL-REFEFERNCE",
24
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
25
"metadata": {
26
"foo": "bar"
27
}
28
},
29
"relationships": {
30
"order": {
31
"links": {
32
"self": "https://yourdomain.commercelayer.io/api/paypal_payments/xYZkjABcde/relationships/order",
33
"related": "https://yourdomain.commercelayer.io/api/paypal_payments/xYZkjABcde/order"
34
}
35
},
36
"payment_gateway": {
37
"links": {
38
"self": "https://yourdomain.commercelayer.io/api/paypal_payments/xYZkjABcde/relationships/payment_gateway",
39
"related": "https://yourdomain.commercelayer.io/api/paypal_payments/xYZkjABcde/payment_gateway"
40
}
41
}
42
},
43
"meta": {
44
"mode": "test"
45
}
46
}
47
}
Copied!
Copy link