Quickstart for Payment Out API

📘

Download Brick Postman collection

To follow this quickstart you can download Brick postman collection so you can try the API along with the video.


🚧

Prepare your account first

Before continue, make sure you have check prepare yourself to use API section.

Step to create your first payment out :

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"
      }
    }
  }
}

You can handle the behavior later for status completed or also check how to handling errors case.

5. Going live to production

If you have complete everything in the development and want to deploy the integration to the production, now you can check the production checklist in this section.