@delopay/sdk 0.121.0 → 0.123.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
@@ -61,6 +61,7 @@ __export(index_exports, {
61
61
  PANES_MAX: () => PANES_MAX,
62
62
  PANE_CATEGORY_KEYS: () => PANE_CATEGORY_KEYS,
63
63
  PANE_ICON_KEYS: () => PANE_ICON_KEYS,
64
+ RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
64
65
  Regions: () => Regions,
65
66
  Risk: () => Risk,
66
67
  STRIPE_FALLBACK_PANE_CATALOG: () => STRIPE_FALLBACK_PANE_CATALOG,
@@ -88,6 +89,7 @@ __export(index_exports, {
88
89
  buildBrandingExport: () => buildBrandingExport,
89
90
  buttonPadValue: () => buttonPadValue,
90
91
  checkoutCopy: () => checkoutCopy,
92
+ checkoutLocaleDir: () => checkoutLocaleDir,
91
93
  cloneBranding: () => cloneBranding,
92
94
  cloneCustomField: () => cloneCustomField,
93
95
  cloneNativePane: () => cloneNativePane,
@@ -5369,7 +5371,26 @@ var SURCHARGE_FIGURE_MODES = [
5369
5371
  "amountThenPercent",
5370
5372
  "percentThenAmount"
5371
5373
  ];
5372
- var CHECKOUT_LOCALES = ["en", "de"];
5374
+ var CHECKOUT_LOCALES = [
5375
+ "en",
5376
+ "de",
5377
+ "fr",
5378
+ "es",
5379
+ "it",
5380
+ "nl",
5381
+ // Simplified and traditional are separate dictionaries in the checkout,
5382
+ // not region variants: they use different characters, so a merchant who
5383
+ // writes one has not written the other.
5384
+ "zh",
5385
+ "zh-Hant",
5386
+ "hi",
5387
+ "ar"
5388
+ ];
5389
+ var RTL_CHECKOUT_LOCALES = ["ar"];
5390
+ function checkoutLocaleDir(locale) {
5391
+ const base = String(locale ?? "").toLowerCase().split("-")[0];
5392
+ return RTL_CHECKOUT_LOCALES.includes(base) ? "rtl" : "ltr";
5393
+ }
5373
5394
  var LOCALIZABLE_COPY_FIELDS = [
5374
5395
  "headerText",
5375
5396
  "payButtonLabel",
@@ -6093,14 +6114,18 @@ function visibleCustomFields(fields, ctx) {
6093
6114
  }
6094
6115
  function translationFor(map, locale) {
6095
6116
  if (!locale) return null;
6096
- const own = (k) => {
6097
- const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : void 0;
6098
- return typeof v === "string" && v.length > 0 ? v : null;
6099
- };
6100
- const exact = own(locale);
6101
- if (exact) return exact;
6102
- const base = locale.split("-")[0];
6103
- return base && base !== locale ? own(base) : null;
6117
+ const folded = /* @__PURE__ */ new Map();
6118
+ for (const [k, v] of Object.entries(map)) {
6119
+ if (typeof v === "string" && v.length > 0 && !folded.has(k.toLowerCase())) {
6120
+ folded.set(k.toLowerCase(), v);
6121
+ }
6122
+ }
6123
+ const parts = locale.toLowerCase().split("-");
6124
+ for (let i = parts.length; i > 0; i -= 1) {
6125
+ const hit = folded.get(parts.slice(0, i).join("-"));
6126
+ if (hit) return hit;
6127
+ }
6128
+ return null;
6104
6129
  }
6105
6130
  function customFieldText(field, part, locale) {
6106
6131
  const map = part === "label" ? field.labelTranslations : part === "placeholder" ? field.placeholderTranslations : field.helpTextTranslations;
@@ -6942,6 +6967,28 @@ var CheckoutSession = class {
6942
6967
  headers: this.pkHeaders(options?.headers)
6943
6968
  });
6944
6969
  }
6970
+ /**
6971
+ * Abandon the attempt the buyer left open on a connector's hosted page
6972
+ * (the payment sits in `requires_customer_action`) and open a fresh attempt
6973
+ * awaiting a payment method, so the same payment can be confirmed again
6974
+ * with another method or connector. Nothing has been authorised on the
6975
+ * abandoned attempt; it is voided locally and kept in the attempt history.
6976
+ * Idempotent: a payment already in `requires_payment_method` comes back
6977
+ * unchanged with `abandoned_attempt_id: null`.
6978
+ *
6979
+ * `POST /payments/{paymentId}/abandon-attempt` (publishable key + client secret)
6980
+ */
6981
+ async abandonAttempt(options) {
6982
+ return this.client.request(
6983
+ "POST",
6984
+ `/payments/${encodeURIComponent(this.paymentId)}/abandon-attempt`,
6985
+ {
6986
+ body: { client_secret: this.requireClientSecret() },
6987
+ ...options,
6988
+ headers: this.pkHeaders(options?.headers)
6989
+ }
6990
+ );
6991
+ }
6945
6992
  /**
6946
6993
  * Payment methods available for this payment.
6947
6994
  *
@@ -7379,6 +7426,7 @@ var encodeNativePanes = encodePanes;
7379
7426
  PANES_MAX,
7380
7427
  PANE_CATEGORY_KEYS,
7381
7428
  PANE_ICON_KEYS,
7429
+ RTL_CHECKOUT_LOCALES,
7382
7430
  Regions,
7383
7431
  Risk,
7384
7432
  STRIPE_FALLBACK_PANE_CATALOG,
@@ -7406,6 +7454,7 @@ var encodeNativePanes = encodePanes;
7406
7454
  buildBrandingExport,
7407
7455
  buttonPadValue,
7408
7456
  checkoutCopy,
7457
+ checkoutLocaleDir,
7409
7458
  cloneBranding,
7410
7459
  cloneCustomField,
7411
7460
  cloneNativePane,