bison-web-components 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/api.js +269 -0
- package/bison-operator-payments.js +866 -36
- package/demo-payments.html +91 -64
- package/package.json +1 -1
package/api.js
CHANGED
|
@@ -328,6 +328,275 @@ class BisonJibPayAPI {
|
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Create Plaid Link token
|
|
333
|
+
*
|
|
334
|
+
* Creates a Plaid Link token using the new API flow.
|
|
335
|
+
*
|
|
336
|
+
* @param {Object} payload - Plaid create-token request payload
|
|
337
|
+
* @param {string} payload.clientName - Client name shown in Plaid Link
|
|
338
|
+
* @param {string} payload.language - Language code (e.g., "en")
|
|
339
|
+
* @param {string[]} payload.products - Plaid products (e.g., ["auth"])
|
|
340
|
+
* @param {string[]} payload.countryCodes - Country codes (e.g., ["US"])
|
|
341
|
+
* @param {{clientUserId: string}} payload.user - Plaid user object
|
|
342
|
+
* @returns {Promise<any>}
|
|
343
|
+
*/
|
|
344
|
+
async createPlaidLinkToken(payload) {
|
|
345
|
+
if (!payload?.user?.clientUserId) {
|
|
346
|
+
throw {
|
|
347
|
+
status: 400,
|
|
348
|
+
data: {
|
|
349
|
+
success: false,
|
|
350
|
+
message: "user.clientUserId is required",
|
|
351
|
+
errors: ["payload.user.clientUserId parameter is missing"],
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return this.request("/api/plaid/create-token", {
|
|
357
|
+
method: "POST",
|
|
358
|
+
body: JSON.stringify(payload),
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Generate Plaid embeddable Link token
|
|
364
|
+
*
|
|
365
|
+
* Calls POST /api/plaid/embeddable/create-token with entityId as query param.
|
|
366
|
+
*
|
|
367
|
+
* Response codes:
|
|
368
|
+
* - 200: Link token created successfully
|
|
369
|
+
* - 400: Invalid request data or missing entityId
|
|
370
|
+
* - 401: Missing or invalid X-Embeddable-Key header
|
|
371
|
+
*
|
|
372
|
+
* @param {string} entityId - Entity UUID (required)
|
|
373
|
+
* @param {Object} payload - Plaid create-token request payload
|
|
374
|
+
* @param {string|null} [payload.clientName]
|
|
375
|
+
* @param {string|null} [payload.language]
|
|
376
|
+
* @param {string[]} [payload.products]
|
|
377
|
+
* @param {(string|null)[]} [payload.countryCodes]
|
|
378
|
+
* @param {{clientUserId?: string|null, legalName?: string|null, phoneNumber?: string|null, emailAddress?: string|null}} [payload.user]
|
|
379
|
+
* @param {string|null} [payload.redirectUri]
|
|
380
|
+
* @param {string|null} [payload.webhook]
|
|
381
|
+
* @returns {Promise<{success: boolean, message: string, data: {linkToken: string, expiration: string, requestId: string} | string, errors: string[], timestamp: string, traceId: string}>}
|
|
382
|
+
*/
|
|
383
|
+
async generatePlaidLinkToken(entityId, payload = {}) {
|
|
384
|
+
if (!entityId || typeof entityId !== "string" || !entityId.trim()) {
|
|
385
|
+
throw {
|
|
386
|
+
status: 400,
|
|
387
|
+
data: {
|
|
388
|
+
success: false,
|
|
389
|
+
message: "entityId is required",
|
|
390
|
+
errors: ["entityId parameter is missing"],
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const isUuid =
|
|
396
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
|
397
|
+
entityId
|
|
398
|
+
);
|
|
399
|
+
if (!isUuid) {
|
|
400
|
+
throw {
|
|
401
|
+
status: 400,
|
|
402
|
+
data: {
|
|
403
|
+
success: false,
|
|
404
|
+
message: "entityId must be a valid UUID",
|
|
405
|
+
errors: ["entityId parameter must be a UUID"],
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const params = new URLSearchParams();
|
|
411
|
+
params.append("entityId", entityId);
|
|
412
|
+
|
|
413
|
+
return this.request(`/api/plaid/embeddable/create-token?${params.toString()}`, {
|
|
414
|
+
method: "POST",
|
|
415
|
+
body: JSON.stringify(payload),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Register Plaid-linked bank account
|
|
421
|
+
*
|
|
422
|
+
* Registers a bank account after Plaid Link success using publicToken and accountId.
|
|
423
|
+
*
|
|
424
|
+
* @param {Object} payload - Bank account registration payload
|
|
425
|
+
* @param {string} payload.publicToken - Plaid public token
|
|
426
|
+
* @param {string} payload.accountId - Plaid account ID
|
|
427
|
+
* @param {number} payload.entityType - 0 for WIO, 1 for Operator
|
|
428
|
+
* @param {string} payload.entityId - WIO or Operator entity GUID
|
|
429
|
+
* @param {string} [payload.moovAccountId] - Optional Moov account ID
|
|
430
|
+
* @param {string} [payload.accountType] - Account type (e.g., "Checking")
|
|
431
|
+
* @param {string} [payload.description] - Description for registration
|
|
432
|
+
* @param {string} [payload.accountHolderName] - Account holder full name
|
|
433
|
+
* @returns {Promise<any>}
|
|
434
|
+
*/
|
|
435
|
+
async registerPlaidBankAccount(payload) {
|
|
436
|
+
if (!payload?.publicToken) {
|
|
437
|
+
throw {
|
|
438
|
+
status: 400,
|
|
439
|
+
data: {
|
|
440
|
+
success: false,
|
|
441
|
+
message: "publicToken is required",
|
|
442
|
+
errors: ["payload.publicToken parameter is missing"],
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (!payload?.accountId) {
|
|
448
|
+
throw {
|
|
449
|
+
status: 400,
|
|
450
|
+
data: {
|
|
451
|
+
success: false,
|
|
452
|
+
message: "accountId is required",
|
|
453
|
+
errors: ["payload.accountId parameter is missing"],
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (payload?.entityType !== 0 && payload?.entityType !== 1) {
|
|
459
|
+
throw {
|
|
460
|
+
status: 400,
|
|
461
|
+
data: {
|
|
462
|
+
success: false,
|
|
463
|
+
message: "entityType must be 0 (WIO) or 1 (Operator)",
|
|
464
|
+
errors: ["payload.entityType must be 0 or 1"],
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (!payload?.entityId) {
|
|
470
|
+
throw {
|
|
471
|
+
status: 400,
|
|
472
|
+
data: {
|
|
473
|
+
success: false,
|
|
474
|
+
message: "entityId is required",
|
|
475
|
+
errors: ["payload.entityId parameter is missing"],
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return this.request("/api/plaid/register-bank-account", {
|
|
481
|
+
method: "POST",
|
|
482
|
+
body: JSON.stringify(payload),
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Register Plaid-linked bank account (embeddable)
|
|
488
|
+
*
|
|
489
|
+
* Calls POST /api/plaid/embeddable/register-bank-account.
|
|
490
|
+
*
|
|
491
|
+
* Response codes:
|
|
492
|
+
* - 200: Bank account registered across processors
|
|
493
|
+
* - 400: Invalid request data or missing entityId
|
|
494
|
+
* - 401: Missing or invalid X-Embeddable-Key header
|
|
495
|
+
* - 500: Internal server error during registration
|
|
496
|
+
*
|
|
497
|
+
* @param {Object} payload - Bank account registration payload
|
|
498
|
+
* @param {string|null} [payload.publicToken]
|
|
499
|
+
* @param {string|null} [payload.accountId]
|
|
500
|
+
* @param {number} payload.entityType - 0 for WIO, 1 for Operator
|
|
501
|
+
* @param {string} payload.entityId - Entity ID
|
|
502
|
+
* @param {string|null} [payload.accountType]
|
|
503
|
+
* @param {string|null} [payload.description]
|
|
504
|
+
* @param {string|null} [payload.accountHolderName]
|
|
505
|
+
* @returns {Promise<{success: boolean, message: string, data: {registrations: Array<{provider: string, success: boolean, externalId: string, bankAccountId: string, errorMessage: string}>, allSucceeded: boolean, isTokenizedAccount: boolean, persistentAccountId: string, plaidItemId: string, isDuplicate: boolean} | string, errors: string[], timestamp: string, traceId: string}>}
|
|
506
|
+
*/
|
|
507
|
+
async registerEmbeddablePlaidBankAccount(payload = {}) {
|
|
508
|
+
if (payload?.entityType !== 0 && payload?.entityType !== 1) {
|
|
509
|
+
throw {
|
|
510
|
+
status: 400,
|
|
511
|
+
data: {
|
|
512
|
+
success: false,
|
|
513
|
+
message: "entityType must be 0 (WIO) or 1 (Operator)",
|
|
514
|
+
errors: ["payload.entityType must be 0 or 1"],
|
|
515
|
+
},
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (!payload?.entityId || typeof payload.entityId !== "string" || !payload.entityId.trim()) {
|
|
520
|
+
throw {
|
|
521
|
+
status: 400,
|
|
522
|
+
data: {
|
|
523
|
+
success: false,
|
|
524
|
+
message: "entityId is required",
|
|
525
|
+
errors: ["payload.entityId parameter is missing"],
|
|
526
|
+
},
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return this.request("/api/plaid/embeddable/register-bank-account", {
|
|
531
|
+
method: "POST",
|
|
532
|
+
body: JSON.stringify(payload),
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Retry Plaid bank account registration (embeddable)
|
|
538
|
+
*
|
|
539
|
+
* Calls POST /api/plaid/embeddable/retry-registration.
|
|
540
|
+
*
|
|
541
|
+
* Response codes:
|
|
542
|
+
* - 200: Retry registration completed
|
|
543
|
+
* - 400: Invalid request data or missing entityId
|
|
544
|
+
* - 401: Missing or invalid X-Embeddable-Key header
|
|
545
|
+
* - 404: Plaid item not found
|
|
546
|
+
* - 500: Internal server error during retry
|
|
547
|
+
*
|
|
548
|
+
* @param {Object} payload - Retry registration payload
|
|
549
|
+
* @param {string|null} [payload.plaidItemId]
|
|
550
|
+
* @param {string|null} [payload.accountId]
|
|
551
|
+
* @param {number} payload.entityType - 0 for WIO, 1 for Operator
|
|
552
|
+
* @param {string} payload.entityId - Entity ID
|
|
553
|
+
* @param {string[]} payload.providers - Provider names to retry against
|
|
554
|
+
* @returns {Promise<{success: boolean, message: string, data: {registrations: Array<{provider: string, success: boolean, externalId: string, bankAccountId: string, errorMessage: string}>, allSucceeded: boolean, isTokenizedAccount: boolean, persistentAccountId: string, plaidItemId: string, isDuplicate: boolean} | string, errors: string[], timestamp: string, traceId: string}>}
|
|
555
|
+
*/
|
|
556
|
+
async retryEmbeddablePlaidRegistration(payload = {}) {
|
|
557
|
+
if (payload?.entityType !== 0 && payload?.entityType !== 1) {
|
|
558
|
+
throw {
|
|
559
|
+
status: 400,
|
|
560
|
+
data: {
|
|
561
|
+
success: false,
|
|
562
|
+
message: "entityType must be 0 (WIO) or 1 (Operator)",
|
|
563
|
+
errors: ["payload.entityType must be 0 or 1"],
|
|
564
|
+
},
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (!payload?.entityId || typeof payload.entityId !== "string" || !payload.entityId.trim()) {
|
|
569
|
+
throw {
|
|
570
|
+
status: 400,
|
|
571
|
+
data: {
|
|
572
|
+
success: false,
|
|
573
|
+
message: "entityId is required",
|
|
574
|
+
errors: ["payload.entityId parameter is missing"],
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (
|
|
580
|
+
!Array.isArray(payload?.providers) ||
|
|
581
|
+
payload.providers.length === 0 ||
|
|
582
|
+
payload.providers.some((provider) => typeof provider !== "string" || !provider.trim())
|
|
583
|
+
) {
|
|
584
|
+
throw {
|
|
585
|
+
status: 400,
|
|
586
|
+
data: {
|
|
587
|
+
success: false,
|
|
588
|
+
message: "providers is required",
|
|
589
|
+
errors: ["payload.providers must be a non-empty string array"],
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return this.request("/api/plaid/embeddable/retry-registration", {
|
|
595
|
+
method: "POST",
|
|
596
|
+
body: JSON.stringify(payload),
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
|
|
331
600
|
/**
|
|
332
601
|
* Create Plaid processor token
|
|
333
602
|
*
|