@kuvarpay/sdk 1.5.0 → 1.6.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/README.md CHANGED
@@ -96,7 +96,7 @@ The SDK defaults to the KuvarPay Production API (`https://payment.kuvarpay.com`)
96
96
  | Method | Description |
97
97
  | :--- | :--- |
98
98
  | `getBanks({ country? \| currency?, type? })` | List a corridor's **primary-rail** payment methods (banks / mobile money). Pass a country (ISO-2) or currency (ISO-4217). |
99
- | `resolveBankAccount(data)` | Verify bank account names before creating subaccounts. |
99
+ | `resolveBankAccount(data)` | **Deprecated** alias for `resolveRecipient` — takes `methodId`, not `bank_code`. |
100
100
 
101
101
  ### 🌍 Fiat Collection (Pay with Local Currency)
102
102
 
package/index.d.ts CHANGED
@@ -236,7 +236,30 @@ export class KuvarPayServer {
236
236
  // Banks
237
237
  getBanks(currency: string, options?: { type?: 'bank' | 'mobile_money'; direction?: 'inbound' | 'outbound' }): Promise<{ methods: Array<{ methodId: string; name: string; currency: string; type: 'bank' | 'mobile_money'; manualInput?: boolean; minAmount?: number | null; maxAmount?: number | null }> }>;
238
238
  getBanks(params: { country?: string; currency?: string; type?: 'bank' | 'mobile_money'; direction?: 'inbound' | 'outbound' }): Promise<{ methods: Array<{ methodId: string; name: string; currency: string; type: 'bank' | 'mobile_money'; manualInput?: boolean; minAmount?: number | null; maxAmount?: number | null }> }>;
239
- resolveBankAccount(data: { bank_code: string; account_number: string; country_code?: string }): Promise<any>;
239
+ /**
240
+ * @deprecated Use `resolveRecipient`. Thin alias over
241
+ * `POST /api/v1/fiat/resolve-recipient`.
242
+ *
243
+ * The legacy `/api/v1/banks/resolve` endpoint was retired; passing `bank_code`
244
+ * now throws. Supply `methodId` from `getBanks({ direction: 'outbound' })`.
245
+ */
246
+ resolveBankAccount(data: {
247
+ methodId?: string;
248
+ method_id?: string;
249
+ accountNumber?: string;
250
+ account_number?: string;
251
+ phone?: string;
252
+ }): Promise<{
253
+ supported: boolean;
254
+ resolved: boolean;
255
+ accountName: string | null;
256
+ bankName?: string;
257
+ reason?: string | null;
258
+ /** Legacy alias for `accountName`. */
259
+ account_name: string | null;
260
+ /** Echo of the submitted account number. */
261
+ account_number: string | null;
262
+ }>;
240
263
 
241
264
  // Fiat collection (Pay with Local Currency)
242
265
  /**
package/index.js CHANGED
@@ -549,12 +549,37 @@ class KuvarPayServer {
549
549
  }
550
550
 
551
551
  /**
552
- * Resolve bank account name
553
- * POST /api/v1/banks/resolve
554
- * @param {Object} data - { bank_code, account_number, country_code? }
552
+ * Resolve a bank / mobile-money account name.
553
+ *
554
+ * @deprecated Use {@link resolveRecipient}. Kept as a thin alias so existing
555
+ * integrations keep working.
556
+ *
557
+ * The legacy `POST /api/v1/banks/resolve` endpoint (which took a raw
558
+ * `bank_code`) has been retired — calling it now 404s. Name enquiry runs
559
+ * through `POST /api/v1/fiat/resolve-recipient`, which is keyed off the opaque
560
+ * `methodId` from `getBanks()`.
561
+ *
562
+ * @param {Object} data - { methodId | method_id, accountNumber | account_number, phone }
555
563
  */
556
- async resolveBankAccount(data) {
557
- return this._post('/api/v1/banks/resolve', data);
564
+ async resolveBankAccount(data = {}) {
565
+ const methodId = data.methodId || data.method_id;
566
+ const accountNumber = data.accountNumber || data.account_number;
567
+ const phone = data.phone;
568
+
569
+ if (!methodId) {
570
+ throw new Error(
571
+ (data.bank_code || data.bankCode)
572
+ ? 'resolveBankAccount no longer accepts bank_code — the legacy /api/v1/banks endpoints were retired. ' +
573
+ 'Pass methodId from getBanks({ country, direction: "outbound" }) instead, or call resolveRecipient() directly.'
574
+ : 'methodId is required (get one from getBanks({ country, direction: "outbound" }))'
575
+ );
576
+ }
577
+
578
+ const result = await this.resolveRecipient({ methodId, accountNumber, phone });
579
+ return Object.assign({}, result, {
580
+ account_name: result && result.accountName != null ? result.accountName : null,
581
+ account_number: accountNumber != null ? accountNumber : null,
582
+ });
558
583
  }
559
584
 
560
585
  // --- Fiat collection (Pay with Local Currency) ---
package/index.mjs CHANGED
@@ -436,8 +436,40 @@ export class KuvarPayServer {
436
436
  return this._get(`/api/v1/fiat/banks?${qs.toString()}`);
437
437
  }
438
438
 
439
- async resolveBankAccount(data) {
440
- return this._post('/api/v1/banks/resolve', data);
439
+ /**
440
+ * @deprecated Use {@link resolveRecipient}. Kept as a thin alias so existing
441
+ * integrations keep working.
442
+ *
443
+ * The legacy `POST /api/v1/banks/resolve` endpoint (which took a raw
444
+ * `bank_code`) has been retired — calling it now 404s. Name enquiry runs
445
+ * through `POST /api/v1/fiat/resolve-recipient`, which is keyed off the opaque
446
+ * `methodId` from `getBanks()`.
447
+ *
448
+ * Accepts either the new field names or the legacy snake_case ones:
449
+ * { methodId | method_id, accountNumber | account_number, phone }
450
+ *
451
+ * Returns the resolveRecipient shape ({ supported, resolved, accountName, … })
452
+ * plus `account_name` / `account_number` aliases for older call sites.
453
+ */
454
+ async resolveBankAccount(data = {}) {
455
+ const methodId = data.methodId || data.method_id;
456
+ const accountNumber = data.accountNumber || data.account_number;
457
+ const phone = data.phone;
458
+
459
+ if (!methodId) {
460
+ throw new Error(
461
+ (data.bank_code || data.bankCode)
462
+ ? 'resolveBankAccount no longer accepts bank_code — the legacy /api/v1/banks endpoints were retired. ' +
463
+ 'Pass methodId from getBanks({ country, direction: "outbound" }) instead, or call resolveRecipient() directly.'
464
+ : 'methodId is required (get one from getBanks({ country, direction: "outbound" }))'
465
+ );
466
+ }
467
+
468
+ const result = await this.resolveRecipient({ methodId, accountNumber, phone });
469
+ return Object.assign({}, result, {
470
+ account_name: result && result.accountName != null ? result.accountName : null,
471
+ account_number: accountNumber != null ? accountNumber : null,
472
+ });
441
473
  }
442
474
 
443
475
  // --- Fiat collection (Pay with Local Currency) ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuvarpay/sdk",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Official KuvarPay Server SDK for Node.js",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -30,4 +30,4 @@
30
30
  },
31
31
  "author": "KuvarPay Team",
32
32
  "license": "MIT"
33
- }
33
+ }