Step-by-step guide
Learn how to create a setup intent and charge the card using the API.
During its lifecycle, the Setup Intent goes through a combination of the following statuses, depending upon your requirements.
Status | Description |
---|---|
Created | The setup intent is created. |
Authorized | The customer adds their card details and authorizes the setup intent. |
Expired | The setup intent expired after creation. |
CardExpired | The card entered has passed the expiry date and is no longer usable. |
Canceled | The setup intent in created state is deleted. |
Completed | The setup intent cycle is complete and the merchant has charged the customer's card. |
Closed | The authorized setup intent is also deleted. This is applicable when you set includeAuthorized to true using the DELETE /setup-intents endpoint. |
Flow diagram
Follow the steps below for a complete setup intent flow:
Step 1: Create a setup intent
To create a setup intent, use the following endpoint:
POST /setup-intents
In your request body, include the following:
reference
: A reference number to track.intendedAmount
: The amount you intend to collect from a customer in the future after a payment method is attached.merchantInitiatedTransactionType
: The transaction type you intend to set up.terms
: The agreed terms between you and your customer.
- When configuring the
intendedAmount
, a customer will not be charged right away. The charge may vary depending upon the terms agreed between a customer and a merchant. - By default, you can create a setup intent with
captureMode: Auto
only.
Request example
The following code sample demonstrates creating a setup intent of 10.00 GBP.
- cURL
- PowerShell
- Python
- C#
loading...
loading...
loading...
loading...
Once you've created a setup intent, the status is updated to ⦿ created.
Step 2. Redirect your customer to Dojo's Checkout page
After receiving the request, Dojo creates a setup intent and returns its unique ID in the following format:
{
"id": "si_sandbox_Oh69aQaQMUuNIPJcPrcRwQ",
...
}
-
Return this ID to the client-side and use it to create a link in the following format:
https://pay.dojo.tech/checkout/{{id}}
-
Redirect your customer to the link on your client-side:
online-checkout-client.htmlloading...
After your customer fills in their payment information on the Checkout page, Dojo server-side saves the card details and redirects the customer to the success page.
Once your customer authorizes their card in the setup intent, the status is updated to ⦿ authorized.