@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/dist/index.cjs CHANGED
@@ -1021,7 +1021,7 @@ var Connectors = class {
1021
1021
  );
1022
1022
  }
1023
1023
  /**
1024
- * Share a connector with more shops of the same merchant (todos#320).
1024
+ * Share a connector with more shops of the same merchant.
1025
1025
  * `POST /account/{accountId}/connectors/{connectorId}/shops`
1026
1026
  *
1027
1027
  * Nothing is copied: every shop sends payments to the same account, on the
@@ -1035,7 +1035,7 @@ var Connectors = class {
1035
1035
  );
1036
1036
  }
1037
1037
  /**
1038
- * Fold copies of the same provider account into this connector (todos#395).
1038
+ * Fold copies of the same provider account into this connector.
1039
1039
  * `POST /account/{accountId}/connectors/{connectorId}/consolidate`
1040
1040
  *
1041
1041
  * The copies' shops move to the connector with their on/off state, routing,
@@ -1063,7 +1063,7 @@ var Connectors = class {
1063
1063
  );
1064
1064
  }
1065
1065
  /**
1066
- * Stop a connector serving one shop (todos#407). Any shop may leave, the
1066
+ * Stop a connector serving one shop. Any shop may leave, the
1067
1067
  * one the connector was created in included, while another one stays: the
1068
1068
  * last shop is refused, and the connector is deleted instead. The account,
1069
1069
  * its limits and every other shop on it are unaffected.
@@ -1078,7 +1078,7 @@ var Connectors = class {
1078
1078
  /**
1079
1079
  * Read the transaction currencies a connector may process: its own list,
1080
1080
  * what the provider is known to accept with its methods, and the effective
1081
- * currencies in each shop it serves (todos#333).
1081
+ * currencies in each shop it serves.
1082
1082
  * `GET /account/{accountId}/connectors/{connectorId}/currencies`
1083
1083
  */
1084
1084
  async getCurrencies(accountId, connectorId) {
@@ -6725,6 +6725,77 @@ var SellToRestrictions = class {
6725
6725
  options
6726
6726
  );
6727
6727
  }
6728
+ /**
6729
+ * One project's own policy, if it has one.
6730
+ * `GET /sell-to-restrictions/projects/{project_id}`
6731
+ */
6732
+ async retrieveProject(projectId) {
6733
+ return this.request("GET", `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`);
6734
+ }
6735
+ /**
6736
+ * Give one project its own policy. It replaces the merchant-wide policy for
6737
+ * every shop of the project's subtree without an override or a nearer
6738
+ * project policy, from their next payment on. An empty `blocked_countries`
6739
+ * lifts every restriction for them. Recorded in the audit log first.
6740
+ * `PUT /sell-to-restrictions/projects/{project_id}`
6741
+ */
6742
+ async updateProjectPolicy(projectId, params, options) {
6743
+ return this.request("PUT", `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`, {
6744
+ body: params,
6745
+ ...options
6746
+ });
6747
+ }
6748
+ /**
6749
+ * Remove one project's policy, so its subtree inherits from above again.
6750
+ * Removing a policy the project does not have changes nothing.
6751
+ * `DELETE /sell-to-restrictions/projects/{project_id}`
6752
+ */
6753
+ async deleteProjectPolicy(projectId, options) {
6754
+ return this.request(
6755
+ "DELETE",
6756
+ `/sell-to-restrictions/projects/${encodeURIComponent(projectId)}`,
6757
+ options
6758
+ );
6759
+ }
6760
+ /**
6761
+ * One payment connector account's own policy, and which buyer
6762
+ * signals its payments can be judged on. Needs the merchant-level `Read`
6763
+ * rung; a shop-scoped role is refused.
6764
+ * `GET /sell-to-restrictions/connectors/{merchant_connector_id}`
6765
+ */
6766
+ async retrieveConnectorPolicy(merchantConnectorId) {
6767
+ return this.request(
6768
+ "GET",
6769
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`
6770
+ );
6771
+ }
6772
+ /**
6773
+ * Give one payment connector account its own policy. It applies on top of
6774
+ * each shop's policy, in every shop the account serves, from the next
6775
+ * payment on: a buyer it refuses is routed to another account of the shop.
6776
+ * Needs the merchant-wide `Write` rung and write visibility for the
6777
+ * processor; recorded in the audit log first.
6778
+ * `PUT /sell-to-restrictions/connectors/{merchant_connector_id}`
6779
+ */
6780
+ async updateConnectorPolicy(merchantConnectorId, params, options) {
6781
+ return this.request(
6782
+ "PUT",
6783
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`,
6784
+ { body: params, ...options }
6785
+ );
6786
+ }
6787
+ /**
6788
+ * Remove one connector account's own policy; each shop's policy still
6789
+ * applies. Removing a policy the account does not have changes nothing.
6790
+ * `DELETE /sell-to-restrictions/connectors/{merchant_connector_id}`
6791
+ */
6792
+ async deleteConnectorPolicy(merchantConnectorId, options) {
6793
+ return this.request(
6794
+ "DELETE",
6795
+ `/sell-to-restrictions/connectors/${encodeURIComponent(merchantConnectorId)}`,
6796
+ options
6797
+ );
6798
+ }
6728
6799
  /**
6729
6800
  * Which checks each payment path performs, and how this deployment resolves
6730
6801
  * a buyer's country — read before relying on a restriction for a path.
@@ -10795,6 +10866,9 @@ var Delopay = class {
10795
10866
  this.maxRetries = options?.maxRetries ?? 2;
10796
10867
  this.debug = options?.debug ?? false;
10797
10868
  if (options?.logger !== void 0) this.logger = options.logger;
10869
+ if (options?.profileId !== void 0 && options.profileId !== "") {
10870
+ this.profileId = options.profileId;
10871
+ }
10798
10872
  if (options?.baseUrl !== void 0) {
10799
10873
  this.baseUrl = options.baseUrl;
10800
10874
  } else if (options?.sandbox) {
@@ -10943,6 +11017,17 @@ var Delopay = class {
10943
11017
  return url;
10944
11018
  }
10945
11019
  /** The credential header: the JWT when one is set, else the API key. */
