Skip to main content

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

MethodDescriptionAuth RequiredHTTP Endpoint
getRecipientsGet all bank recipientsGET /ntcp/recipients
createRecipientCreate new bank recipientPOST /ntcp/recipients
getWalletRecipientsGet all wallet recipientsGET /ntcp/wallet-recipients
createWalletRecipientCreate new wallet recipientPOST /ntcp/wallet-recipients
getAllRecipientsGet unified recipient listGET /ntcp/contacts

Transfer Operations

MethodDescriptionAuth RequiredHTTP Endpoint
transferDomesticExecute domestic bank transferPOST /ntcp/transfer/domestic
transferInternationalExecute international transferPOST /ntcp/transfer/international
getTransferReceiptGet bank transfer receiptGET /ntcp/transfer/receipt/:trx_id
getWalletReceiptGet wallet transfer receiptGET /ntcp/transfer/wallet-receipt/:trx_id
getCrossborderWalletReceiptGet crossborder wallet receiptGET /ntcp/transfer/crossborder-wallet-receipt/:trx_id

Batch Transfer Operations

MethodDescriptionAuth RequiredHTTP Endpoint
generateBatchTemplateGenerate CSV templateGET /batchtransfer/generate-template
uploadBatchFileUpload batch CSV filePOST /batchtransfer/upload
getBatchListGet all user batchesGET /batchtransfer/batches
getBatchDetailsGet batch details and itemsGET /batchtransfer/:batch_id
scheduleBatchSchedule batch executionPOST /batchtransfer/:batch_id/schedule
startBatchNowStart batch immediatelyPOST /batchtransfer/:batch_id/start-now
getBatchStatusGet batch processing statusGET /batchtransfer/:batch_id/status
processBatchProcess batch via workerPOST /batchtransfer/:batch_id/process
processAllBatchesProcess all user batchesPOST /batchtransfer/process-all

Administrative Operations

MethodDescriptionAuth RequiredHTTP Endpoint
getApprovalSummaryGet approval summaryGET /ntcp/approvals/summary
getBalanceHistoryGet wallet balance historyGET /ntcp/:wallet_id/balance-history

Deprecated Methods

MethodStatusReplacement
addRecipient⚠️ DeprecatedUse createRecipient
deleteRecipient⚠️ DeprecatedEndpoint not implemented
initBatchTransfer⚠️ DeprecatedUse uploadBatchFile
getBatchDetail⚠️ DeprecatedUse 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 holder
  • bank_name (string, required): Name of the bank
  • account_number (string, required): Bank account number
  • currency_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 ID
  • amount (number, required): Transfer amount
  • to_currency (string, required): Target currency (must match source)
  • note (string, optional): Transfer note or memo
  • bank_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 ID
  • amount (number, required): Transfer amount in source currency
  • currency_from (string, required): Source currency code
  • currency_to (string, required): Target currency code
  • note (string, optional): Transfer note or purpose
  • bank_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 ID
  • transfer_method (string): 'LOCAL' or 'INTERNATIONAL'
  • country_code (string): Target country code
  • recipient_currency (string): Recipient currency
  • payment_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_id and file fields

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 with start and end dates

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);
}
}