Integration Process
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.eyJzdWIiOiIxODQ3IiwiY29sb3VyIjoiIzMzMzMzMyIsInJvbGUiOlsiVVNFUiJdLCJuYW1lIjoiQnJpY2siLCJpc3MiOiJCcmljayIsImV4cCI6MTY1NzA4ODgzOSwiaWF0IjoxNjU3MDg4NTM5LCJqdGkiOiIyZTZmZTIwOS0yN2ZiLTQ0MjctOTI5Mi1lNThiYzMyMDUyMzkiLCJ0cyI6MTY1NzA4ODUzOTg1N30.gexikMhPVvS8z2j9muHhSAZb_TrkUAn4BDWIvOJLZDE",
"issuedAt": "2022-07-06T13:22:19.857147",
"expiresAt": "2022-07-06T13:27:19.857147"
}
}
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. Verify recipient account
The process to verify the recipient account needed to make sure payment out to be seamless without error due to invalid account data such as invalid bank account code or bank account number. It also help you to make sure that the owner of the recipient account is the right person you are sending the money to.
Call this verify recipient account API using public access token like this :
curl --request GET \
--url 'https://sandbox.onebrick.io/v2/payments/gs/bank-account-validation?accountNumber=accountNumber&bankShortCode=bankShortCode' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'publicAccessToken: Bearer {{publicAccessToken}}'
After calling API above, you will get the name of the owners for the given account like sample result below. If it belongs to the right person then you can do the further process to do payment out.
{
"status": 200,
"data": {
"message": "We are successfully able to verify the account",
"accountNo": "4124668005",
"accountName": "M.HIBBAN IRSYAD",
"bankShortCode": "PERMATA"
},
"metaData": {
"source": "API",
"entity": "Payment"
},
"error": null
}
List Bank Account Destination
If you need to check list of bank that is covered by Brick system, you can check it in this link. For now Brick only able to verify payment out destination to bank account and not e-wallet account.
3. Create payment out
This API is the process to finally send money to the recipient account. You need to generate new public access token like in step 1. After that use the new public access token to call this payment out API.
You need to provide data for the payment data and recipient data, but for example you can follow the API call below :
curl --request POST \
--url https://sandbox.onebrick.io/v2/payments/gs/disbursements \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'publicAccessToken: Bearer {{publicAccessToken}}' \
--data '
{
"referenceId": "test-disbursement-1",
"description": "test-disbursement-1",
"amount": 10000,
"disbursementMethod": {
"type": "bank_transfer",
"bankShortCode": "MANDIRI",
"bankAccountNo": "12345678",
"bankAccountHolderName": "PROD ONLY"
}
}
'
If process of payment out valid, you will see the response below that showing the payment out status as processing.
{
"status": 200,
"data": {
"message": "We have received your request and are processing it, please check your callback URL for transaction status",
"id": "asdasd123123asdasdasd",
"type": "disbursement",
"attributes": {
"referenceId": "test-disbursement-1",
"description": "test-disbursement-1",
"amount": "10000",
"status": "processing",
"createdAt": "2022-07-21T13:49:39.752+07:00",
"disbursementMethod": {
"type": "bank_transfer",
"bankAccountNo": "12345678",
"bankShortCode": "BCA",
"bankAccountHolderName": "PROD ONLY"
}
}
},
"metaData": {
"source": "API",
"entity": "Payment"
},
"error": null
}
Payment system is process that is dependent to the bank system and we will send the updated status once completed to your callback URL that you have setup before in the step 4.
4. Getting the callback status
Usually process of payment out will take few minutes until it is received in recipient bank account balance. Once money receive and we got confirmation from bank system that transfer status completed, we will forward the updated status to your callback URL like this :
{
"data": {
"id": "asdasd123123asdasdasd",
"type": "disbursement",
"attributes": {
"referenceId": "test-disbursement-1",
"description": "test-disbursement-1",
"amount": "10000",
"status": "completed",
"createdAt": "2022-07-21T13:49:39.752+07:00",
"disbursementMethod": {
"type": "bank_transfer",
"bankAccountNo": "12345678",
"bankShortCode": "BCA",
"bankAccountHolderName": "PROD ONLY",
"bankName" : "Bank Central Asia"
}
}
}
}
Testing callback in sandbox
Callbacks are sent when there are changes in transaction status. It will be sent automatically in production, but in sandbox, because there is no real transaction happening, how callbacks are triggered is different.
To test out callback for specific status, you can follow testing process in this section.
You can handle the behavior later for status completed or also check how to handling errors case.
Updated 9 months ago