@delopay/sdk 0.334.0 → 0.337.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
@@ -26,7 +26,7 @@ const delopay = new Delopay(process.env.DELOPAY_API_KEY!);
26
26
  const payment = await delopay.payments.create({
27
27
  amount: 1000, // in minor units (€10.00)
28
28
  currency: 'EUR',
29
- description: 'Order #1234',
29
+ description: 'Order 1234',
30
30
  customer_id: 'cus_abc123',
31
31
  });
32
32
 
@@ -66,7 +66,7 @@ const payment = await delopay.payments.create({
66
66
  currency: 'EUR',
67
67
  payment_link: true,
68
68
  customer_id: 'cus_abc123',
69
- description: 'Order #1234',
69
+ description: 'Order 1234',
70
70
  return_url: 'https://example.com/checkout/complete',
71
71
  });
72
72
 
@@ -733,7 +733,7 @@ var Connectors = class {
733
733
  );
734
734
  }
735
735
  /**
736
- * Share a connector with more shops of the same merchant (todos#320).
736
+ * Share a connector with more shops of the same merchant.
737
737
  * `POST /account/{accountId}/connectors/{connectorId}/shops`
738
738
  *
739
739
  * Nothing is copied: every shop sends payments to the same account, on the
@@ -747,7 +747,7 @@ var Connectors = class {
747
747
  );
748
748
  }
749
749
  /**
750
- * Fold copies of the same provider account into this connector (todos#395).
750
+ * Fold copies of the same provider account into this connector.
751
751
  * `POST /account/{accountId}/connectors/{connectorId}/consolidate`
752
752
  *
753
753
  * The copies' shops move to the connector with their on/off state, routing,
@@ -775,7 +775,7 @@ var Connectors = class {
775
775
  );
776
776
  }
777
777
  /**
778
- * Stop a connector serving one shop (todos#407). Any shop may leave, the
778
+ * Stop a connector serving one shop. Any shop may leave, the
779
779
  * one the connector was created in included, while another one stays: the
780
780
  * last shop is refused, and the connector is deleted instead. The account,
781
781
  * its limits and every other shop on it are unaffected.
@@ -790,7 +790,7 @@ var Connectors = class {
790
790
  /**
791
791
  * Read the transaction currencies a connector may process: its own list,
792
792
  * what the provider is known to accept with its methods, and the effective
793
- * currencies in each shop it serves (todos#333).
793
+ * currencies in each shop it serves.
794
794
  * `GET /account/{accountId}/connectors/{connectorId}/currencies`
795
795
  */
796
796
  async getCurrencies(accountId, connectorId) {
@@ -6470,7 +6470,7 @@ var SellToRestrictions = class {
6470
6470
  );
6471
6471
  }
6472
6472
  /**
6473
- * One payment connector account's own policy (todos#504), and which buyer
6473
+ * One payment connector account's own policy, and which buyer
6474
6474
  * signals its payments can be judged on. Needs the merchant-level `Read`
6475
6475
  * rung; a shop-scoped role is refused.
6476
6476
  * `GET /sell-to-restrictions/connectors/{merchant_connector_id}`
@@ -10578,6 +10578,9 @@ var Delopay = class {
10578
10578
  this.maxRetries = options?.maxRetries ?? 2;
10579
10579
  this.debug = options?.debug ?? false;
10580
10580
  if (options?.logger !== void 0) this.logger = options.logger;
10581
+ if (options?.profileId !== void 0 && options.profileId !== "") {
10582
+ this.profileId = options.profileId;
10583
+ }
10581
10584
  if (options?.baseUrl !== void 0) {
10582
10585
  this.baseUrl = options.baseUrl;
10583
10586
  } else if (options?.sandbox) {
@@ -10726,6 +10729,17 @@ var Delopay = class {
10726
10729
  return url;
10727
10730
  }
10728
10731
  /** The credential header: the JWT when one is set, else the API key. */
10732
+ /**
10733
+ * The client's `X-Profile-Id`, unless the call names one itself (in any
10734
+ * letter case: two spellings would be sent as one joined value).
10735
+ */
10736
+ profileHeaders(callHeaders) {
10737
+ if (this.profileId === void 0) return {};
10738
+ const named = Object.keys(callHeaders ?? {}).some(
10739
+ (name) => name.toLowerCase() === "x-profile-id"
10740
+ );
10741
+ return named ? {} : { "X-Profile-Id": this.profileId };
10742
+ }
10729
10743
  authHeaders() {
10730
10744
  if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };
10731
10745
  if (this.apiKey) return { "api-key": this.apiKey };
