One Time Payment / Redirection
Prepare your account first
Before start this process, make sure you have check prepare your account section first.
1. Generate public access token
Public access token is authentication token that will be used in further API call in payment out and accept payment APIs. This public access token generated using your API credential Client ID
and Client Secret
that you get from preparation section.
Put Client ID and Client Secret in header of the authentication API to generate the public access token like this :
Example :
curl -u client ID:client Secret https://sandbox.onebrick.io/v2/payments/auth/token
Process above will give you response like this and you get your public access token and ready to use it in the next process.
{
"status": 200,
"error": null,
"metaData": {
"source": "API",
"entity": "Payment"
},
"data": {
"message": "Access token is valid for 5 minutes and can use one time only",
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI4NjEyIiwiY29sb3VyIjoiI0ZGNkY1MiIsInJvbGUiOlsiVVNFUiJdLCJuYW1lIjoiSmVubmlmZXIgVGVzdGluZyIsImlzcyI6Ikplbm5pZmVyIFRlc3RpbmciLCJleHAiOjE3MjYxOTkxNDAsImlhdCI6MTcyNjE5ODg0MCwianRpIjoiOWMwZDI4OWItOGM0MS00YjA1LThiODYtMjNiMzFmNDRmMjNlIiwidHMiOjE3MjYxOTg4NDAwOTd9.ej2PG-9cOS8zpvC-aVq74rnz8W-n6byK7Cm4lekwIVU",
"issuedAt": "2024-09-13T10:40:40.097894",
"expiresAt": "2024-09-13T10:45:40.097894"
}
}
Limitation of public access token
This API gives you a public access token that is only valid to be used 1 time and only for the next 5 minutes. If expired, you need to generate new public access token.
2. Create Payment API
The Create Payment API allows client to create e-wallet redirect link where the end users will do the payment.
curl --request POST \
--url https://sandbox.onebrick.io/v2/payments/gs/acceptance/ewallet \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'publicAccessToken: Bearer {{publicAccessToken}}' \
--data '
{
"amount": "10000",
"referenceId": "Test-Sandbox-01",
"ewalletCode": "DANA",
"expiryTime": 60
}
'
3. Getting the Callback Status
Once the end-user completes the payment using the provided link and the e-money providers confirmed the transaction as complete, we will send the updated status to your callback URL. The notification will include the latest payment status, ensuring you are informed when the transaction is finalized. Here is the example of the callback response.
{
"data": {
"id": "WA_7d6f21d3e170424ea1ac1a79996f27c7",
"referenceId": "Test-Sandbox-01",
"amount": 10000,
"status": "PAID",
"createdAt": "2024-09-13T10:16:03.000+07:00",
"paidAt": "2024-09-13T10:47:34.557+07:00"
}
}
4. Request Final Notification
If you need to check the most recent status manually, you can call Status E-wallet Payment API at to retrieve the latest notification. For example, you can follow the API call below:
curl --request GET \
--url https://sandbox.onebrick.io/v2/payments/gs/v2/payments/gs/acceptance/ewallet/WA_7d6f21d3e170424ea1ac1a79996f27c7 \
--header 'accept: application/json' \
--header 'publicAccessToken: Bearer {{publicAccessToken}}'
If the request of final notification is valid, you will see the response below that showing the payment out status as completed.
{
"status": 200,
"data": {
"message": "We have successfully get status E-Wallet",
"id": "WA_7d6f21d3e170424ea1ac1a79996f27c7",
"referenceId": "Test-Sandbox-01",
"amount": "10000",
"status": "completed",
"ewalletCode": "DANA",
"redirectUrl": "https://m.sandbox.dana.id/m/portal/cashier/checkout?bizNo=20240913111212800110166428801774762×tamp=1726198476396&originSourcePlatform=IPG&mid=216620040016026395535&sign=ae0XxUMldxGjS4oJDf3XuzWhx9fHYCz7Be%2BG8zUAWZAtc1axXlBSB4uzO%2FVX8IqvpIm5mZMCKwBWALPi8F2KHMpO566juhFvVxqpQ0%2B5v8w%2BdJngzMETKgcD6g6sY28V1sOR3BOy32CZQWxzRqVmvNX32Jdh5YHuuLepMnqdAWYPBcnTu6laj%2BcuHIEJoJXRX5n%2Fnp9UDQ6OBcE%2FX9CBKXmzIXGQ%2BDJWyO%2BBRZnoNmbzyUzhRvWOH13h3abmj7kDY33xpmwOiZoBAYNVq6TZnqbEXFQPPnTiV0NV7ry%2BCDOLbTMChcO0erurZZ%2FlJEltqIicp8WCIMcN%2BE5%2ForDKpQ%3D%3D&forceToH5=false",
"expiredAt": "2024-09-13T11:35:36.296+07:00"
},
"metaData": {
"source": "API",
"entity": "Payment"
},
"error": null
}
Testing callback in sandbox
Callbacks are automatically sent in production whenever there's a change in transaction status. However, in sandbox mode, since no real transactions occur, triggering callbacks works differently.
To test a specific status update in sandbox, you can manually trigger the callback by selecting "Resend Callback" in the Brick Dashboard under: Receive Money > E-wallet > Action > Resend Callback.
For further details, please refer to the API Reference.
Updated 11 days ago