NTCP Module
The ntcp module handles recipient management, domestic/international transfers, and batch processing for corporate payment solutions.
Import
const ntcp = await brdzSDK.ntcp;
Methods Overview (23 methods)
Recipient Management
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
getRecipients | Get all bank recipients | ✅ | GET /ntcp/recipients |
createRecipient | Create new bank recipient | ✅ | POST /ntcp/recipients |
getWalletRecipients | Get all wallet recipients | ✅ | GET /ntcp/wallet-recipients |
createWalletRecipient | Create new wallet recipient | ✅ | POST /ntcp/wallet-recipients |
getAllRecipients | Get unified recipient list | ✅ | GET /ntcp/contacts |
Transfer Operations
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
transferDomestic | Execute domestic bank transfer | ✅ | POST /ntcp/transfer/domestic |
transferInternational | Execute international transfer | ✅ | POST /ntcp/transfer/international |
getTransferReceipt | Get bank transfer receipt | ✅ | GET /ntcp/transfer/receipt/:trx_id |
getWalletReceipt | Get wallet transfer receipt | ✅ | GET /ntcp/transfer/wallet-receipt/:trx_id |
getCrossborderWalletReceipt | Get crossborder wallet receipt | ✅ | GET /ntcp/transfer/crossborder-wallet-receipt/:trx_id |
Batch Transfer Operations
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
generateBatchTemplate | Generate CSV template | ✅ | GET /batchtransfer/generate-template |
uploadBatchFile | Upload batch CSV file | ✅ | POST /batchtransfer/upload |
getBatchList | Get all user batches | ✅ | GET /batchtransfer/batches |
getBatchDetails | Get batch details and items | ✅ | GET /batchtransfer/:batch_id |
scheduleBatch | Schedule batch execution | ✅ | POST /batchtransfer/:batch_id/schedule |
startBatchNow | Start batch immediately | ✅ | POST /batchtransfer/:batch_id/start-now |
getBatchStatus | Get batch processing status | ✅ | GET /batchtransfer/:batch_id/status |
processBatch | Process batch via worker | ✅ | POST /batchtransfer/:batch_id/process |
processAllBatches | Process all user batches | ✅ | POST /batchtransfer/process-all |
Administrative Operations
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
getApprovalSummary | Get approval summary | ✅ | GET /ntcp/approvals/summary |
getBalanceHistory | Get wallet balance history | ✅ | GET /ntcp/:wallet_id/balance-history |
Deprecated Methods
| Method | Status | Replacement |
|---|---|---|
addRecipient | ⚠️ Deprecated | Use createRecipient |
deleteRecipient | ⚠️ Deprecated | Endpoint not implemented |
initBatchTransfer | ⚠️ Deprecated | Use uploadBatchFile |
getBatchDetail | ⚠️ Deprecated | Use getBatchDetails |
Recipient Management
getRecipients
Get all bank account recipients for the authenticated user.
const recipients = await ntcp.getRecipients();
console.log('Bank recipients:', recipients);
Returns:
{
recipients: [
{
id: 1,
account_holder_name: "John Doe",
bank_name: "Bank Mandiri",
account_number: "1234567890",
currency_code: "IDR",
country_code: "ID",
created_at: "2024-01-15T10:30:00Z"
}
]
}
createRecipient
Create a new bank account recipient.
const newRecipient = {
account_holder_name: "Jane Smith",
bank_name: "Bank Central Asia",
account_number: "9876543210",
currency_code: "IDR",
country_code: "ID"
};
const result = await ntcp.createRecipient(newRecipient);
console.log('Recipient created:', result.recipient);
Parameters:
account_holder_name(string, required): Full name of account holderbank_name(string, required): Name of the bankaccount_number(string, required): Bank account numbercurrency_code(string, required): Currency code (IDR, USD, SGD, etc.)country_code(string, required): Two-letter country code
getWalletRecipients
Get all wallet recipients for internal transfers.
const walletRecipients = await ntcp.getWalletRecipients();
console.log('Wallet recipients:', walletRecipients);
Returns:
{
success: true,
recipients: [
{
id: 1,
wallet_id: "12345",
username: "johndoe",
phone: "+628123456789",
currency: "IDR",
country_code: "ID"
}
]
}
createWalletRecipient
Create a new wallet recipient.
const newWalletRecipient = {
wallet_id: "12345",
username: "johndoe",
phone: "+628123456789",
currency: "IDR",
country_code: "ID"
};
const result = await ntcp.createWalletRecipient(newWalletRecipient);
console.log('Wallet recipient created:', result.recipient);
getAllRecipients
Get all recipients (bank and wallet) in a unified format.
const allRecipients = await ntcp.getAllRecipients();
console.log('All recipients:', allRecipients);
// Group by transfer method
const bankRecipients = allRecipients.filter(r => r.transferMethod === 'Bank Transfer');
const walletRecipients = allRecipients.filter(r => r.transferMethod === 'Wallet Transfer');
Returns:
[
{
id: "bank_1",
recipientName: "John Doe",
nickname: "",
transferMethod: "Bank Transfer",
accountDetails: "Bank Central Asia - 1234567890"
},
{
id: "wallet_1",
recipientName: "johndoe",
nickname: "+628123456789",
transferMethod: "Wallet Transfer",
accountDetails: "IDR Wallet ID: 12345 | Country: ID"
}
]
Transfer Operations
transferDomestic
Execute domestic bank transfer within the same country and currency.
const transferData = {
from_wallet_id: "12345",
amount: 1000000,
to_currency: "IDR",
note: "Invoice payment",
bank_account: {
account_holder_name: "John Doe",
bank_name: "Bank Central Asia",
account_number: "1234567890"
}
};
const result = await ntcp.transferDomestic(transferData);
console.log('Transfer completed:', result.transaction_id);
Parameters:
from_wallet_id(string, required): Source wallet IDamount(number, required): Transfer amountto_currency(string, required): Target currency (must match source)note(string, optional): Transfer note or memobank_account(object, required): Bank account details
Returns:
{
message: "NTCP Domestic Transfer Success",
transaction_id: "NTCP-12345-1000000-1642167890-BANK",
bank_transfer_status: "SUCCESS_RECEIVED",
bank_transaction_id: "BCA20240115001",
fee: {
platform_fee: 5000,
partner_fee: 2500,
total_with_fee: 1007500
}
}
transferInternational
Execute international transfer with currency conversion.
const transferData = {
from_wallet_id: "12345",
amount: 100,
currency_from: "USD",
currency_to: "IDR",
note: "International payment",
bank_account: {
account_holder_name: "John Doe",
bank_name: "Bank Mandiri",
account_number: "9876543210",
swift_code: "BMRIIDJA",
country_code: "ID"
}
};
const result = await ntcp.transferInternational(transferData);
console.log('International transfer:', result.data);
Parameters:
from_wallet_id(string, required): Source wallet IDamount(number, required): Transfer amount in source currencycurrency_from(string, required): Source currency codecurrency_to(string, required): Target currency codenote(string, optional): Transfer note or purposebank_account(object, required): Recipient bank account with SWIFT code
getTransferReceipt
Get detailed receipt for a bank transfer transaction.
const receipt = await ntcp.getTransferReceipt('NTCP-12345-1000000-1642167890-BANK');
console.log('Transfer receipt:', receipt.receipt);
getWalletReceipt
Get receipt for wallet-to-wallet transfer.
const receipt = await ntcp.getWalletReceipt('WALLET-TXN-12345');
console.log('Wallet receipt:', receipt.receipt);
getCrossborderWalletReceipt
Get receipt for crossborder wallet transfer.
const receipt = await ntcp.getCrossborderWalletReceipt('CROSSBORDER-TXN-12345');
console.log('Crossborder receipt:', receipt.receipt);
Batch Transfer Operations
generateBatchTemplate
Generate CSV template for batch transfer uploads.
// Basic template
const template = await ntcp.generateBatchTemplate();
// Template with parameters
const templateWithParams = await ntcp.generateBatchTemplate({
from_wallet_id: 'wallet_123',
transfer_method: 'INTERNATIONAL',
country_code: 'SG',
recipient_currency: 'SGD',
payment_currency: 'USD'
});
console.log('Template generated');
Parameters (optional):
from_wallet_id(string): Source wallet IDtransfer_method(string): 'LOCAL' or 'INTERNATIONAL'country_code(string): Target country coderecipient_currency(string): Recipient currencypayment_currency(string): Payment currency
uploadBatchFile
Upload CSV/Excel file containing batch transfer data.
// Using FormData (browser environment)
const formData = new FormData();
formData.append('from_wallet_id', 'wallet_123');
formData.append('file', fileInput.files[0]);
const result = await ntcp.uploadBatchFile(formData);
console.log('Batch uploaded:', result.batch_id);
Parameters:
- FormData with
from_wallet_idandfilefields
Returns:
{
batch_id: "batch_12345_1642167890",
total_items: 25,
status: "PENDING",
message: "Batch file uploaded successfully",
validation_summary: {
valid_items: 23,
invalid_items: 2,
total_amount: 50000000,
currency: "IDR"
}
}
getBatchList
Get all batch transfers for the authenticated user.
const batches = await ntcp.getBatchList();
console.log('User batches:', batches.batches);
// Display batch summary
batches.batches.forEach(batch => {
console.log(`${batch.name} (${batch.status}): ${batch.total_items} items`);
});
getBatchDetails
Get detailed information about a specific batch.
const batchId = 'batch_12345_1642167890';
const details = await ntcp.getBatchDetails(batchId);
console.log('Batch details:', details);
console.log(`Valid items: ${details.items.filter(i => i.status !== 'INVALID').length}`);
scheduleBatch
Schedule a batch to run at a specific future time.
const batchId = 'batch_12345_1642167890';
const scheduleTime = '2024-01-16T09:00:00Z';
const result = await ntcp.scheduleBatch(batchId, { schedule_time: scheduleTime });
console.log('Batch scheduled:', result.status);
startBatchNow
Mark a batch for immediate processing.
const batchId = 'batch_12345_1642167890';
const result = await ntcp.startBatchNow(batchId);
console.log('Batch started:', result.status);
console.log(`Processing ${result.valid_items} valid items`);
getBatchStatus
Get current processing status and progress of a batch.
const batchId = 'batch_12345_1642167890';
const status = await ntcp.getBatchStatus(batchId);
console.log(`Progress: ${status.progress_percentage}%`);
console.log(`Completed: ${status.completed_items}/${status.total_items}`);
console.log(`Status: ${status.status}`);
Returns:
{
batch_id: "batch_12345_1642167890",
status: "PROCESSING",
total_items: 25,
completed_items: 18,
failed_items: 2,
pending_items: 5,
progress_percentage: 72,
started_at: "2024-01-15T10:30:00Z",
estimated_completion: "2024-01-15T11:00:00Z"
}
processBatch
Trigger immediate processing of a batch through the worker.
const batchId = 'batch_12345_1642167890';
const result = await ntcp.processBatch(batchId);
console.log(`Batch processed: ${result.success_count}/${result.total_items} successful`);
processAllBatches
Process all batches belonging to the user that are in DRAFT or SCHEDULED status.
const result = await ntcp.processAllBatches();
console.log('All batches processed:', result.message);
console.log('Processed batches:', result.processed_batches);
Administrative Operations
getApprovalSummary
Get summary of pending approvals by transaction type.
// Using auth middleware (recommended)
const approvals = await ntcp.getApprovalSummary();
// Or with explicit user_id
const approvalsWithUserId = await ntcp.getApprovalSummary({ user_id: '123' });
console.log('Pending approvals:', approvals.approval_summary);
// Calculate total pending
const totalPending = approvals.approval_summary.reduce((sum, item) => sum + item.pending, 0);
console.log(`Total pending: ${totalPending}`);
Returns:
{
approval_summary: [
{
trans_wallet_type: "WITHDRAW",
pending: 5
},
{
trans_wallet_type: "TRANSFER",
pending: 12
}
]
}
getBalanceHistory
Get daily balance history for a wallet within a date range.
const walletId = '12345';
const history = await ntcp.getBalanceHistory(walletId, {
start: '2024-01-01',
end: '2024-01-31'
});
console.log('Balance history:', history.history);
// Calculate statistics
const balances = history.history.map(h => h.balance);
const avgBalance = balances.reduce((a, b) => a + b, 0) / balances.length;
console.log(`Average balance: ${avgBalance.toLocaleString()}`);
Parameters:
wallet_id(string, required): Wallet ID (path parameter)params(object, required): Query parameters withstartandenddates
Returns:
{
wallet_id: "12345",
start: "2024-01-01",
end: "2024-01-31",
history: [
{
date: "2024-01-01",
balance: 1000000
},
{
date: "2024-01-02",
balance: 950000
}
]
}
Deprecated Methods
addRecipient (Deprecated)
⚠️ Deprecated: Use createRecipient instead.
// ❌ Deprecated
const result = await ntcp.addRecipient(data);
// ✅ Use this instead
const result = await ntcp.createRecipient(data);
deleteRecipient (Deprecated)
⚠️ Deprecated: Endpoint not implemented in current API.
// ❌ Not available
try {
await ntcp.deleteRecipient(data);
} catch (error) {
// Will throw: "deleteRecipient endpoint not available"
}
initBatchTransfer (Deprecated)
⚠️ Deprecated: Use uploadBatchFile instead.
// ❌ Deprecated
const result = await ntcp.initBatchTransfer(data);
// ✅ Use this instead
const result = await ntcp.uploadBatchFile(formData);
getBatchDetail (Deprecated)
⚠️ Deprecated: Use getBatchDetails instead.
// ❌ Deprecated
const details = await ntcp.getBatchDetail(batchId);
// ✅ Use this instead
const details = await ntcp.getBatchDetails(batchId);
Error Handling
try {
const result = await ntcp.transferDomestic(transferData);
console.log('Transfer successful:', result.transaction_id);
} catch (error) {
if (error.message.includes('Insufficient funds')) {
console.error('💰 Insufficient wallet balance');
} else if (error.message.includes('API key')) {
console.error('🔑 Authentication issue');
} else if (error.message.includes('Wallet not found')) {
console.error('👛 Wallet validation failed');
} else {
console.error('❌ Transfer failed:', error.message);
}
}
Complete Workflow Example
// Complete NTCP workflow example
async function completeNTCPWorkflow() {
try {
// 1. Create recipients
const bankRecipient = await ntcp.createRecipient({
account_holder_name: "John Doe",
bank_name: "Bank Central Asia",
account_number: "1234567890",
currency_code: "IDR",
country_code: "ID"
});
// 2. Execute domestic transfer
const transfer = await ntcp.transferDomestic({
from_wallet_id: "wallet_123",
amount: 500000,
to_currency: "IDR",
note: "Test payment",
bank_account: {
account_holder_name: "John Doe",
bank_name: "Bank Central Asia",
account_number: "1234567890"
}
});
// 3. Get receipt
const receipt = await ntcp.getTransferReceipt(transfer.transaction_id);
// 4. Process batch transfers
const formData = new FormData();
formData.append('from_wallet_id', 'wallet_123');
formData.append('file', batchFile);
const batch = await ntcp.uploadBatchFile(formData);
const processResult = await ntcp.startBatchNow(batch.batch_id);
console.log('Workflow completed successfully');
} catch (error) {
console.error('Workflow failed:', error.message);
}
}