mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-09-30 11:13:11 +00:00
- Add standalone test script to validate sandbox API connectivity for check management and account info endpoints - Update seed-bank-status to persist amount, issueDate, and method fields - Add data/ to gitignore
126 lines
3.8 KiB
JavaScript
126 lines
3.8 KiB
JavaScript
/**
|
|
* One-off script to test BoA CashPro sandbox API connectivity.
|
|
* Reads credentials from SSM Parameter Store (same params as production),
|
|
* makes test API calls, and prints the full responses so you can capture
|
|
* the client ID, timestamp, and transactionIdentification for BoA onboarding.
|
|
*
|
|
* Usage:
|
|
* node scripts/test-boa-sandbox.js
|
|
*/
|
|
|
|
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
|
|
|
|
const ssm = new SSMClient();
|
|
const BOA_BASE_URL = "https://developer.bankofamerica.com";
|
|
|
|
async function getSSMParam(name) {
|
|
const { Parameter } = await ssm.send(
|
|
new GetParameterCommand({ Name: name, WithDecryption: true })
|
|
);
|
|
return Parameter.Value;
|
|
}
|
|
|
|
async function main() {
|
|
console.log("Loading credentials from SSM...\n");
|
|
|
|
const [checkMgmtToken, accountInfoToken, accountNumber, companyId] = await Promise.all([
|
|
getSSMParam("/payments-dashboard/boa-check-mgmt-token"),
|
|
getSSMParam("/payments-dashboard/boa-account-info-token"),
|
|
getSSMParam("/payments-dashboard/boa-account-number"),
|
|
getSSMParam("/payments-dashboard/boa-company-id"),
|
|
]);
|
|
|
|
console.log("Credentials loaded. Testing sandbox endpoints...\n");
|
|
|
|
// --- Test 1: Check Issue (add_issue with a test check) ---
|
|
console.log("=".repeat(60));
|
|
console.log("TEST 1: Check Issue (add_issue)");
|
|
console.log("=".repeat(60));
|
|
|
|
const issuePayload = {
|
|
issueList: [
|
|
{
|
|
accountNumber,
|
|
checkNumber: "999999",
|
|
amount: "1.00",
|
|
issueAction: "add_issue",
|
|
issueDate: new Date().toISOString().split("T")[0],
|
|
},
|
|
],
|
|
};
|
|
|
|
console.log("Request:", JSON.stringify(issuePayload, null, 2), "\n");
|
|
|
|
try {
|
|
const issueRes = await fetch(
|
|
`${BOA_BASE_URL}/cashpro/checkmanagement/v1/check-issues`,
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${checkMgmtToken}`,
|
|
companyId,
|
|
},
|
|
body: JSON.stringify(issuePayload),
|
|
}
|
|
);
|
|
|
|
const issueHeaders = Object.fromEntries(issueRes.headers.entries());
|
|
const issueText = await issueRes.text();
|
|
|
|
console.log("Status:", issueRes.status);
|
|
console.log("Response Headers:", JSON.stringify(issueHeaders, null, 2));
|
|
console.log("Response Body:", issueText);
|
|
} catch (err) {
|
|
console.error("Check Issue request failed:", err.message);
|
|
}
|
|
|
|
// --- Test 2: Previous Day Transaction Inquiry ---
|
|
console.log("\n" + "=".repeat(60));
|
|
console.log("TEST 2: Previous Day Transaction Inquiry");
|
|
console.log("=".repeat(60));
|
|
|
|
const yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
const dateStr = yesterday.toISOString().split("T")[0];
|
|
|
|
const inquiryPayload = {
|
|
accounts: [{ accountNumber, bankId: "BOFAFRPP" }],
|
|
fromDate: dateStr,
|
|
toDate: dateStr,
|
|
};
|
|
|
|
console.log("Request:", JSON.stringify(inquiryPayload, null, 2), "\n");
|
|
|
|
try {
|
|
const inquiryRes = await fetch(
|
|
`${BOA_BASE_URL}/cashpro/reporting/v1/transaction-inquiries/previous-day`,
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${accountInfoToken}`,
|
|
},
|
|
body: JSON.stringify(inquiryPayload),
|
|
}
|
|
);
|
|
|
|
const inquiryHeaders = Object.fromEntries(inquiryRes.headers.entries());
|
|
const inquiryText = await inquiryRes.text();
|
|
|
|
console.log("Status:", inquiryRes.status);
|
|
console.log("Response Headers:", JSON.stringify(inquiryHeaders, null, 2));
|
|
console.log("Response Body:", inquiryText);
|
|
} catch (err) {
|
|
console.error("Transaction Inquiry request failed:", err.message);
|
|
}
|
|
|
|
console.log("\n" + "=".repeat(60));
|
|
console.log("Done. Look for: client ID, timestamp, transactionIdentification");
|
|
console.log("=".repeat(60));
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("Fatal error:", err);
|
|
process.exit(1);
|
|
});
|