Create a payment method
How to create a payment method via API
To create a new payment method, send a POST
request to the /api/payment_methods
endpoint, passing the resource arguments in the request body.
Request
POST https://yourdomain.commercelayer.io/api/payment_methods
Arguments
type
string
Required
attributes.name
string
Optional, default to titleized payment source type
attributes.payment_source_type
string
Required
attributes.currency_code
string
Required, unless inherited by market
attributes.moto
boolean
Optional, default is 'false'
attributes.require_capture
boolean
Optional, deafult is 'true'
attributes.auto_place
boolean
Optional, default is 'false'
attributes.auto_capture
boolean
Optional, default is 'false'
attributes.price_amount_cents
integer
Required
attributes.auto_capture_max_amount_cents
integer
Optional
attributes._disable
boolean
Optional
attributes._enable
boolean
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.market
object
Optional
relationships.payment_gateway
object
Required
relationships.store
object
Optional
Example
The following request creates a new payment method:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/payment_methods' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "payment_methods",
"attributes": {
"payment_source_type": "stripe_payments",
"currency_code": "EUR",
"price_amount_cents": 0
},
"relationships": {
"payment_gateway": {
"data": {
"type": "payment_gateways",
"id": "ABCRtyUpBa"
}
}
}
}
}'
Last updated