Skip to main content
Version: Next

Trích nợ tự động

Quản lý liên kết trích nợ tự động: đăng ký, thanh toán, hủy liên kết, hoàn tiền.


Đăng ký liên kết

API: POST /v1/direct-debit/register

const result = await client.directDebit.register({
requestId: 'REQ_001',
phone: '0935926988',
returnUrl: 'https://example.com/callback',
bankBin: '970418',
accountName: 'NGUYEN VAN A',
});

Tham số đầu vào

TrườngKiểuBắt buộcMô tả
requestIdstringMã yêu cầu duy nhất
phonestringSố điện thoại
returnUrlstringURL callback sau đăng ký
bankBinstringMã BIN ngân hàng. Dùng BankBinEnum
accountNamestringTên chủ tài khoản

Response

Trả về URL đăng ký trong data (string).


Thanh toán hóa đơn

API: POST /v1/direct-debit/payment-bill

const result = await client.directDebit.paymentBill({
requestId: 'REQ_002',
subscriptionId: 'SUB_001',
amount: '500000',
description: 'Thanh toán đơn hàng',
partnerCode: 'one-pay',
serviceProviderName: 'TINGEE',
});

Tham số đầu vào

TrườngKiểuBắt buộcMô tả
requestIdstringMã yêu cầu duy nhất
subscriptionIdstringMã liên kết trích nợ
amountstringSố tiền (dạng string)
descriptionstringNội dung thanh toán
partnerCodestringMã đối tác (one-pay)
serviceProviderNamestringTên nhà cung cấp dịch vụ
clientIdstringMã client
expirationTimestringThời gian hết hạn
tokenRefstringToken tham chiếu
accountNumberstringSố tài khoản
returnUrlstringURL callback
additionalDataobjectDữ liệu bổ sung

Response

{
"code": "00",
"message": "Success",
"data": {
"code": "00",
"status": "success",
"transactionCode": "TXN_001"
}
}
TrườngKiểuMô tả
data.codestringMã kết quả
data.statusstringTrạng thái: success, failure, pending, pending-confirm, ...
data.transactionCodestringMã giao dịch
data.isSentConfirmEmailbooleanĐã gửi email xác nhận
data.isSentConfirmZalobooleanĐã gửi Zalo xác nhận
data.returnUrlstringURL redirect

Hủy liên kết

API: DELETE /v1/direct-debit/delete-subscription

const result = await client.directDebit.deleteSubscription({
requestId: 'REQ_003',
subscriptionId: 'SUB_001',
tokenRef: 'TOKEN_REF',
returnUrl: 'https://example.com/callback',
});

Tham số đầu vào

TrườngKiểuBắt buộcMô tả
requestIdstringMã yêu cầu duy nhất
subscriptionIdstringMã liên kết trích nợ
tokenRefstringToken tham chiếu
returnUrlstringURL callback

Response

{
"code": "00",
"message": "Success",
"data": {
"code": "00",
"confirmUrl": "https://..."
}
}
TrườngKiểuMô tả
data.codestringMã kết quả
data.confirmUrlstringURL xác nhận hủy liên kết

Hoàn tiền

API: POST /v1/direct-debit/refund

const result = await client.directDebit.refund({
subscriptionId: 'SUB_001',
tokenRef: 'TOKEN_REF',
transactionId: 'TXN_001',
amount: 100000,
});

Tham số đầu vào

TrườngKiểuBắt buộcMô tả
subscriptionIdstringMã liên kết trích nợ
tokenRefstringToken tham chiếu
transactionIdstringMã giao dịch cần hoàn
amountnumberSố tiền hoàn

Response

{
"code": "00",
"message": "Success",
"data": {
"refundAmount": 100000,
"transactionId": "TXN_REFUND_001",
"status": "success"
}
}
TrườngKiểuMô tả
data.refundAmountnumberSố tiền đã hoàn
data.transactionIdstringMã giao dịch hoàn
data.statusstringTrạng thái: success, failure, Pending

Sửa phương thức thanh toán

API: PUT /v1/direct-debit/edit-confirm-payment-method

const result = await client.directDebit.editConfirmPaymentMethod({
requestId: 'REQ_004',
returnUrl: 'https://example.com/callback',
subscriptionId: 'SUB_001',
});

