Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions examples/avatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ const UNIQUE_ID = "031100649"; // Discover routing number
* Demonstrate how to get avatar associated with uniqueID.
*/
async function run() {
// Load credentials and initialize the Moov client
const credentials = loadCredentials("./secrets/credentials.json");
const moov = new Moov(credentials, gotOptionsForLogging);
try {
// Load credentials and initialize the Moov client
const credentials = loadCredentials("./secrets/credentials.json");
const moov = new Moov(credentials, gotOptionsForLogging);

try
{
const avatar = moov.avatars.get(UNIQUE_ID);
}
catch(err)
{
await moov.avatars.get(UNIQUE_ID);
} catch (err) {
console.error("Error: ", err.message);
}
}

run();
run();
28 changes: 16 additions & 12 deletions examples/createTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ async function run() {
amount: TRANSFER_AMOUNT,
});

try
{
// Select ACH
const sourcePaymentMethodID = sourceOptions.find(
try {
// Select ACH
const sourceOption = sourceOptions.find(
(x) => x.paymentMethodType === "ach-debit-fund"
).paymentMethodID;

);
if (!sourceOption) {
throw new Error("No ACH debit fund option available");
}
const sourcePaymentMethodID = sourceOption.paymentMethodID;
// Get destination transfer options given the source transfer option
const { destinationOptions } = await moov.transfers.getTransferOptions({
source: {
Expand All @@ -47,12 +49,16 @@ async function run() {
});

// Select ACH standard
const destinationPaymentMethodID = destinationOptions.find(
const destinationOption = destinationOptions.find(
(x) => x.paymentMethodType === "ach-credit-standard"
).paymentMethodID;
);
if (!destinationOption) {
throw new Error("No ACH credit standard option available");
}
const destinationPaymentMethodID = destinationOption.paymentMethodID;

// Create the transfer
const transfer = await moov.transfers.create({
await moov.transfers.create({
source: {
paymentMethodID: sourcePaymentMethodID,
},
Expand All @@ -61,9 +67,7 @@ async function run() {
},
amount: TRANSFER_AMOUNT,
});
}
catch(err)
{
} catch (err) {
// catch an exception you plan to handle, if not allow it to bubble up
console.error("Error: ", err.message);
}
Expand Down