Search…
API Reference
Resources
Create a braintree payment
How to create a braintree payment via API
To create a new braintree payment, send a POST request to the /api/braintree_payments endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.payment_id
string
Optional
attributes.local
boolean
Optional
attributes.options
object
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 braintree payment:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/braintree_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": "braintree_payments",
9
"relationships": {
10
"order": {
11
"data": {
12
"type": "orders",
13
"id": "QWERtyUpBa"
14
}
15
}
16
}
17
}
18
}'
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": "braintree_payments",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/braintree_payments/xYZkjABcde"
7
},
8
"attributes": {
9
"client_token": "xxxx.yyyy.zzzz",
10
"payment_method_nonce": "xxxx.yyyy.zzzz",
11
"payment_id": "xxxx.yyyy.zzzz",
12
"local": true,
13
"options": {
14
"customer_id": "1234567890"
15
},
16
"created_at": "2018-01-01T12:00:00.000Z",
17
"updated_at": "2018-01-01T12:00:00.000Z",
18
"reference": "ANY-EXTERNAL-REFEFERNCE",
19
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
20
"metadata": {
21
"foo": "bar"
22
}
23
},
24
"relationships": {
25
"order": {
26
"links": {
27
"self": "https://yourdomain.commercelayer.io/api/braintree_payments/xYZkjABcde/relationships/order",
28
"related": "https://yourdomain.commercelayer.io/api/braintree_payments/xYZkjABcde/order"
29
}
30
},
31
"payment_gateway": {
32
"links": {
33
"self": "https://yourdomain.commercelayer.io/api/braintree_payments/xYZkjABcde/relationships/payment_gateway",
34
"related": "https://yourdomain.commercelayer.io/api/braintree_payments/xYZkjABcde/payment_gateway"
35
}
36
}
37
},
38
"meta": {
39
"mode": "test"
40
}
41
}
42
}
Copied!
Last modified 23d ago
Copy link