Tham số đầu vào

TrườngKiểuBắt buộcMô tả
requestIdstringMã yêu cầu duy nhất
returnUrlstringURL callback
subscriptionIdstringMã liên kết trích nợ

Response

Trả về URL xác nhận trong data (string).


Trạng thái liên kết

API: GET /v1/direct-debit/get-subscription-status

const result = await client.directDebit.getSubscriptionStatus({
subscriptionId: 'SUB_001',
tokenRef: 'TOKEN_REF',
});

Tham số đầu vào (query)

TrườngKiểuBắt buộcMô tả
subscriptionIdstringMã liên kết trích nợ
tokenRefstringToken tham chiếu
requestIdstringMã yêu cầu

Response

{
"code": "00",
"message": "Success",
"data": {
"subscriptionId": "SUB_001",
"tokenRef": "TOKEN_REF",
"bankBin": "970418",
"bankName": "BIDV",
"accountNumber": "0935926988",
"accountName": "NGUYEN VAN A",
"phone": "0935926988",
"status": "active",
"confirmPaymentByEmail": false,
"confirmPaymentByZalo": true,
"confirmPhoneNumber": "0935926988"
}
}
TrườngKiểuMô tả
data.subscriptionIdstringMã liên kết
data.tokenRefstringToken tham chiếu
data.bankBinstringMã BIN ngân hàng. Dùng BankBinEnum
data.bankNamestringTên ngân hàng. Dùng BankNameEnum
data.accountNumberstringSố tài khoản
data.phonestringSố điện thoại
data.statusstringactive hoặc inactive
data.confirmPaymentByEmailbooleanXác nhận qua email
data.confirmPaymentByZalobooleanXác nhận qua Zalo

Trạng thái giao dịch

API: GET /v1/direct-debit/get-transaction-status

const result = await client.directDebit.getTransactionStatus({
transactionId: 'TXN_001',
tokenRef: 'TOKEN_REF',
subscriptionId: 'SUB_001',
});

Tham số đầu vào (query)

TrườngKiểuBắt buộcMô tả
transactionIdstringMã giao dịch
tokenRefstringToken tham chiếu
subscriptionIdstringMã liên kết trích nợ

Response

{
"code": "00",
"message": "Success",
"data": {
"transactionId": "TXN_001",
"subscriptionId": "SUB_001",
"tokenRef": "TOKEN_REF",
"bankBin": "970418",
"accountNumber": "0935926988",
"amount": 500000,
"status": "success",
"transactionDate": "2025-01-15T10:30:00Z"
}
}
TrườngKiểuMô tả
data.transactionIdstringMã giao dịch
data.subscriptionIdstringMã liên kết
data.bankBinstringMã BIN ngân hàng. Dùng BankBinEnum
data.amountnumberSố tiền
data.statusstringsuccess, failed, pending, insufficient-balance, ...
data.transactionDatestringThời gian giao dịch
data.customerobjectThông tin khách hàng (onepayAccountId, name, phone, email)

Lịch sử giao dịch

API: GET /v1/direct-debit/get-paging-transactions

const result = await client.directDebit.getPagingTransactions({
subscriptionId: 'SUB_001',
tokenRef: 'TOKEN_REF',
skipCount: 0,
maxResultCount: 10,
});

Tham số đầu vào (query)

TrườngKiểuBắt buộcMô tả
subscriptionIdstringMã liên kết trích nợ
tokenRefstringToken tham chiếu
startTimestringThời gian bắt đầu lọc
endTimestringThời gian kết thúc lọc
skipCountnumberSố bản ghi bỏ qua
maxResultCountnumberSố bản ghi tối đa

Response

Trả về PagedResultDto với totalCount và mảng items:

TrườngKiểuMô tả
items[].transactionIdstringMã giao dịch
items[].codestringMã kết quả
items[].bankNamestringTên ngân hàng. Dùng BankNameEnum
items[].amountstringSố tiền
items[].contentstringNội dung giao dịch
items[].accountNumberstringSố tài khoản
items[].transactionDatestringThời gian giao dịch
items[].statusstringsuccess, failure, pending, refunded, ...