Checkout
Introduction
Checkout is a feature provided by Sonic Payment Gateway that allows merchants to easily accept payments from customers. This guide will walk through the process of creating, retrieving, updating and deleting checkouts, as well as getting all checkouts.
Create a Checkout
To create a checkout, you will need to make a POST request to the checkout endpoint and provide the necessary information about the checkout in the request body. Here's an example of creating a checkout using cURL:
POST
https://api.sonicpay.org/checkouts
Request Body
amount*
100
currency*
USDT
description*
Test
redirect_url*
https://example.com/success
cancel_url*
https://example.com/cancel
Example cURL:
The following table lists the parameters that can be included in the request body when creating a checkout:
amount
integer
The total amount of the checkout in the smallest unit of the currency (e.g. cents for USDT).
currency
string
The currency of the checkout. Must be a valid ISO 4217 currency code.
description
string
A description of the checkout.
redirect_url
string
The URL that the customer will be redirected to after a successful payment.
cancel_url
string
The URL that the customer will be redirected to after there is a failed payment.
If the request is successful, the response will contain the checkout object, including the checkout ID, which will be used for future interactions with the checkout.
Get a Checkout
To retrieve a specific checkout, you will need to make a GET request to the checkout endpoint and provide the checkout ID in the URL.
GET
https://api.sonicpay.org/checkouts/{checkout_id}
Request Body
checkout_id*
23732
Here is the information that might be returned in a GET request to the endpoint https://api.sonicpay.org/checkouts/{checkout_id}
when authorized:
id
string
The unique identifier for the checkout
amount
number
The amount of the checkout in the currency specified
currency
string
The currency of the checkout
description
string
The description of the checkout as provided in the initial request
redirect_url
string
The URL that the user will be redirected to upon successful completion of the checkout
cancel_url
string
The URL that the user will be redirected to if they cancel the checkout
status
string
The current status of the checkout, such as pending
, successful
, or failed
metadata
object
Additional information associated with the checkout, in key-value pairs
created_at
string
The date and time the checkout was created, in ISO 8601 format
Here's an example of retrieving a checkout using cURL:
If the request is successful, the response will contain the checkout object.
Delete a Checkout
To delete a checkout, you will need to make a DELETE request to the checkout endpoint and provide the checkout ID in the URL.
DELETE
https://api.sonicpay.org/checkouts/{checkout_id}
Request Body
checkout_id
23732
Here's an example of deleting a checkout using cURL:
If the request is successful, the response will be empty.
Update a Checkout
To update a checkout, you will need to make a PUT request to the checkout endpoint and provide the checkout ID in the URL.
PUT
https://api.sonicpay.org/checkouts/{checkout_id}'
Request Body
description*
Update Checkout
Here's an example of updating a checkout using cURL:
Note that other parameters such as amount
and currency
cannot be updated using this endpoint.
Get all Checkouts
make a GET request to the following endpoint:
status
- filter checkouts by status (ex.status=completed
)created_at
- filter checkouts by created_at timestamp (ex.created_at=2022-01-01
)updated_at
- filter checkouts by updated_at timestamp (ex.updated_at=2022-01-01
)
GET
https://api.sonicpay.org/api/v1/checkouts?status=completed
Curl Example:
Response:
Sonic Payment Gateway also allows you to update, delete and get all checkouts.
Update a checkout: You can update the status of a checkout by making a PUT request to the checkout's endpoint with the updated status as the payload
Delete a checkout: You can delete a checkout by making a DELETE request to the checkout's endpoint.
Get all checkouts: You can get all checkouts by making a GET request to the checkouts endpoint.
Last updated