11020
+ /**
11021
+ * The client's `X-Profile-Id`, unless the call names one itself (in any
11022
+ * letter case: two spellings would be sent as one joined value).
11023
+ */
11024
+ profileHeaders(callHeaders) {
11025
+ if (this.profileId === void 0) return {};
11026
+ const named = Object.keys(callHeaders ?? {}).some(
11027
+ (name) => name.toLowerCase() === "x-profile-id"
11028
+ );
11029
+ return named ? {} : { "X-Profile-Id": this.profileId };
11030
+ }
10946
11031
  authHeaders() {
10947
11032
  if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };
10948
11033
  if (this.apiKey) return { "api-key": this.apiKey };
@@ -10986,6 +11071,7 @@ var Delopay = class {
10986
11071
  const lastEventId = options.lastEventId ?? "";
10987
11072
  const headers = {
10988
11073
  ...this.authHeaders(),
11074
+ ...this.profileHeaders(options.headers),
10989
11075
  Accept: "text/event-stream",
10990
11076
  ...lastEventId ? { "Last-Event-ID": lastEventId } : {},
10991
11077
  ...options.headers
@@ -11123,6 +11209,7 @@ var Delopay = class {
11123
11209
  const url = this.buildUrl(path, options?.query);
11124
11210
  let headers = {
11125
11211
  ...this.authHeaders(),
11212
+ ...this.profileHeaders(options?.headers),
11126
11213
  ...options?.headers
11127
11214
  };
11128
11215
  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);
@@ -13712,7 +13799,7 @@ function decodeBranding(source) {
13712
13799
  DEFAULT_BRANDING.whopSelection
13713
13800
  ),
13714
13801
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
13715
- // A look stored before todos#412 has no e-Payouts keys: the form keeps
13802
+ // A look stored before e-Payouts had its own keys has none: the form keeps
13716
13803
  // the PayPal values it was drawn with until then.
13717
13804
  epayoutsCardLayout: pickEnum(
13718
13805
  extras["epayoutsCardLayout"],
@@ -14401,7 +14488,7 @@ function parseImportedBranding(raw) {
14401
14488
  dflt.whopSelection
14402
14489
  ),
14403
14490
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
14404
- // A look stored before todos#412 has no e-Payouts keys: the form keeps
14491
+ // A look stored before e-Payouts had its own keys has none: the form keeps
14405
14492
  // the PayPal values it was drawn with until then.
14406
14493
  epayoutsCardLayout: pickEnum(
14407
14494
  root["epayoutsCardLayout"],
@@ -14861,6 +14948,47 @@ var CheckoutSession = class {
14861
14948
  }
14862
14949
  );
14863
14950
  }
14951
+ /**
14952
+ * The methods the buyer may pick for a subscription that waits for the
14953
+ * choice (`method_choice_pending`), judged for the buyer. Call it from the
14954
+ * buyer's browser: the sell-to country is read from this request's own
14955
+ * connection. Authenticated with the subscription's client secret.
14956
+ *
14957
+ * `GET /subscriptions/method-options/{merchantId}/{subscriptionId}`
14958
+ */
14959
+ async subscriptionMethodOptions(options) {
14960
+ return this.client.request(
14961
+ "GET",
14962
+ `/subscriptions/method-options/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
14963
+ {
14964
+ ...options,
14965
+ headers: this.bearerHeaders(options?.headers)
14966
+ }
14967
+ );
14968
+ }
14969
+ /**
14970
+ * Bind a waiting subscription to the method the buyer picked and open its
14971
+ * first cycle on that method's billing account. The methods are judged
14972
+ * again from this request; afterwards
14973
+ * {@link CheckoutSession.fetchSubscriptionData} describes the bound
14974
+ * subscription (Stripe's Payment Element for `card`, `confirmSubscription`
14975
+ * for the others). A subscription that no longer waits answers 409
14976
+ * (`DE_20`). Authenticated with the subscription's client secret.
14977
+ *
14978
+ * `POST /subscriptions/select-method/{merchantId}/{subscriptionId}`
14979
+ */
14980
+ async selectSubscriptionMethod(method, options) {
14981
+ const body = { method };
14982
+ return this.client.request(
14983
+ "POST",
14984
+ `/subscriptions/select-method/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
14985
+ {
14986
+ body,
14987
+ ...options,
14988
+ headers: this.bearerHeaders(options?.headers)
14989
+ }
14990
+ );
14991
+ }
14864
14992
  /**
14865
14993
  * Confirm a subscription (PayPal approval rail). The client secret is
14866
14994
  * attached automatically; the shop's profile id travels as the
@@ -15134,7 +15262,8 @@ var CheckoutSession = class {
15134
15262
  * Only `authorized: true` permits the form to contact its processor. A
15135
15263
  * competing flow receives `false` and must reload; an unresolved provider
15136
15264
  * outcome stays reserved, regardless of elapsed time. A buyer-blocklist
15137
- * refusal throws a `DelopayError` with code `DE_14`.
15265
+ * refusal throws a `DelopayError` with code `DE_14`; a shop whose payments
15266
+ * DeloPay stopped is refused with `DE_22`.
15138
15267
  *
15139
15268
  * `POST /payment-link/{merchantId}/{paymentId}/browser-card-claim`
15140
15269
  */
@@ -15160,7 +15289,8 @@ var CheckoutSession = class {
15160
15289
  * against the shop's sell-to restrictions before Stripe authorises, and a
15161
15290
  * refusal throws a `DelopayError` with code `DE_10`. A buyer on the
15162
15291
  * merchant's buyer blocklist is refused before any Stripe call with code
15163
- * `DE_14` (`buyer_blocked`, 422), which names no entry. When the answer's
15292
+ * `DE_14` (`buyer_blocked`, 422), which names no entry, and a shop whose
15293
+ * payments DeloPay stopped with `DE_22`. When the answer's
15164
15294
  * `status` is `requires_action`, run `stripe.handleNextAction` with its
15165
15295
  * `client_secret` — safe, because the intent is `confirmation_method=manual`
15166
15296
  * and that secret confirms nothing without the secret key — then call this
@@ -15391,7 +15521,7 @@ var CheckoutSession = class {
15391
15521
  /**
15392
15522
  * Reopen a provider session the buyer switched away from, when they pick the
15393
15523
  * same method again, instead of opening a second session at the provider
15394
- * (delopay-todos#401). Pass an `attempt_id` from the checkout's
15524
+ *. Pass an `attempt_id` from the checkout's
15395
15525
  * `reopenable_attempts`; the attempt becomes the payment's active one again
15396
15526
  * and `redirect_url` sends the buyer back to it. Refused (`IR_16`) when the
15397
15527
  * payment no longer awaits a method, a payment is under way on the checkout,