@@ -10769,6 +10783,7 @@ var Delopay = class {
10769
10783
  const lastEventId = options.lastEventId ?? "";
10770
10784
  const headers = {
10771
10785
  ...this.authHeaders(),
10786
+ ...this.profileHeaders(options.headers),
10772
10787
  Accept: "text/event-stream",
10773
10788
  ...lastEventId ? { "Last-Event-ID": lastEventId } : {},
10774
10789
  ...options.headers
@@ -10906,6 +10921,7 @@ var Delopay = class {
10906
10921
  const url = this.buildUrl(path, options?.query);
10907
10922
  let headers = {
10908
10923
  ...this.authHeaders(),
10924
+ ...this.profileHeaders(options?.headers),
10909
10925
  ...options?.headers
10910
10926
  };
10911
10927
  const isRawBody = options?.body !== void 0 && options?.body !== null && (options.body instanceof FormData || options.body instanceof Blob || options.body instanceof ArrayBuffer || options.body instanceof URLSearchParams);
@@ -13495,7 +13511,7 @@ function decodeBranding(source) {
13495
13511
  DEFAULT_BRANDING.whopSelection
13496
13512
  ),
13497
13513
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
13498
- // A look stored before todos#412 has no e-Payouts keys: the form keeps
13514
+ // A look stored before e-Payouts had its own keys has none: the form keeps
13499
13515
  // the PayPal values it was drawn with until then.
13500
13516
  epayoutsCardLayout: pickEnum(
13501
13517
  extras["epayoutsCardLayout"],
@@ -14184,7 +14200,7 @@ function parseImportedBranding(raw) {
14184
14200
  dflt.whopSelection
14185
14201
  ),
14186
14202
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
14187
- // A look stored before todos#412 has no e-Payouts keys: the form keeps
14203
+ // A look stored before e-Payouts had its own keys has none: the form keeps
14188
14204
  // the PayPal values it was drawn with until then.
14189
14205
  epayoutsCardLayout: pickEnum(
14190
14206
  root["epayoutsCardLayout"],
@@ -14644,6 +14660,47 @@ var CheckoutSession = class {
14644
14660
  }
14645
14661
  );
14646
14662
  }
14663
+ /**
14664
+ * The methods the buyer may pick for a subscription that waits for the
14665
+ * choice (`method_choice_pending`), judged for the buyer. Call it from the
14666
+ * buyer's browser: the sell-to country is read from this request's own
14667
+ * connection. Authenticated with the subscription's client secret.
14668
+ *
14669
+ * `GET /subscriptions/method-options/{merchantId}/{subscriptionId}`
14670
+ */
14671
+ async subscriptionMethodOptions(options) {
14672
+ return this.client.request(
14673
+ "GET",
14674
+ `/subscriptions/method-options/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
14675
+ {
14676
+ ...options,
14677
+ headers: this.bearerHeaders(options?.headers)
14678
+ }
14679
+ );
14680
+ }
14681
+ /**
14682
+ * Bind a waiting subscription to the method the buyer picked and open its
14683
+ * first cycle on that method's billing account. The methods are judged
14684
+ * again from this request; afterwards
14685
+ * {@link CheckoutSession.fetchSubscriptionData} describes the bound
14686
+ * subscription (Stripe's Payment Element for `card`, `confirmSubscription`
14687
+ * for the others). A subscription that no longer waits answers 409
14688
+ * (`DE_20`). Authenticated with the subscription's client secret.
14689
+ *
14690
+ * `POST /subscriptions/select-method/{merchantId}/{subscriptionId}`
14691
+ */
14692
+ async selectSubscriptionMethod(method, options) {
14693
+ const body = { method };
14694
+ return this.client.request(
14695
+ "POST",
14696
+ `/subscriptions/select-method/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
14697
+ {
14698
+ body,
14699
+ ...options,
14700
+ headers: this.bearerHeaders(options?.headers)
14701
+ }
14702
+ );
14703
+ }
14647
14704
  /**
14648
14705
  * Confirm a subscription (PayPal approval rail). The client secret is
14649
14706
  * attached automatically; the shop's profile id travels as the
@@ -14917,7 +14974,8 @@ var CheckoutSession = class {
14917
14974
  * Only `authorized: true` permits the form to contact its processor. A
14918
14975
  * competing flow receives `false` and must reload; an unresolved provider
14919
14976
  * outcome stays reserved, regardless of elapsed time. A buyer-blocklist
14920
- * refusal throws a `DelopayError` with code `DE_14`.
14977
+ * refusal throws a `DelopayError` with code `DE_14`; a shop whose payments
14978
+ * DeloPay stopped is refused with `DE_22`.
14921
14979
  *
14922
14980
  * `POST /payment-link/{merchantId}/{paymentId}/browser-card-claim`
14923
14981
  */
@@ -14943,7 +15001,8 @@ var CheckoutSession = class {
14943
15001
  * against the shop's sell-to restrictions before Stripe authorises, and a
14944
15002
  * refusal throws a `DelopayError` with code `DE_10`. A buyer on the
14945
15003
  * merchant's buyer blocklist is refused before any Stripe call with code
14946
- * `DE_14` (`buyer_blocked`, 422), which names no entry. When the answer's
15004
+ * `DE_14` (`buyer_blocked`, 422), which names no entry, and a shop whose
15005
+ * payments DeloPay stopped with `DE_22`. When the answer's
14947
15006
  * `status` is `requires_action`, run `stripe.handleNextAction` with its
14948
15007
  * `client_secret` — safe, because the intent is `confirmation_method=manual`
14949
15008
  * and that secret confirms nothing without the secret key — then call this
@@ -15174,7 +15233,7 @@ var CheckoutSession = class {
15174
15233
  /**
15175
15234
  * Reopen a provider session the buyer switched away from, when they pick the
15176
15235
  * same method again, instead of opening a second session at the provider
15177
- * (delopay-todos#401). Pass an `attempt_id` from the checkout's
15236
+ *. Pass an `attempt_id` from the checkout's
15178
15237
  * `reopenable_attempts`; the attempt becomes the payment's active one again
15179
15238
  * and `redirect_url` sends the buyer back to it. Refused (`IR_16`) when the
15180
15239
  * payment no longer awaits a method, a payment is under way on the checkout,
@@ -16090,4 +16149,4 @@ export {
16090
16149
  decodeNativePanes,
16091
16150
  encodeNativePanes
16092
16151
  };
16093
- //# sourceMappingURL=chunk-GHDAF4L4.js.map
16152
+ //# sourceMappingURL=chunk-EPN4ZOGA.js.map