Merx

POST shop/checkout

Validates the submitted data and starts the payment.

fetch('/api/shop/checkout', {
	method: 'POST',
	headers: {
		'Accept': 'application/json',
		'Content-Type': 'application/json',
	},
	body: JSON.stringify({
		"paymentGateway": "invoice",
		"email": "jane@example.com",
		"company": "Example Inc.",
		"street": "Example Street 1",
		"postal_code": "12345",
		"city": "Example City",
		"country": "DE"
	}),
});

Return type

array

Array with redirect url when json is the preferred mime type, otherwise redirects with code 303.

Example response

POST https://shop.test/api/shop/checkout
{
    "status": "error",
    "message": "An unexpected error occurred! Enable debug mode for more info: https://getkirby.com/docs/reference/system/options/debug",
    "code": 500,
    "key": null,
    "details": []
}

Example errors

Invalid or missing fields

Request body
{
    "paymentGateway": "invoice",
    "email": "jane@example",
    "street": "Example Street 1",
    "city": "Example City",
    "country": "DE"
}
Response
{
    "status": "error",
    "message": "An unexpected error occurred! Enable debug mode for more info: https://getkirby.com/docs/reference/system/options/debug",
    "code": 500,
    "key": null,
    "details": []
}

No payment gateway

Request body
{
    "email": "jane@example.com",
    "company": "Example Inc.",
    "street": "Example Street 1",
    "postal_code": "12345",
    "city": "Example City",
    "country": "DE"
}
Response
{
    "status": "error",
    "message": "No payment gateway provided.",
    "code": 400,
    "key": "error.merx.noPaymentGateway",
    "details": []
}

Empty cart

The example request, sent with an empty cart.

Response
{
    "status": "error",
    "message": "Cart is empty.",
    "code": 500,
    "key": "error.merx.emptycart",
    "details": []
}