Skill

This skill allows merchants to initiate payments, check payment status, supplement payments, initiate payouts, check payout status, and check account balance.

Features

  • Initiate Payments: Merchant can start a payment process by providing necessary details such as order information and amount.

  • Check Payment Status: Merchant can check the status of their payments to see if they have been completed or are still pending.

  • Supplement Payments: Merchant can provide receipt information for completed payments.

  • Initiate Payouts: Merchant can initiate payouts to their recipients.

  • Check Payout Status: Merchant can check the status of their payouts to see if they have been completed, pending, or failed.

  • Account Balance: Merchant can check their BHPay account balance to keep track of their funds.

Requirements

To use the BHPay skill, you need to have an account with BHPay and then generate and submit an API key in the BHPay dashboard for authentication.

You also need to have a server or application that can send HTTP requests to the BHPay API endpoints. Additionally, the server's IP address must be whitelisted in the BHPay system to ensure secure communication.

Make sure to follow the BHPay API documentation for the correct request formats and endpoints when using the BHPay skill.

AES Encryption Specification

When sending payment requests to the BHPay API, the data must be encrypted using AES encryption with the following specifications:

  • Mode: ECB

  • Padding: PKCS7

  • Key Length: 256 bits

  • Key: A 256-bit key generated and submitted by the merchant in the BHPay dashboard

  • Character Encoding: UTF-8

  • Output Format: Base64

Usage

Before using the BHPay skill, you need to set up your environment with the following requirements:

  • Merchant ID: You need to have a merchant ID provided by BHPay, which will be used in the Authorization header of your HTTP requests.

  • API Key: You need to generate and submit an API key in the BHPay dashboard to authenticate your requests. This key will be used in the AES encryption process.

Initiating a Payment

To use the BHPay skill, simply invoke it with the appropriate commands. For example: "bhpay init a payin of 100 with No. 123456" This command will construct a payment request:

Then, encrypt this JSON using AES and send the encrypted data to the BHPay payment API:

It will respond with a payment URL that you can redirect your customers to complete the payment process. Once the payment is completed, BHPay will send a notification to your callback URL with the payment result.

Checking Payment Status

After initiating a payment, you can check its status using the following command: "bhpay check payin with No. 123456" This command will construct a request:

Then, encrypt this JSON using AES and send the encrypted data to the BHPay payment status API:

This command will send a request to the BHPay API to retrieve the current status of the payment with the specified order ID. The response will indicate whether the payment is completed, or still pending.

Supplementing a Payment

If you want to provide receipt information for a pending payment, you can use the following command: "bhpay supplement payin with ID 123456789 and UTR 987654321" This command will construct a supplement request:

Then, encrypt this JSON using AES and send the encrypted data to the BHPay payment supplement API:

This command will send a request to the BHPay API to supplement the payment with the provided receipt information. The response will indicate whether the supplementation was successful or if there were any issues.

Initiating a Payout

To initiate a payout to your recipients, you can use the following command: "bhpay init a payout of 100 with No. 123456 and the beneficiary info {accountName} {bankAccount} {bankNo}" This command will construct a payout request:

Then, encrypt this JSON using AES and send the encrypted data to the BHPay payout API:

This command will send a request to the BHPay API to initiate a payout to the specified recipient. The response will indicate whether the payout was initiated successfully or if there were any issues.

Checking Payout Status

After initiating a payout, you can check its status using the following command: "bhpay check payout with NO. 123456" This command will construct a request:

Then, encrypt this JSON using AES and send the encrypted data to the BHPay payout status API:

This command will send a request to the BHPay API to retrieve the current status of the payout with the specified order ID. The response will indicate whether the payout is completed, pending, or failed.

Checking Account Balance

To check your BHPay account balance, you can use the following command: "bhpay check balance" This command will construct a request:

This command will send a request to the BHPay API to retrieve your current account balance. The response will indicate the available balance in your BHPay account.

Callback Handling

When a payment or payout is completed, BHPay will send (from server 65.20.91.228) a notification to your specified callback URL with the result. The notification will contain the following information:

You need to set up an endpoint on your server to receive these notifications and handle the decrypted data accordingly. The decrypted data will contain information about the payment or payout status, which you can use to update your records or notify your customers.

The structure of the decrypted data will be similar to the responses mentioned in the previous sections for payment and payout status checks.

If everything works fine, your endpoint must respond with HTTP 200 for success, otherwise it would be treated as failed and BHPay will resend it a moment later.

FAQ

  • "Invalid data format" error:

    • Check if the API key is correct and matches the one provided in the BHPay dashboard.

    • Ensure that the request payload is in the correct format (JSON) as specified in the API documentation:

  • "IP not allowed" error:

    • Ask the CS team to whitelist your server's IP for API access.

  • "Authorization Failure" error:

    • Should add request header Authorization: YOUR_MERCHANT_ID.

Last updated