Creates a Payment Method
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment_method: {
name: 'Test Payment Method',
active: true,
auto_capture: true,
description: 'This is a test payment method',
type: 'Spree::Gateway::Bogus',
display_on: 'both',
store_ids: ['2'],
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/payment_methods', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "24",
"type": "payment_method",
"attributes": {
"name": "API Bogus",
"type": "Spree::Gateway::Bogus",
"description": null,
"active": true,
"display_on": "both",
"auto_capture": null,
"position": 3,
"created_at": "2022-11-08T19:34:48.527Z",
"updated_at": "2022-11-08T19:34:48.530Z",
"deleted_at": null,
"public_metadata": {},
"private_metadata": {},
"preferences": {
"dummy_key": "PUBLICKEY123",
"test_mode": true,
"server": "test"
}
},
"relationships": {
"stores": {
"data": [
{
"id": "291",
"type": "store"
},
{
"id": "292",
"type": "store"
}
]
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record created
Show child attributes
Was this page helpful?
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment_method: {
name: 'Test Payment Method',
active: true,
auto_capture: true,
description: 'This is a test payment method',
type: 'Spree::Gateway::Bogus',
display_on: 'both',
store_ids: ['2'],
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/payment_methods', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "24",
"type": "payment_method",
"attributes": {
"name": "API Bogus",
"type": "Spree::Gateway::Bogus",
"description": null,
"active": true,
"display_on": "both",
"auto_capture": null,
"position": 3,
"created_at": "2022-11-08T19:34:48.527Z",
"updated_at": "2022-11-08T19:34:48.530Z",
"deleted_at": null,
"public_metadata": {},
"private_metadata": {},
"preferences": {
"dummy_key": "PUBLICKEY123",
"test_mode": true,
"server": "test"
}
},
"relationships": {
"stores": {
"data": [
{
"id": "291",
"type": "store"
},
{
"id": "292",
"type": "store"
}
]
}
}
}
}