@delopay/sdk 0.83.0 → 0.86.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.
@@ -434,6 +434,39 @@ var Connectors = class {
434
434
  async list(accountId) {
435
435
  return this.request("GET", `/account/${encodeURIComponent(accountId)}/connectors`);
436
436
  }
437
+ /**
438
+ * The profile-scoped connector list. The merchant-wide `list()` is
439
+ * merchant-gated and 403s for a profile-entity (shop user) JWT; this
440
+ * variant is scoped server-side to the caller's own profile.
441
+ *
442
+ * `GET /account/{accountId}/profile/connectors`
443
+ */
444
+ async listByProfile(accountId) {
445
+ return this.request("GET", `/account/${encodeURIComponent(accountId)}/profile/connectors`);
446
+ }
447
+ /**
448
+ * The built-in e-Payouts reference catalog — the "Restore defaults" source.
449
+ * `GET /account/{accountId}/connectors/epayouts/catalog/defaults`
450
+ */
451
+ async getEpayoutsCatalogDefaults(accountId) {
452
+ return this.request(
453
+ "GET",
454
+ `/account/${encodeURIComponent(accountId)}/connectors/epayouts/catalog/defaults`
455
+ );
456
+ }
457
+ /**
458
+ * Sweep the merchant's own e-Payouts module and return the rails it
459
+ * actually has enabled. Server-side this makes many upstream calls, so it
460
+ * can take several seconds — show progress.
461
+ *
462
+ * `POST /account/{accountId}/connectors/{connectorId}/epayouts/catalog/sync`
463
+ */
464
+ async syncEpayoutsCatalog(accountId, connectorId) {
465
+ return this.request(
466
+ "POST",
467
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/epayouts/catalog/sync`
468
+ );
469
+ }
437
470
  async update(accountId, connectorId, params) {
438
471
  return this.request(
439
472
  "POST",
@@ -466,6 +499,55 @@ var Connectors = class {
466
499
  );
467
500
  }
468
501
  // --- Advanced operations (Task 4.8) ---
502
+ /**
503
+ * Run the configuration checks for a vault (VGS) connector account:
504
+ * credential validity, write-only Collect scope, reachability, environment
505
+ * coherence, route coverage. Read-only but not cheap — it decrypts the
506
+ * vault's management credential and talks to VGS.
507
+ *
508
+ * `POST /account/{accountId}/connectors/{connectorId}/vault/verify`
509
+ */
510
+ async verifyVault(accountId, connectorId, params) {
511
+ return this.request(
512
+ "POST",
513
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/verify`,
514
+ { body: params }
515
+ );
516
+ }
517
+ /**
518
+ * Compute the route document the vault SHOULD have and diff it against
519
+ * what exists, without writing anything. The returned fingerprints must be
520
+ * echoed byte for byte on {@link Connectors.applyVaultRoutes}.
521
+ *
522
+ * A router without these endpoints answers 404 — render that as "this
523
+ * build cannot configure routes", never as "there is nothing to change".
524
+ *
525
+ * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/preview`
526
+ */
527
+ async previewVaultRoutes(accountId, connectorId, params) {
528
+ return this.request(
529
+ "POST",
530
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/preview`,
531
+ { body: params }
532
+ );
533
+ }
534
+ /**
535
+ * Write the routes the merchant just previewed. Both fingerprints come
536
+ * from the preview and are opaque: `expected_current_fingerprint` says the
537
+ * vault has not moved (`null` = "the preview found no routes" and is sent
538
+ * as `null`, never omitted), `expected_desired_fingerprint` says the
539
+ * document is still the one on screen. A 409 (`DE_04`) means the vault
540
+ * changed since the preview — nothing was written; preview again.
541
+ *
542
+ * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/apply`
543
+ */
544
+ async applyVaultRoutes(accountId, connectorId, params) {
545
+ return this.request(
546
+ "POST",
547
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/apply`,
548
+ { body: params }
549
+ );
550
+ }
469
551
  /** Verify connector credentials. `POST /account/connectors/verify` */
470
552
  async verify(params) {
471
553
  return this.request("POST", "/account/connectors/verify", { body: params });
@@ -1428,6 +1510,39 @@ var Payments = class {
1428
1510
  ...options
1429
1511
  });
1430
1512
  }
1513
+ /**
1514
+ * The status timeline of client/device observations captured while the
1515
+ * buyer interacted with the payment (checkout opens, confirms, redirect
1516
+ * legs, reported client signals), oldest first.
1517
+ *
1518
+ * `GET /payments/{paymentId}/client-context`
1519
+ */
1520
+ async listClientContext(paymentId, options) {
1521
+ return this.request(
1522
+ "GET",
1523
+ `/payments/${encodeURIComponent(paymentId)}/client-context`,
1524
+ options
1525
+ );
1526
+ }
1527
+ /**
1528
+ * Soft-delete a payment. Only payments whose status is in the merchant's
1529
+ * delete policy (see {@link Payments.getDeletePolicy}) can be deleted;
1530
+ * anything else fails with a precondition error.
1531
+ *
1532
+ * `DELETE /payments/{paymentId}`
1533
+ */
1534
+ async delete(paymentId, options) {
1535
+ return this.request("DELETE", `/payments/${encodeURIComponent(paymentId)}`, options);
1536
+ }
1537
+ /**
1538
+ * The effective deletable-status set for the calling merchant — lets a
1539
+ * dashboard show the delete action only where it is allowed.
1540
+ *
1541
+ * `GET /payments/delete-policy`
1542
+ */
1543
+ async getDeletePolicy(options) {
1544
+ return this.request("GET", "/payments/delete-policy", options);
1545
+ }
1431
1546
  // --- Advanced operations (Task 3.2) ---
1432
1547
  /** Generate session tokens. `POST /payments/session-tokens` */
1433
1548
  async sessionTokens(params) {
@@ -1498,10 +1613,30 @@ var Payments = class {
1498
1613
  async listByFilter(params) {
1499
1614
  return this.request("POST", "/payments/list", { body: params });
1500
1615
  }
1616
+ /**
1617
+ * List payments by filter, scoped to the caller's profile (the shop-user
1618
+ * twin of `listByFilter`). The backend narrows to the profile from the
1619
+ * auth context, so `profile_id` / `project_id` must not be sent.
1620
+ *
1621
+ * Not to be confused with {@link Payments.listByProfile}, which is the GET
1622
+ * cursor variant and rejects this body.
1623
+ *
1624
+ * `POST /payments/profile/list`
1625
+ */
1626
+ async listByProfileFilter(params, options) {
1627
+ return this.request("POST", "/payments/profile/list", { body: params, ...options });
1628
+ }
1501
1629
  /** Get payment filter options. `GET /payments/filter` */
1502
1630
  async getFilters(params) {
1503
1631
  return this.request("GET", "/payments/filter", { query: params });
1504
1632
  }
1633
+ /**
1634
+ * Get payment filter options, scoped to the caller's profile.
1635
+ * `GET /payments/profile/filter`
1636
+ */
1637
+ async getFiltersByProfile(params) {
1638
+ return this.request("GET", "/payments/profile/filter", { query: params });
1639
+ }
1505
1640
  /** Get payment aggregates. `GET /payments/aggregate` */
1506
1641
  async aggregate(params) {
1507
1642
  return this.request("GET", "/payments/aggregate", { query: params });
@@ -1702,6 +1837,16 @@ var Profiles = class {
1702
1837
  async list(accountId) {
1703
1838
  return this.request("GET", `/account/${encodeURIComponent(accountId)}/business-profile`);
1704
1839
  }
1840
+ /**
1841
+ * List the business profiles the caller can see at profile scope — the
1842
+ * `ProfileAccountRead` twin of `list()` (which needs merchant-level read).
1843
+ * A shop-scoped user gets exactly their own shop back.
1844
+ *
1845
+ * `GET /account/{accountId}/profile`
1846
+ */
1847
+ async listByProfile(accountId) {
1848
+ return this.request("GET", `/account/${encodeURIComponent(accountId)}/profile`);
1849
+ }
1705
1850
  async update(accountId, profileId, params) {
1706
1851
  return this.request(
1707
1852
  "POST",
@@ -2345,7 +2490,7 @@ var Shops = class {
2345
2490
  /**
2346
2491
  * Upload a logo file for a shop. The file is stored in Delopay's configured
2347
2492
  * object store and a public HTTPS URL is returned. This method does NOT write
2348
- * the URL into the shop's `payment_link_config.default_config.logo` — call
2493
+ * the URL into the shop's `payment_link_config.logo` — call
2349
2494
  * `shops.update` afterwards with the returned `logo_url` to persist the change.
2350
2495
  *
2351
2496
  * Accepts PNG, JPEG, WebP or SVG. The file must be ≤ 1 MiB.
@@ -2359,7 +2504,7 @@ var Shops = class {
2359
2504
  * ```typescript
2360
2505
  * const { logo_url } = await delopay.shops.uploadLogo('merch_1', 'pro_1', file);
2361
2506
  * await delopay.shops.update('merch_1', 'pro_1', {
2362
- * payment_link_config: { default_config: { logo: logo_url } },
2507
+ * payment_link_config: { logo: logo_url },
2363
2508
  * });
2364
2509
  * ```
2365
2510
  */
@@ -2372,6 +2517,29 @@ var Shops = class {
2372
2517
  { body: form }
2373
2518
  );
2374
2519
  }
2520
+ /**
2521
+ * Update only the checkout appearance (the `payment_link_config` blob:
2522
+ * theme, logo, colours, seller name, SDK layout/rules, DeloPay-branding
2523
+ * toggle) of a shop. Applied as a whole-object replace of
2524
+ * `payment_link_config`, mirroring the shop-update semantics.
2525
+ *
2526
+ * Gated on the dedicated `CheckoutBranding` permission, so "may restyle
2527
+ * the checkout" can be granted without full account/shop write.
2528
+ *
2529
+ * `POST /shops/{merchantId}/{shopId}/checkout-branding`
2530
+ *
2531
+ * @param merchantId - The merchant account ID.
2532
+ * @param shopId - The shop (business profile) ID to restyle.
2533
+ * @param params - The new `payment_link_config` blob (full replacement).
2534
+ * @returns The updated business profile.
2535
+ */
2536
+ async updateCheckoutBranding(merchantId, shopId, params, options) {
2537
+ return this.request(
2538
+ "POST",
2539
+ `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/checkout-branding`,
2540
+ { body: params, ...options }
2541
+ );
2542
+ }
2375
2543
  };
2376
2544
 
2377
2545
  // src/resources/stripeConnect.ts
@@ -2478,6 +2646,26 @@ var Users = class {
2478
2646
  async update(params) {
2479
2647
  return this.request("POST", "/user/update", { body: params });
2480
2648
  }
2649
+ /**
2650
+ * RFC 7396 merge-patch the caller's own user-scoped metadata bucket.
2651
+ * Returns the full user details, so callers can refresh their context
2652
+ * without a second fetch.
2653
+ *
2654
+ * `PATCH /user/metadata`
2655
+ */
2656
+ async updateMetadata(params) {
2657
+ return this.request("PATCH", "/user/metadata", { body: params });
2658
+ }
2659
+ /**
2660
+ * RFC 7396 merge-patch the merchant-scoped metadata bucket shared by
2661
+ * every dashboard user of the merchant. Same response contract as
2662
+ * {@link Users.updateMetadata}.
2663
+ *
2664
+ * `PATCH /user/merchant/metadata`
2665
+ */
2666
+ async updateMerchantMetadata(params) {
2667
+ return this.request("PATCH", "/user/merchant/metadata", { body: params });
2668
+ }
2481
2669
  /**
2482
2670
  * Permanently delete the caller's account. Requires a fresh password
2483
2671
  * (and a current 6-digit TOTP code if the user has TOTP enrolled). On
@@ -3237,6 +3425,283 @@ var Subscriptions = class {
3237
3425
  ...options
3238
3426
  });
3239
3427
  }
3428
+ /**
3429
+ * Resolve which of the given payments were raised by a subscription.
3430
+ * `POST /subscriptions/payments/lookup`
3431
+ *
3432
+ * The linkage exists in one direction only — an invoice points at the payment
3433
+ * it settled, and nothing is stamped on the payment — so this is the only way
3434
+ * to tell a subscription charge from a one-off one when you are holding a
3435
+ * page of payments. In particular, do not use `off_session` or the presence
3436
+ * of a mandate: an ordinary saved-card charge sets those identically.
3437
+ *
3438
+ * Ids that belong to no subscription are **absent** from `links` rather than
3439
+ * returned as an error, so match on presence:
3440
+ *
3441
+ * ```ts
3442
+ * const { links } = await subscriptions.lookupPayments(
3443
+ * { payment_ids: page.map((p) => p.payment_id) },
3444
+ * { headers: { 'X-Profile-Id': profileId } },
3445
+ * );
3446
+ * const bySubscription = new Map(links.map((l) => [l.payment_id, l]));
3447
+ * ```
3448
+ *
3449
+ * Profile-scoped like every other subscription route, and that matters more
3450
+ * here than elsewhere: a `payment_id` is merchant-supplied and only unique
3451
+ * within a merchant, so the shop is part of the question, not an
3452
+ * optimisation. Pass the profile that owns **the payments** — for a list
3453
+ * spanning several shops, group the ids by shop and call once per group.
3454
+ *
3455
+ * At most 200 ids per call.
3456
+ */
3457
+ async lookupPayments(params, options) {
3458
+ return this.request("POST", "/subscriptions/payments/lookup", { body: params, ...options });
3459
+ }
3460
+ };
3461
+
3462
+ // src/resources/settlement.ts
3463
+ var Settlement = class {
3464
+ constructor(request) {
3465
+ this.request = request;
3466
+ }
3467
+ /**
3468
+ * Per-shop settlement rollup for the host merchant: unpaid totals and the
3469
+ * running current period, one row per shop.
3470
+ *
3471
+ * `GET /settlement/overview`
3472
+ */
3473
+ async overview(params, options) {
3474
+ return this.request("GET", "/settlement/overview", {
3475
+ query: { test_mode: params.test_mode },
3476
+ ...options
3477
+ });
3478
+ }
3479
+ /**
3480
+ * Live rollup of the current (not yet statemented) period.
3481
+ *
3482
+ * `GET /settlement/current`
3483
+ */
3484
+ async current(params, options) {
3485
+ return this.request("GET", "/settlement/current", {
3486
+ query: { test_mode: params.test_mode, profile_id: params.profile_id },
3487
+ ...options
3488
+ });
3489
+ }
3490
+ /**
3491
+ * List generated settlement statements, newest first.
3492
+ *
3493
+ * `GET /settlement/statements`
3494
+ */
3495
+ async listStatements(params, options) {
3496
+ return this.request("GET", "/settlement/statements", {
3497
+ query: {
3498
+ test_mode: params.test_mode,
3499
+ profile_id: params.profile_id,
3500
+ limit: params.limit,
3501
+ offset: params.offset
3502
+ },
3503
+ ...options
3504
+ });
3505
+ }
3506
+ /**
3507
+ * One statement with its per-connector/currency breakdown.
3508
+ *
3509
+ * `GET /settlement/statements/{statementId}`
3510
+ */
3511
+ async retrieveStatement(statementId, options) {
3512
+ return this.request(
3513
+ "GET",
3514
+ `/settlement/statements/${encodeURIComponent(statementId)}`,
3515
+ options
3516
+ );
3517
+ }
3518
+ /**
3519
+ * Generate (or regenerate) the statement for one shop and calendar month.
3520
+ *
3521
+ * `POST /settlement/statements/generate`
3522
+ */
3523
+ async generateStatement(params, options) {
3524
+ return this.request("POST", "/settlement/statements/generate", {
3525
+ body: params,
3526
+ ...options
3527
+ });
3528
+ }
3529
+ /**
3530
+ * Record payout progress on a statement (`unpaid` / `partial` / `paid`).
3531
+ *
3532
+ * `POST /settlement/statements/{statementId}/payout`
3533
+ */
3534
+ async updateStatementPayout(statementId, params, options) {
3535
+ return this.request(
3536
+ "POST",
3537
+ `/settlement/statements/${encodeURIComponent(statementId)}/payout`,
3538
+ { body: params, ...options }
3539
+ );
3540
+ }
3541
+ /**
3542
+ * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with
3543
+ * the same auth, retries and error handling as every other call — persist
3544
+ * or object-URL it caller-side.
3545
+ *
3546
+ * `GET /settlement/statements/{statementId}/pdf`
3547
+ *
3548
+ * @example
3549
+ * ```typescript
3550
+ * const pdf = await delopay.settlement.downloadStatementPdf('stmt_1', {
3551
+ * currency: 'EUR',
3552
+ * include_transactions: true,
3553
+ * });
3554
+ * const url = URL.createObjectURL(pdf);
3555
+ * ```
3556
+ */
3557
+ async downloadStatementPdf(statementId, params, options) {
3558
+ return this.request("GET", `/settlement/statements/${encodeURIComponent(statementId)}/pdf`, {
3559
+ query: {
3560
+ currency: params?.currency,
3561
+ include_transactions: params?.include_transactions
3562
+ },
3563
+ responseType: "blob",
3564
+ ...options
3565
+ });
3566
+ }
3567
+ /**
3568
+ * The individual settled attempts of one shop's calendar month.
3569
+ *
3570
+ * `GET /settlement/lines`
3571
+ */
3572
+ async listLines(params, options) {
3573
+ return this.request("GET", "/settlement/lines", {
3574
+ query: {
3575
+ profile_id: params.profile_id,
3576
+ year: params.year,
3577
+ month: params.month,
3578
+ test_mode: params.test_mode,
3579
+ limit: params.limit,
3580
+ offset: params.offset
3581
+ },
3582
+ ...options
3583
+ });
3584
+ }
3585
+ /**
3586
+ * The fee schedules that currently apply to a shop.
3587
+ *
3588
+ * `GET /settlement/fee-config`
3589
+ */
3590
+ async feeConfig(params, options) {
3591
+ return this.request("GET", "/settlement/fee-config", {
3592
+ query: { profile_id: params.profile_id },
3593
+ ...options
3594
+ });
3595
+ }
3596
+ /**
3597
+ * Enqueue a settlement-line backfill over historical attempts. Attempts
3598
+ * already covered by a line are always skipped.
3599
+ *
3600
+ * `POST /settlement/backfill`
3601
+ */
3602
+ async backfill(params, options) {
3603
+ return this.request("POST", "/settlement/backfill", { body: params, ...options });
3604
+ }
3605
+ /**
3606
+ * Toggle whether a shop's owner can see their own settlement figures.
3607
+ *
3608
+ * `POST /settlement/shops/visibility`
3609
+ */
3610
+ async setShopVisibility(params, options) {
3611
+ return this.request("POST", "/settlement/shops/visibility", {
3612
+ body: params,
3613
+ ...options
3614
+ });
3615
+ }
3616
+ /**
3617
+ * Manual adjustments recorded on a statement.
3618
+ *
3619
+ * `GET /settlement/statements/{statementId}/adjustments`
3620
+ */
3621
+ async listStatementAdjustments(statementId, options) {
3622
+ return this.request(
3623
+ "GET",
3624
+ `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,
3625
+ options
3626
+ );
3627
+ }
3628
+ /**
3629
+ * Add a manual adjustment to a statement. Positive `amount_usd` charges
3630
+ * the shop (reducing their payout); negative credits them.
3631
+ *
3632
+ * `POST /settlement/statements/{statementId}/adjustments`
3633
+ */
3634
+ async createStatementAdjustment(statementId, params, options) {
3635
+ return this.request(
3636
+ "POST",
3637
+ `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,
3638
+ { body: params, ...options }
3639
+ );
3640
+ }
3641
+ /**
3642
+ * Remove a manual adjustment from a statement.
3643
+ *
3644
+ * `DELETE /settlement/statements/{statementId}/adjustments/{adjustmentId}`
3645
+ */
3646
+ async deleteStatementAdjustment(statementId, adjustmentId, options) {
3647
+ return this.request(
3648
+ "DELETE",
3649
+ `/settlement/statements/${encodeURIComponent(statementId)}/adjustments/${encodeURIComponent(adjustmentId)}`,
3650
+ options
3651
+ );
3652
+ }
3653
+ };
3654
+
3655
+ // src/resources/operationLimits.ts
3656
+ var OperationLimits = class {
3657
+ constructor(request) {
3658
+ this.request = request;
3659
+ }
3660
+ /**
3661
+ * List the merchant's limit rules, optionally for one operation.
3662
+ *
3663
+ * `GET /operation-limits/rules`
3664
+ */
3665
+ async listRules(params, options) {
3666
+ return this.request("GET", "/operation-limits/rules", {
3667
+ query: { operation: params?.operation },
3668
+ ...options
3669
+ });
3670
+ }
3671
+ /**
3672
+ * Create or replace the limit rule for one target. Full-replace upsert:
3673
+ * absent limit fields clear that dimension.
3674
+ *
3675
+ * `PUT /operation-limits/rules`
3676
+ */
3677
+ async upsertRule(params, options) {
3678
+ return this.request("PUT", "/operation-limits/rules", { body: params, ...options });
3679
+ }
3680
+ /**
3681
+ * Delete a limit rule.
3682
+ *
3683
+ * `DELETE /operation-limits/rules/{ruleId}`
3684
+ */
3685
+ async deleteRule(ruleId, options) {
3686
+ return this.request("DELETE", `/operation-limits/rules/${encodeURIComponent(ruleId)}`, options);
3687
+ }
3688
+ /**
3689
+ * The merchant-level enforcement settings. An untouched merchant gets the
3690
+ * defaults: rolling window, admins not exempt.
3691
+ *
3692
+ * `GET /operation-limits/settings`
3693
+ */
3694
+ async retrieveSettings(options) {
3695
+ return this.request("GET", "/operation-limits/settings", options);
3696
+ }
3697
+ /**
3698
+ * Update the enforcement settings. Only provided fields change.
3699
+ *
3700
+ * `PUT /operation-limits/settings`
3701
+ */
3702
+ async updateSettings(params, options) {
3703
+ return this.request("PUT", "/operation-limits/settings", { body: params, ...options });
3704
+ }
3240
3705
  };
3241
3706
 
3242
3707
  // src/client.ts
@@ -3366,6 +3831,8 @@ var Delopay = class {
3366
3831
  this.relay = new Relay(request);
3367
3832
  this.stripeConnect = new StripeConnect(request);
3368
3833
  this.threeDsRules = new ThreeDsRules(request);
3834
+ this.settlement = new Settlement(request);
3835
+ this.operationLimits = new OperationLimits(request);
3369
3836
  this.subscriptions = new Subscriptions(request);
3370
3837
  this.files = new Files(request);
3371
3838
  this.export = new Export(request);
@@ -3489,7 +3956,8 @@ var Delopay = class {
3489
3956
  method,
3490
3957
  headers,
3491
3958
  body: serializedBody,
3492
- signal: combined.signal
3959
+ signal: combined.signal,
3960
+ ...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
3493
3961
  });
3494
3962
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
3495
3963
  emit("response", { status: response.status, method, path, requestId });
@@ -3536,6 +4004,12 @@ var Delopay = class {
3536
4004
  }
3537
4005
  throw error;
3538
4006
  }
4007
+ if (options?.responseType === "blob") {
4008
+ return await response.blob();
4009
+ }
4010
+ if (options?.responseType === "arraybuffer") {
4011
+ return await response.arrayBuffer();
4012
+ }
3539
4013
  const text = await response.text();
3540
4014
  return text ? JSON.parse(text) : void 0;
3541
4015
  } catch (err) {
@@ -4779,6 +5253,205 @@ function shadowFor(style) {
4779
5253
  }
4780
5254
  }
4781
5255
 
5256
+ // src/checkoutSession.ts
5257
+ function withoutCredentialHeaders(extra) {
5258
+ if (!extra) return {};
5259
+ const out = {};
5260
+ for (const [key, value] of Object.entries(extra)) {
5261
+ const lower = key.toLowerCase();
5262
+ if (lower === "api-key" || lower === "authorization") continue;
5263
+ out[key] = value;
5264
+ }
5265
+ return out;
5266
+ }
5267
+ var CheckoutSession = class {
5268
+ constructor(options) {
5269
+ this.merchantId = options.merchantId;
5270
+ this.paymentId = options.paymentId;
5271
+ this.publishableKey = options.publishableKey;
5272
+ this.clientSecret = options.clientSecret;
5273
+ this.client = new Delopay("", {
5274
+ baseUrl: options.baseUrl,
5275
+ sandbox: options.sandbox,
5276
+ timeout: options.timeout,
5277
+ maxRetries: options.maxRetries,
5278
+ debug: options.debug,
5279
+ logger: options.logger
5280
+ });
5281
+ }
5282
+ get linkBase() {
5283
+ return `/payment-link/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`;
5284
+ }
5285
+ /** Headers for the client-secret bearer routes (`/payment-link/*`). */
5286
+ bearerHeaders(extra) {
5287
+ return {
5288
+ ...withoutCredentialHeaders(extra),
5289
+ Authorization: `Bearer ${this.requireClientSecret()}`
5290
+ };
5291
+ }
5292
+ /** Headers for the publishable-key routes (`/payments/*`, `/payment-methods`). */
5293
+ pkHeaders(extra) {
5294
+ if (!this.publishableKey) {
5295
+ throw new DelopayError("This call requires the publishable key", {
5296
+ status: 0,
5297
+ code: "MISSING_CREDENTIAL",
5298
+ type: "invalid_request"
5299
+ });
5300
+ }
5301
+ return { ...withoutCredentialHeaders(extra), "api-key": this.publishableKey };
5302
+ }
5303
+ requireClientSecret() {
5304
+ if (!this.clientSecret) {
5305
+ throw new DelopayError("This call requires the payment client secret", {
5306
+ status: 0,
5307
+ code: "MISSING_CREDENTIAL",
5308
+ type: "invalid_request"
5309
+ });
5310
+ }
5311
+ return this.clientSecret;
5312
+ }
5313
+ /**
5314
+ * The Paysepro rail catalog for the buyer's country.
5315
+ *
5316
+ * `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`
5317
+ *
5318
+ * @param country - Lowercase ISO 3166-1 alpha-2 country code.
5319
+ */
5320
+ async payseproMethods(country, options) {
5321
+ return this.client.request("GET", `${this.linkBase}/paysepro/methods`, {
5322
+ query: { cc: country },
5323
+ ...options,
5324
+ headers: this.bearerHeaders(options?.headers)
5325
+ });
5326
+ }
5327
+ /**
5328
+ * The e-Payouts rail catalog for the buyer's country, plus the set of
5329
+ * countries that have at least one vendor.
5330
+ *
5331
+ * `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`
5332
+ *
5333
+ * @param country - Lowercase ISO 3166-1 alpha-2 country code.
5334
+ */
5335
+ async epayoutsMethods(country, options) {
5336
+ return this.client.request("GET", `${this.linkBase}/epayouts/methods`, {
5337
+ query: { cc: country },
5338
+ ...options,
5339
+ headers: this.bearerHeaders(options?.headers)
5340
+ });
5341
+ }
5342
+ /**
5343
+ * Record a buyer-side checkout event on the payment's status timeline.
5344
+ *
5345
+ * Telemetry semantics, built in so callers can genuinely fire-and-forget:
5346
+ * the request is sent with `keepalive: true` (it survives the document
5347
+ * navigating away, e.g. right before a `window.open`), and transport or
5348
+ * server failures resolve to `undefined` instead of rejecting — telemetry
5349
+ * must never break a checkout or surface an unhandled rejection. Do not
5350
+ * `await` this in a click handler that must stay synchronous.
5351
+ *
5352
+ * A missing client secret still throws `MISSING_CREDENTIAL`: that is a
5353
+ * wiring bug, not a telemetry failure.
5354
+ *
5355
+ * `POST /payment-link/{merchantId}/{paymentId}/checkout-events`
5356
+ */
5357
+ async recordEvent(params, options) {
5358
+ const headers = this.bearerHeaders(options?.headers);
5359
+ try {
5360
+ return await this.client.request("POST", `${this.linkBase}/checkout-events`, {
5361
+ body: params,
5362
+ keepalive: true,
5363
+ ...options,
5364
+ headers
5365
+ });
5366
+ } catch {
5367
+ return void 0;
5368
+ }
5369
+ }
5370
+ /**
5371
+ * A short-lived VGS Collect session for browser-side card capture.
5372
+ *
5373
+ * A 404 — or a 400 carrying the "shop has no vault" code — means the shop
5374
+ * has no vault configured; other errors must NOT be treated that way (a
5375
+ * refused vault falling back to an unprotected card pane is exactly the
5376
+ * bug this endpoint's error contract exists to prevent).
5377
+ *
5378
+ * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
5379
+ */
5380
+ async vaultCollectSession(options) {
5381
+ return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
5382
+ ...options,
5383
+ headers: this.bearerHeaders(options?.headers)
5384
+ });
5385
+ }
5386
+ /**
5387
+ * Register the aliased card as a payment method and mint the one-shot
5388
+ * `payment_token` the confirm call spends.
5389
+ *
5390
+ * `POST /payment-link/{merchantId}/{paymentId}/vault/payment-method`
5391
+ */
5392
+ async registerVaultPaymentMethod(params, options) {
5393
+ return this.client.request("POST", `${this.linkBase}/vault/payment-method`, {
5394
+ body: params,
5395
+ ...options,
5396
+ headers: this.bearerHeaders(options?.headers)
5397
+ });
5398
+ }
5399
+ /**
5400
+ * The payment's current state — status polling for redirect/popup rails.
5401
+ *
5402
+ * `GET /payments/{paymentId}` (publishable key + client secret)
5403
+ */
5404
+ async retrievePayment(options) {
5405
+ return this.client.request("GET", `/payments/${encodeURIComponent(this.paymentId)}`, {
5406
+ query: { client_secret: this.requireClientSecret() },
5407
+ ...options,
5408
+ headers: this.pkHeaders(options?.headers)
5409
+ });
5410
+ }
5411
+ /**
5412
+ * Update the payment before confirmation (e.g. persist custom-field
5413
+ * answers as `metadata` on rails that never hit `/confirm`). The client
5414
+ * secret is attached automatically.
5415
+ *
5416
+ * `POST /payments/{paymentId}` (publishable key)
5417
+ */
5418
+ async updatePayment(params, options) {
5419
+ return this.client.request("POST", `/payments/${encodeURIComponent(this.paymentId)}`, {
5420
+ body: { ...params, client_secret: this.requireClientSecret() },
5421
+ ...options,
5422
+ headers: this.pkHeaders(options?.headers)
5423
+ });
5424
+ }
5425
+ /**
5426
+ * Confirm the payment. The client secret is attached automatically; pass
5427
+ * an `Idempotency-Key` header via `options` to make retries safe.
5428
+ *
5429
+ * `POST /payments/{paymentId}/confirm` (publishable key)
5430
+ */
5431
+ async confirmPayment(params, options) {
5432
+ return this.client.request("POST", `/payments/${encodeURIComponent(this.paymentId)}/confirm`, {
5433
+ body: { ...params, client_secret: this.requireClientSecret() },
5434
+ ...options,
5435
+ headers: this.pkHeaders(options?.headers)
5436
+ });
5437
+ }
5438
+ /**
5439
+ * Payment methods available for this payment.
5440
+ *
5441
+ * `GET /payment-methods` (publishable key + client secret)
5442
+ *
5443
+ * @param params - Optional filters; `country` is the highest-precedence
5444
+ * geo hint, ahead of billing address and IP geolocation.
5445
+ */
5446
+ async listPaymentMethods(params, options) {
5447
+ return this.client.request("GET", "/payment-methods", {
5448
+ query: { client_secret: this.requireClientSecret(), country: params?.country },
5449
+ ...options,
5450
+ headers: this.pkHeaders(options?.headers)
5451
+ });
5452
+ }
5453
+ };
5454
+
4782
5455
  // src/nativePanes.ts
4783
5456
  var STRIPE_NATIVE_PANE_METHODS = [
4784
5457
  {
@@ -5023,6 +5696,8 @@ export {
5023
5696
  Regions,
5024
5697
  AvailabilityOverrides,
5025
5698
  Subscriptions,
5699
+ Settlement,
5700
+ OperationLimits,
5026
5701
  Delopay,
5027
5702
  leaf,
5028
5703
  allOf,
@@ -5084,6 +5759,7 @@ export {
5084
5759
  parseImportedBranding,
5085
5760
  applyBrandingVariables,
5086
5761
  shadowFor,
5762
+ CheckoutSession,
5087
5763
  STRIPE_NATIVE_PANE_METHODS,
5088
5764
  NATIVE_PANE_ICON_KEYS,
5089
5765
  NATIVE_PANE_CATEGORY_KEYS,
@@ -5096,4 +5772,4 @@ export {
5096
5772
  focusedCheckoutUrl,
5097
5773
  CHECKOUT_EVENT_KINDS
5098
5774
  };
5099
- //# sourceMappingURL=chunk-G44EQT6Q.js.map
5775
+ //# sourceMappingURL=chunk-DQ36QCU7.js.map