@delopay/sdk 0.332.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) {
@@ -6437,6 +6437,77 @@ var SellToRestrictions = class {
6437
6437
  options
6438
6438
  );
6439
6439
  }
6440
+ /**
6441
+ * One project's own policy, if it has one.
6442
+ * `GET /sell-to-restrictions/projects/{project_id}`
6443
+ */
6444
+ async retrieveProject(projectId) {
6445
+ return this.request("GET", `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`);
6446
+ }
6447
+ /**
6448
+ * Give one project its own policy. It replaces the merchant-wide policy for
6449
+ * every shop of the project's subtree without an override or a nearer
6450
+ * project policy, from their next payment on. An empty `blocked_countries`
6451
+ * lifts every restriction for them. Recorded in the audit log first.
6452
+ * `PUT /sell-to-restrictions/projects/{project_id}`
6453
+ */
6454
+ async updateProjectPolicy(projectId, params, options) {
6455
+ return this.request("PUT", `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`, {
6456
+ body: params,
6457
+ ...options
6458
+ });
6459
+ }
6460
+ /**
6461
+ * Remove one project's policy, so its subtree inherits from above again.
6462
+ * Removing a policy the project does not have changes nothing.
6463
+ * `DELETE /sell-to-restrictions/projects/{project_id}`
6464
+ */
6465
+ async deleteProjectPolicy(projectId, options) {
6466
+ return this.request(
6467
+ "DELETE",
6468
+ `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`,
6469
+ options
6470
+ );
6471
+ }
6472
+ /**
6473
+ * One payment connector account's own policy, and which buyer
6474
+ * signals its payments can be judged on. Needs the merchant-level `Read`
6475
+ * rung; a shop-scoped role is refused.
6476
+ * `GET /sell-to-restrictions/connectors/{merchant_connector_id}`
6477
+ */
6478
+ async retrieveConnectorPolicy(merchantConnectorId) {
6479
+ return this.request(
6480
+ "GET",
6481
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`
6482
+ );
6483
+ }
6484
+ /**
6485
+ * Give one payment connector account its own policy. It applies on top of
6486
+ * each shop's policy, in every shop the account serves, from the next
6487
+ * payment on: a buyer it refuses is routed to another account of the shop.
6488
+ * Needs the merchant-wide `Write` rung and write visibility for the
6489
+ * processor; recorded in the audit log first.
6490
+ * `PUT /sell-to-restrictions/connectors/{merchant_connector_id}`
6491
+ */
6492
+ async updateConnectorPolicy(merchantConnectorId, params, options) {
6493
+ return this.request(
6494
+ "PUT",
6495
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`,
6496
+ { body: params, ...options }
6497
+ );
6498
+ }
6499
+ /**
6500
+ * Remove one connector account's own policy; each shop's policy still
6501
+ * applies. Removing a policy the account does not have changes nothing.
6502
+ * `DELETE /sell-to-restrictions/connectors/{merchant_connector_id}`
6503
+ */
6504
+ async deleteConnectorPolicy(merchantConnectorId, options) {
6505
+ return this.request(
6506
+ "DELETE",
6507
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`,
6508
+ options
6509
+ );
6510
+ }
6440
6511
  /**
6441
6512
  * Which checks each payment path performs, and how this deployment resolves
6442
6513
  * a buyer's country — read before relying on a restriction for a path.
@@ -10507,6 +10578,9 @@ var Delopay = class {
10507
10578
  this.maxRetries = options?.maxRetries ?? 2;
10508
10579
  this.debug = options?.debug ?? false;
10509
10580
  if (options?.logger !== void 0) this.logger = options.logger;
10581
+ if (options?.profileId !== void 0 && options.profileId !== "") {
10582
+ this.profileId = options.profileId;
10583
+ }
10510
10584
  if (options?.baseUrl !== void 0) {
10511
10585
  this.baseUrl = options.baseUrl;
10512
10586
  } else if (options?.sandbox) {
@@ -10655,6 +10729,17 @@ var Delopay = class {
10655
10729
  return url;
10656
10730
  }
10657
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
+ }
10658
10743
  authHeaders() {
10659
10744
  if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };
10660
10745
  if (this.apiKey) return { "api-key": this.apiKey };
@@ -10698,6 +10783,7 @@ var Delopay = class {
10698
10783
  const lastEventId = options.lastEventId ?? "";
10699
10784
  const headers = {
10700
10785
  ...this.authHeaders(),
10786
+ ...this.profileHeaders(options.headers),
10701
10787
  Accept: "text/event-stream",
10702
10788
  ...lastEventId ? { "Last-Event-ID": lastEventId } : {},
10703
10789
  ...options.headers
@@ -10835,6 +10921,7 @@ var Delopay = class {
10835
10921
  const url = this.buildUrl(path, options?.query);
10836
10922
  let headers = {
10837
10923
  ...this.authHeaders(),
10924
+ ...this.profileHeaders(options?.headers),
10838
10925
  ...options?.headers
10839
10926
  };
10840
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);
@@ -13424,7 +13511,7 @@ function decodeBranding(source) {
13424
13511
  DEFAULT_BRANDING.whopSelection
13425
13512
  ),
13426
13513
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
13427
- // 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
13428
13515
  // the PayPal values it was drawn with until then.
13429
13516
  epayoutsCardLayout: pickEnum(
13430
13517
  extras["epayoutsCardLayout"],
@@ -14113,7 +14200,7 @@ function parseImportedBranding(raw) {
14113
14200
  dflt.whopSelection
14114
14201
  ),
14115
14202
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
14116
- // 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
14117
14204
  // the PayPal values it was drawn with until then.
14118
14205
  epayoutsCardLayout: pickEnum(
14119
14206
  root["epayoutsCardLayout"],
@@ -14573,6 +14660,47 @@ var CheckoutSession = class {
14573
14660
  }
14574
14661
  );
14575
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
+ }
14576
14704
  /**
14577
14705
  * Confirm a subscription (PayPal approval rail). The client secret is
14578
14706
  * attached automatically; the shop's profile id travels as the
@@ -14846,7 +14974,8 @@ var CheckoutSession = class {
14846
14974
  * Only `authorized: true` permits the form to contact its processor. A
14847
14975
  * competing flow receives `false` and must reload; an unresolved provider
14848
14976
  * outcome stays reserved, regardless of elapsed time. A buyer-blocklist
14849
- * 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`.
14850
14979
  *
14851
14980
  * `POST /payment-link/{merchantId}/{paymentId}/browser-card-claim`
14852
14981
  */
@@ -14872,7 +15001,8 @@ var CheckoutSession = class {
14872
15001
  * against the shop's sell-to restrictions before Stripe authorises, and a
14873
15002
  * refusal throws a `DelopayError` with code `DE_10`. A buyer on the
14874
15003
  * merchant's buyer blocklist is refused before any Stripe call with code
14875
- * `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
14876
15006
  * `status` is `requires_action`, run `stripe.handleNextAction` with its
14877
15007
  * `client_secret` — safe, because the intent is `confirmation_method=manual`
14878
15008
  * and that secret confirms nothing without the secret key — then call this
@@ -15103,7 +15233,7 @@ var CheckoutSession = class {
15103
15233
  /**
15104
15234
  * Reopen a provider session the buyer switched away from, when they pick the
15105
15235
  * same method again, instead of opening a second session at the provider
15106
- * (delopay-todos#401). Pass an `attempt_id` from the checkout's
15236
+ *. Pass an `attempt_id` from the checkout's
15107
15237
  * `reopenable_attempts`; the attempt becomes the payment's active one again
15108
15238
  * and `redirect_url` sends the buyer back to it. Refused (`IR_16`) when the
15109
15239
  * payment no longer awaits a method, a payment is under way on the checkout,
@@ -16019,4 +16149,4 @@ export {
16019
16149
  decodeNativePanes,
16020
16150
  encodeNativePanes
16021
16151
  };
16022
- //# sourceMappingURL=chunk-FAUZMLOT.js.map
16152
+ //# sourceMappingURL=chunk-EPN4ZOGA.js.map