Order-based VA API for BIDV Business Accounts

The Order-based Virtual Account (VA) API is an automated payment confirmation solution for BIDV business bank accounts. Instead of using a fixed VA, each order is assigned a unique VA with an exact matching amount.


What can you do with this API?

  • SePay allows you to perform the following queries with order-based VAs:

    • Get the list of orders
    • Create a new order
    • Get order details
    • Create an additional VA for an order
    • Cancel an order
    • Cancel an order’s VA

Getting started

  • API URL

    [https://my.sepay.vn/userapi/bidv/{bank_account_id}](https://my.sepay.vn/userapi/bidv/{bank_account_id})
  • To use the order-based VA API, you need to:

    • Create an API Token to authenticate your API requests.
    • Obtain the bank_account_id of the BIDV business account from the Bank Accounts API or directly from the bank account management interface on SePay.
      Payment Flow Diagram
      Payment method screen

Partial Payment

  • SePay supports partial payments for orders via Virtual Accounts (VAs). When using this feature:

    • You can create an order with the full amount, but allow customers to pay in installments by:

      • Setting the amount smaller than the order amount when creating a new VA
      • Setting the amount to null so the VA can receive multiple payments with any amount until the total reaches the order amount
    • When the customer makes a partial payment, the order status changes to Partially

    • When the total paid amount reaches the full order amount, the order status automatically changes to Paid and the VA will no longer accept payments

  • This feature is especially useful for high-value orders or when customers need to pay in installments.


Get order list

GET
/userapi/bidv/123456/orders
Content-Type: application/json
Authorization: Bearer {token}

Create a new order

POST
/userapi/bidv/123456/orders
Content-Type: application/json
Authorization: Bearer {token}
  • Request parameters

    NameTypeRequiredDescription
    amount
    number/nullRequired
    Order amount; set to null to allow unlimited payment amount.
    order_code
    stringNot required
    Order code.
    duration
    number/nullNot required
    Order validity time (in seconds). Set to null to have no payment time limit. Default is 600 seconds (10 minutes), maximum is 31,536,000 seconds (1 year).
    va_holder_name
    stringNot required
    VA account holder name (only uppercase letters, digits and spaces, max 70 characters).
    with_qrcode
    booleanNot required
    Request to generate a QR Code.
    Note

    The va_holder_name parameter is only supported for BIDV business accounts that have the custom display name feature enabled by SePay. Please contact SePay support to enable this feature.


Order details

GET
/userapi/bidv/123456/orders/{order_id}
Content-Type: application/json
Authorization: Bearer {token}
  • Retrieve detailed information of an order by ID.
  • Path parameters
    NameTypeRequiredDescription
    order_id
    stringRequired
    Order ID

Create an additional VA

POST
/orders/{order_id}/va
Content-Type: application/json
Authorization: Bearer {token}
  • Create an additional VA for an existing order.
  • Path parameters
    NameTypeRequiredDescription
    order_id
    stringRequired
    Order ID
  • Request parameters
    NameTypeRequiredDescription
    amount
    number/nullRequired
    VA amount: - Defaults to the order amount. - Can be set smaller than the order amount to allow partial payments. - Set to null so the VA can receive multiple payments until the order amount is fully paid.
    va_holder_name
    stringNot required
    VA account holder name (only uppercase letters, digits and spaces, max 70 characters).
    duration
    number/nullNot required
    VA validity time (in seconds). Set to null for no payment time limit. - Default is 600 seconds (10 minutes). - Maximum is 31,536,000 seconds (1 year).

Cancel an order

DELETE
/orders/{order_id}
Content-Type: application/json
Authorization: Bearer {token}
  • Path parameters
    NameTypeRequiredDescription
    order_id
    stringRequired
    Order ID

Cancel a VA

DELETE
/orders/{order_id}/va/{va_number}
Content-Type: application/json
Authorization: Bearer {token}
  • Path parameters
NameTypeRequiredDescription
order_id
stringRequired
ID của một đơn hàng
va_number
stringRequired
Số va

Handle payment notification Webhooks

  • When a customer successfully pays into an order’s VA, SePay will send a webhook notification to your website. The webhook payload includes a code field that contains the order code of that VA.

  • Example webhook payload when a VA is paid:

RESPONSE
{
  "id": 92704,
  "gateway": "BIDV",
  "transactionDate": "2024-01-07 14:02:37",
  "code": "ORD123456789",
  "transferAmount": 2277000,
  "transferType": "in"
}
  • Your website should check the code field to determine which order was paid and update its status accordingly.

  • For details on how to set up and handle webhooks, see Webhook Creation Guide.


Status definitions

  • Order status

    StatusDescription
    PendingOrder not yet paid
    PaidOrder has been paid
    PartiallyOrder partially paid
    CancelledOrder has been cancelled
  • VA status

    StatusDescription
    UnpaidVA not yet paid
    PaidVA has been paid
    CancelledVA has been cancelled

Request limits

  • SePay rate limits order-based API requests as follows:

    • 2 requests/second per IP
    • Exceeding the limit returns response code 429
    • The X-SePay-UserApi-Retry-After header indicates how long to wait before retrying

Error codes

  • SePay may return the following error codes:
    HTTP CodeDescriptionCause
    400
    Bad Request
    Invalid or missing parameters
    401
    Unauthorized
    Invalid token
    404
    Not Found
    Resource not found
    429
    Too Many Requests
    Rate limit exceeded

Create an order with no amount and time limits

  • You can create an order with no limits on amount and payment time by:

    • Setting amount to null so the order and its VAs can receive multiple payments
    • Setting duration to null so the order has no payment time limit
  • Example:

    bash

    After creating an order, you can create a new VA for the order by calling the Create an additional VA API.