Update a payment method
How to update an existing payment method via API
To update an existing payment method, send a
PATCH
request to the /api/payment_methods/:id
endpoint, where id
is the ID of the resource that you want to update.Here below the list of all the possible arguments that you can pass with the request body.
PATCH https://yourdomain.commercelayer.io/api/payment_methods/:id
Body Parameter | Type | Required |
---|---|---|
type | string | Required |
id | string | Required |
attributes.payment_source_type | string | Optional |
attributes.currency_code | string | Optional |
attributes.moto | boolean | Optional |
attributes.require_capture | boolean | Optional |
attributes.auto_capture | boolean | Optional |
attributes._disable | boolean | Optional |
attributes._enable | boolean | Optional |
attributes.price_amount_cents | integer | Optional |
attributes.auto_capture_max_amount_cents | integer | Optional |
attributes.reference | string | Optional |
attributes.reference_origin | string | Optional |
attributes.metadata | object | Optional |
relationships.market | object | Optional |
relationships.payment_gateway | object | Optional |
Request
Response
The following request updates the payment method identified by the ID "xYZkjABcde":
curl -g -X PATCH \
'https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "payment_methods",
"id": "xYZkjABcde",
"attributes": {
"_disable": true
},
"relationships": {
"market": {
"data": {
"type": "markets",
"id": "ABCRtyUpBa"
}
}
}
}
}'
On success, the API responds with a
200 OK
status code, returning the updated resource object:{
"data": {
"id": "xYZkjABcde",
"type": "payment_methods",
"links": {
"self": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde"
},
"attributes": {
"payment_source_type": "StripePayment",
"name": "Stripe Payment",
"currency_code": "EUR",
"moto": false,
"require_capture": true,
"auto_capture": false,
"disabled_at": "2018-01-01T12:00:00.000Z",
"price_amount_cents": 0,
"price_amount_float": 0.0,
"formatted_price_amount": "€0,00",
"auto_capture_max_amount_cents": 0,
"auto_capture_max_amount_float": 0.0,
"formatted_auto_capture_max_amount": "€0,00",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"market": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/relationships/market",
"related": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/market"
}
},
"payment_gateway": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/relationships/payment_gateway",
"related": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/payment_gateway"
}
},
"attachments": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/relationships/attachments",
"related": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/attachments"
}
},
"versions": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/relationships/versions",
"related": "https://yourdomain.commercelayer.io/api/payment_methods/xYZkjABcde/versions"
}
}
},
"meta": {
"mode": "test"
}
}
}
Last modified 29d ago