Storefront integration
Information
Follow this guide if you're building a storefront on top of a headless Magento 2 backend.
Once you've set up our Magento 2 plugin in the Magento back end, you're ready to start accepting payments through your own storefront.
To get started, follow Magento's checkout tutorial until you get to step 9. Then, instead of following steps 9 and 10, use our request payment endpoint below to complete the order.
Request payment
Note
Currently, this endpoint only accepts card payments (including Mada). We will add further functionality in due course.
The request
Endpoint
Note
In addition to card payments the v3 endpoint also allows payments via saved cards for uses who are logged in.
Information
Replace example.com
in the following endpoint URL with your store's domain name. The URL can be http
or https
.
Logged in customers
https://www.example.com/rest/default/v1/checkout_com/mine/api/v3
Guest checkout
https://www.example.com/rest/default/v1/checkout_com/guest/api/v3
Header parameters
Header | Value |
---|---|
required
|
|
required |
|
Body parameters
Field name | Description |
---|---|
string required | The payment method.
|
number required | The shopping cart identifier. |
string required
| The Checkout.com payment token.
InformationThis is only for card payments. |
number required
| The Vault public hash. InformationThis is only for payments through Vault. |
string optional | The bank identification number (BIN) of a card.
|
number optional | The card verification value (CVV) of a card. InformationThis is only for card payments and users who are logged in. |
boolean optional
| Save card option for |
string optional | The URL to which the customer is redirected following a successful payment. Allows you to have a different redirection URL for the storefront from the one on your Magento 2 instance.
|
string optional | The URL to which the customer is redirected following a failed payment. Allows you to have a different redirection URL for the storefront from the one on your Magento 2 instance.
|
Request example
1{2 "paymentRequest": {3 "payment_method": "checkoutcom_card_payment",4 "payment_token": "tok_4gzeau5o2uqubbk6fufs3m7p54",5 "quote_id": 799,6 "save_card": true7 }8}
The response
If you get a response with "success": true
, your order was successful.
If the payment was made with 3D Secure (3DS) authentication, you will get a 200
response containing a redirect link that the customer will need to complete in order to finalize the transaction.
If unsuccessful, you will get one of the following error messages:
- Status code
422
–"The request is invalid."
- Status code
500
–"The order could not be created."
- Status code
422
–"The payment request was declined by the gateway."
Success response example
1{2 "success": true,3 "orderID": "000000028"4}