Skip to main content

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ả
requestIdstring✓Mã yêu cầu duy nhất
phonestring✓Số điện thoại
returnUrlstring✓URL callback sau đăng ký
bankBinstring✕Mã BIN ngân hàng. Dùng BankBinEnum
accountNamestring✕Tê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ả
requestIdstring✓Mã yêu cầu duy nhất
subscriptionIdstring✓Mã liên kết trích nợ
amountstring✓Số tiền (dạng string)
descriptionstring✓Nội dung thanh toán
partnerCodestring✓Mã đối tác (one-pay)
serviceProviderNamestring✓Tên nhà cung cấp dịch vụ
clientIdstring✕Mã client
expirationTimestring✕Thời gian hết hạn
tokenRefstring✕Token tham chiếu
accountNumberstring✕Số tài khoản
returnUrlstring✕URL callback
additionalDataobject✕Dữ 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ả
requestIdstring✓Mã yêu cầu duy nhất
subscriptionIdstring✓Mã liên kết trích nợ
tokenRefstring✓Token tham chiếu
returnUrlstring✓URL 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ả
subscriptionIdstring✓Mã liên kết trích nợ
tokenRefstring✓Token tham chiếu
transactionIdstring✓Mã giao dịch cần hoàn
amountnumber✓Số 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ả
requestIdstring✓Mã yêu cầu duy nhất
returnUrlstring✓URL callback
subscriptionIdstring✓Mã 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ả
subscriptionIdstring✓Mã liên kết trích nợ
tokenRefstring✓Token tham chiếu
requestIdstring✕Mã 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ả
transactionIdstring✓Mã giao dịch
tokenRefstring✓Token tham chiếu
subscriptionIdstring✓Mã 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ả
subscriptionIdstring✓Mã liên kết trích nợ
tokenRefstring✓Token tham chiếu
startTimestring✕Thời gian bắt đầu lọc
endTimestring✕Thời gian kết thúc lọc
skipCountnumber✕Số bản ghi bỏ qua
maxResultCountnumber✕Số 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, ...