Search…
API Reference
Resources
Create an external gateway
How to create an external gateway via API
To create a new external gateway, send a POST request to the /api/external_gateways endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.name
string
Required
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
attributes.authorize_url
string
Optional
attributes.capture_url
string
Optional
attributes.void_url
string
Optional
attributes.refund_url
string
Optional

Example

Request
Response
The following request creates a new external gateway:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/external_gateways' \
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": "external_gateways",
9
"attributes": {
10
"name": "US payment gateway"
11
}
12
}
13
}'
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": "external_gateways",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/external_gateways/xYZkjABcde"
7
},
8
"attributes": {
9
"name": "US payment gateway",
10
"created_at": "2018-01-01T12:00:00.000Z",
11
"updated_at": "2018-01-01T12:00:00.000Z",
12
"reference": "ANY-EXTERNAL-REFEFERNCE",
13
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
14
"metadata": {
15
"foo": "bar"
16
},
17
"shared_secret": "xxxx-yyyy-zzzz",
18
"authorize_url": "https://external_gateway.com/authorize",
19
"capture_url": "https://external_gateway.com/capture",
20
"void_url": "https://external_gateway.com/void",
21
"refund_url": "https://external_gateway.com/refund"
22
},
23
"relationships": {
24
"payment_methods": {
25
"links": {
26
"self": "https://yourdomain.commercelayer.io/api/external_gateways/xYZkjABcde/relationships/payment_methods",
27
"related": "https://yourdomain.commercelayer.io/api/external_gateways/xYZkjABcde/payment_methods"
28
}
29
},
30
"external_payments": {
31
"links": {
32
"self": "https://yourdomain.commercelayer.io/api/external_gateways/xYZkjABcde/relationships/external_payments",
33
"related": "https://yourdomain.commercelayer.io/api/external_gateways/xYZkjABcde/external_payments"
34
}
35
}
36
},
37
"meta": {
38
"mode": "test"
39
}
40
}
41
}
Copied!
Last modified 2mo ago
Copy link