Skip to main content

Auto Debit

Personal

Business

Auto Debit is a service that automatically deducts an amount from your customer's account and transfers it to your business account to automatically renew service plans, settle orders, collect recurring fees, and more.

Steps to Integrate Auto Debit​

Below are the steps to integrate Auto Debit into your product.

  1. Create a grant /grant/token with scopes set to auto_debit.

  2. Open the Cas Link interface using the grantToken returned in the previous step. See details

  3. After the user completes authentication, your frontend will receive a publicToken. Use this publicToken to obtain an accessToken for the grant.

  4. Once you have the accessToken, call the Auto Debit account identity API to verify the account information.

  5. Call the Auto Debit API to create an automatic debit order for renewing your customer's service plan, settling orders, and more.

  6. When an Auto Debit transaction is processed successfully or fails, the Cas system sends a webhook with the details in the autoDebit field. When your system receives this notification, it should re-verify the payment information and continue with the next steps.

Call API​

Create access grant for Auto Debit​

curl --location 'https://sandbox.bankhub.dev/grant/token' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": "auto_debit",
"language": "vi",
"redirectUri": "https://your-domain.vn/link",
}'
info

For API details, see here

Get accessToken from publicToken​

  curl --location 'https://sandbox.bankhub.dev/grant/exchange' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"publicToken": "bdbde2bad-7685-4f95-987c-71309a4a3"
}'
info

For API details, see here

Get the identity of the auto debit account​

  curl --location 'https://sandbox.bankhub.dev/identity/auto-debit' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'Authorization: <ACCESS_TOKEN_HERE>' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>'
info

For API details, see here

Create an Auto Debit order​

  curl -L 'https://sandbox.bankhub.dev/auto-debit' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-client-id: <x-client-id>' \
-H 'x-secret-key: <x-client-id>' \
-d '{
"batchId": "35175743-763c-11ef-a291-0022481a0395",
"payments": [
{
"grantAccessToken": "string",
"paymentId": "56f21066-763c-11ef-a291-0022481a0395",
"amount": 2000,
"description": "Test Auto Debit"
}
]
}'
info

For API details, see here