@delopay/sdk 0.230.0 → 0.232.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
@@ -248,6 +248,7 @@ __export(index_exports, {
248
248
  surfacePadValue: () => surfacePadValue,
249
249
  validSectionOrder: () => validSectionOrder,
250
250
  validatePanes: () => validatePanes,
251
+ vaultFormAppearance: () => vaultFormAppearance,
251
252
  verticalGapValue: () => verticalGapValue,
252
253
  visibleCustomFields: () => visibleCustomFields,
253
254
  whopAccentSwatch: () => whopAccentSwatch,
@@ -2100,6 +2101,20 @@ var PaymentLinks = class {
2100
2101
  async retrieve(linkId) {
2101
2102
  return this.request("GET", `/payment-link/${encodeURIComponent(linkId)}`);
2102
2103
  }
2104
+ /**
2105
+ * The merchant and payment an opaque checkout link opens.
2106
+ *
2107
+ * A link the API issues today is `/pay/{payment_link_id}`, so it names
2108
+ * neither the merchant nor the payment. This answers which ones it means.
2109
+ * Unauthenticated, like the checkout render it precedes: no credential is
2110
+ * needed or sent beyond what the client already carries. An unknown id is a
2111
+ * 404.
2112
+ *
2113
+ * `GET /payment-link/resolve/{payment_link_id}`
2114
+ */
2115
+ async resolve(paymentLinkId) {
2116
+ return this.request("GET", `/payment-link/resolve/${encodeURIComponent(paymentLinkId)}`);
2117
+ }
2103
2118
  /**
2104
2119
  * List payment links, optionally filtered by status or date range.
2105
2120
  *
@@ -9184,6 +9199,19 @@ function inputPadValue(size) {
9184
9199
  function buttonPadValue(size) {
9185
9200
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
9186
9201
  }
9202
+ function vaultFormAppearance(b, danger) {
9203
+ return {
9204
+ surface: b.surface,
9205
+ text: b.text,
9206
+ border: b.border,
9207
+ accent: b.primary,
9208
+ ...danger ? { danger } : {},
9209
+ font: b.fontFamily,
9210
+ radius: b.radiusInput,
9211
+ size: b.inputSize,
9212
+ labels: b.labelStyle
9213
+ };
9214
+ }
9187
9215
  function logoDimensions(size) {
9188
9216
  switch (size) {
9189
9217
  case "sm":
@@ -11810,11 +11838,29 @@ var CheckoutSession = class {
11810
11838
  * reports the vault as enabled and still expects its cards cloaked. The same
11811
11839
  * status also covers a payment that does not exist.
11812
11840
  *
11841
+ * `params.appearance` asks for a form styled to match the page (Enigma
11842
+ * Vault). The answer then carries `height`, the frame height to use. If the
11843
+ * vault refuses the styled form the answer is the plain one, without
11844
+ * `height`. `params.locale` is the buyer's locale.
11845
+ *
11813
11846
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11814
11847
  */
11815
- async vaultCollectSession(options) {
11848
+ async vaultCollectSession(options, params) {
11849
+ const look = params?.appearance;
11816
11850
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11817
11851
  ...options,
11852
+ query: {
11853
+ locale: params?.locale,
11854
+ form_surface: look?.surface,
11855
+ form_text: look?.text,
11856
+ form_border: look?.border,
11857
+ form_accent: look?.accent,
11858
+ form_danger: look?.danger,
11859
+ form_font: look?.font,
11860
+ form_radius: look?.radius,
11861
+ form_size: look?.size,
11862
+ form_labels: look?.labels
11863
+ },
11818
11864
  headers: this.bearerHeaders(options?.headers)
11819
11865
  });
11820
11866
  }
@@ -12403,9 +12449,10 @@ function encodePanes(panes) {
12403
12449
  };
12404
12450
  });
12405
12451
  }
12452
+ var OPAQUE_PAYMENT_LINK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
12406
12453
  function focusedCheckoutUrl(params) {
12407
12454
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
12408
- const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12455
+ const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12409
12456
  params.paymentId
12410
12457
  )}`;
12411
12458
  const query = new URLSearchParams({ pane: params.method });
@@ -12673,6 +12720,7 @@ var encodeNativePanes = encodePanes;
12673
12720
  surfacePadValue,
12674
12721
  validSectionOrder,
12675
12722
  validatePanes,
12723
+ vaultFormAppearance,
12676
12724
  verticalGapValue,
12677
12725
  visibleCustomFields,
12678
12726
  whopAccentSwatch,