@delopay/sdk 0.229.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.
@@ -1843,6 +1843,20 @@ var PaymentLinks = class {
1843
1843
  async retrieve(linkId) {
1844
1844
  return this.request("GET", `/payment-link/${encodeURIComponent(linkId)}`);
1845
1845
  }
1846
+ /**
1847
+ * The merchant and payment an opaque checkout link opens.
1848
+ *
1849
+ * A link the API issues today is `/pay/{payment_link_id}`, so it names
1850
+ * neither the merchant nor the payment. This answers which ones it means.
1851
+ * Unauthenticated, like the checkout render it precedes: no credential is
1852
+ * needed or sent beyond what the client already carries. An unknown id is a
1853
+ * 404.
1854
+ *
1855
+ * `GET /payment-link/resolve/{payment_link_id}`
1856
+ */
1857
+ async resolve(paymentLinkId) {
1858
+ return this.request("GET", `/payment-link/resolve/${encodeURIComponent(paymentLinkId)}`);
1859
+ }
1846
1860
  /**
1847
1861
  * List payment links, optionally filtered by status or date range.
1848
1862
  *
@@ -8526,6 +8540,133 @@ var GOOGLE_PAY_BUTTON_TYPES = [
8526
8540
  "subscribe",
8527
8541
  "donate"
8528
8542
  ];
8543
+ var WHOP_CARD_PRESETS = ["accordion", "tiles", "card_stacked", "card_compact"];
8544
+ function whopCardElement(preset) {
8545
+ switch (preset) {
8546
+ case "tiles":
8547
+ return { element: "payment", layout: "horizontal" };
8548
+ case "card_stacked":
8549
+ return { element: "card", layout: "stacked" };
8550
+ case "card_compact":
8551
+ return { element: "card", layout: "compact" };
8552
+ default:
8553
+ return { element: "payment", layout: "accordion" };
8554
+ }
8555
+ }
8556
+ var WHOP_ACCENT_COLORS = [
8557
+ "auto",
8558
+ "gray",
8559
+ "blue",
8560
+ "indigo",
8561
+ "iris",
8562
+ "violet",
8563
+ "purple",
8564
+ "plum",
8565
+ "pink",
8566
+ "crimson",
8567
+ "ruby",
8568
+ "red",
8569
+ "tomato",
8570
+ "orange",
8571
+ "amber",
8572
+ "yellow",
8573
+ "lime",
8574
+ "grass",
8575
+ "green",
8576
+ "jade",
8577
+ "teal",
8578
+ "cyan",
8579
+ "sky",
8580
+ "mint",
8581
+ "brown",
8582
+ "bronze",
8583
+ "gold"
8584
+ ];
8585
+ var WHOP_ACCENT_SWATCHES = {
8586
+ blue: "#0090ff",
8587
+ indigo: "#3e63dd",
8588
+ iris: "#5b5bd6",
8589
+ violet: "#6e56cf",
8590
+ purple: "#8e4ec6",
8591
+ plum: "#ab4aba",
8592
+ pink: "#d6409f",
8593
+ crimson: "#e93d82",
8594
+ ruby: "#e54666",
8595
+ red: "#e5484d",
8596
+ tomato: "#e54d2e",
8597
+ orange: "#f76b15",
8598
+ amber: "#ffc53d",
8599
+ yellow: "#ffe629",
8600
+ lime: "#bdee63",
8601
+ grass: "#46a758",
8602
+ green: "#30a46c",
8603
+ jade: "#29a383",
8604
+ teal: "#12a594",
8605
+ cyan: "#00a2c7",
8606
+ sky: "#7ce2fe",
8607
+ mint: "#86ead4",
8608
+ brown: "#ad7f58",
8609
+ bronze: "#a18072",
8610
+ gold: "#978365"
8611
+ };
8612
+ function whopAccentSwatch(accent) {
8613
+ return accent === "gray" ? "#8d8d8d" : WHOP_ACCENT_SWATCHES[accent];
8614
+ }
8615
+ function hexRgb(hex) {
8616
+ const raw = hex.trim().replace(/^#/, "");
8617
+ const full = raw.length === 3 ? raw.replace(/./g, (c) => c + c) : raw;
8618
+ if (!/^[0-9a-f]{6}$/i.test(full)) return null;
8619
+ const n = Number.parseInt(full, 16);
8620
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
8621
+ }
8622
+ function oklab([r, g, b]) {
8623
+ const lin = (c) => {
8624
+ const v = c / 255;
8625
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
8626
+ };
8627
+ const [lr, lg, lb] = [lin(r), lin(g), lin(b)];
8628
+ const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
8629
+ const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
8630
+ const s2 = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
8631
+ return [
8632
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s2,
8633
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s2,
8634
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s2
8635
+ ];
8636
+ }
8637
+ function nearestWhopAccent(hex) {
8638
+ const rgb = hexRgb(hex);
8639
+ if (!rgb) return "blue";
8640
+ const [L, a, b] = oklab(rgb);
8641
+ if (Math.hypot(a, b) < 0.04) return "gray";
8642
+ let best = "blue";
8643
+ let bestDistance = Number.POSITIVE_INFINITY;
8644
+ for (const [name, swatch] of Object.entries(WHOP_ACCENT_SWATCHES)) {
8645
+ const swatchRgb = hexRgb(swatch);
8646
+ if (!swatchRgb) continue;
8647
+ const [sL, sa, sb] = oklab(swatchRgb);
8648
+ const distance = Math.hypot((L - sL) * 0.5, a - sa, b - sb);
8649
+ if (distance < bestDistance) {
8650
+ bestDistance = distance;
8651
+ best = name;
8652
+ }
8653
+ }
8654
+ return best;
8655
+ }
8656
+ function resolveWhopAccent(accent, primaryHex) {
8657
+ return accent === "auto" ? nearestWhopAccent(primaryHex) : accent;
8658
+ }
8659
+ var WHOP_EMAIL_LABELS = ["above", "floating"];
8660
+ var WHOP_GRAY_COLORS = [
8661
+ "auto",
8662
+ "gray",
8663
+ "mauve",
8664
+ "slate",
8665
+ "sage",
8666
+ "olive",
8667
+ "sand"
8668
+ ];
8669
+ var WHOP_BILLING_DETAILS = ["minimal", "full"];
8529
8670
 
8530
8671
  // src/branding.ts
8531
8672
  function surchargeShowsLabel(labelMode, style, position) {
@@ -8800,6 +8941,19 @@ function inputPadValue(size) {
8800
8941
  function buttonPadValue(size) {
8801
8942
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
8802
8943
  }
8944
+ function vaultFormAppearance(b, danger) {
8945
+ return {
8946
+ surface: b.surface,
8947
+ text: b.text,
8948
+ border: b.border,
8949
+ accent: b.primary,
8950
+ ...danger ? { danger } : {},
8951
+ font: b.fontFamily,
8952
+ radius: b.radiusInput,
8953
+ size: b.inputSize,
8954
+ labels: b.labelStyle
8955
+ };
8956
+ }
8803
8957
  function logoDimensions(size) {
8804
8958
  switch (size) {
8805
8959
  case "sm":
@@ -9279,6 +9433,16 @@ var DEFAULT_BRANDING_BASE = {
9279
9433
  micropaymentFieldFontSize: "md",
9280
9434
  micropaymentFieldWeight: "regular",
9281
9435
  micropaymentFocusRing: "strong",
9436
+ whopCardPreset: "accordion",
9437
+ whopAccentColor: "auto",
9438
+ whopGrayColor: "auto",
9439
+ whopBillingDetails: "minimal",
9440
+ whopSeparated: false,
9441
+ whopEmailLabel: "above",
9442
+ whopFieldChrome: "outlined",
9443
+ whopFieldFontSize: "md",
9444
+ whopFieldWeight: "regular",
9445
+ whopFocusRing: "strong",
9282
9446
  customCss: ""
9283
9447
  };
9284
9448
  var DEFAULT_BRANDING = {
@@ -10221,6 +10385,52 @@ function decodeBranding(source) {
10221
10385
  CARD_FOCUS_RINGS,
10222
10386
  DEFAULT_BRANDING.micropaymentFocusRing
10223
10387
  ),
10388
+ whopCardPreset: pickEnum(
10389
+ extras["whopCardPreset"],
10390
+ WHOP_CARD_PRESETS,
10391
+ DEFAULT_BRANDING.whopCardPreset
10392
+ ),
10393
+ whopAccentColor: pickEnum(
10394
+ extras["whopAccentColor"],
10395
+ WHOP_ACCENT_COLORS,
10396
+ DEFAULT_BRANDING.whopAccentColor
10397
+ ),
10398
+ whopGrayColor: pickEnum(
10399
+ extras["whopGrayColor"],
10400
+ WHOP_GRAY_COLORS,
10401
+ DEFAULT_BRANDING.whopGrayColor
10402
+ ),
10403
+ whopBillingDetails: pickEnum(
10404
+ extras["whopBillingDetails"],
10405
+ WHOP_BILLING_DETAILS,
10406
+ DEFAULT_BRANDING.whopBillingDetails
10407
+ ),
10408
+ whopSeparated: parseBool(extras["whopSeparated"], DEFAULT_BRANDING.whopSeparated),
10409
+ whopEmailLabel: pickEnum(
10410
+ extras["whopEmailLabel"],
10411
+ WHOP_EMAIL_LABELS,
10412
+ DEFAULT_BRANDING.whopEmailLabel
10413
+ ),
10414
+ whopFieldChrome: pickEnum(
10415
+ extras["whopFieldChrome"],
10416
+ CARD_FIELD_CHROMES,
10417
+ DEFAULT_BRANDING.whopFieldChrome
10418
+ ),
10419
+ whopFieldFontSize: pickEnum(
10420
+ extras["whopFieldFontSize"],
10421
+ CARD_FIELD_FONT_SIZES,
10422
+ DEFAULT_BRANDING.whopFieldFontSize
10423
+ ),
10424
+ whopFieldWeight: pickEnum(
10425
+ extras["whopFieldWeight"],
10426
+ CARD_FIELD_WEIGHTS,
10427
+ DEFAULT_BRANDING.whopFieldWeight
10428
+ ),
10429
+ whopFocusRing: pickEnum(
10430
+ extras["whopFocusRing"],
10431
+ CARD_FOCUS_RINGS,
10432
+ DEFAULT_BRANDING.whopFocusRing
10433
+ ),
10224
10434
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
10225
10435
  nomupayFormStyle: pickEnum(
10226
10436
  extras["nomupayFormStyle"],
@@ -10368,6 +10578,16 @@ function encodeBranding(branding, base) {
10368
10578
  micropaymentFieldFontSize: branding.micropaymentFieldFontSize,
10369
10579
  micropaymentFieldWeight: branding.micropaymentFieldWeight,
10370
10580
  micropaymentFocusRing: branding.micropaymentFocusRing,
10581
+ whopCardPreset: branding.whopCardPreset,
10582
+ whopAccentColor: branding.whopAccentColor,
10583
+ whopGrayColor: branding.whopGrayColor,
10584
+ whopBillingDetails: branding.whopBillingDetails,
10585
+ whopSeparated: String(branding.whopSeparated),
10586
+ whopEmailLabel: branding.whopEmailLabel,
10587
+ whopFieldChrome: branding.whopFieldChrome,
10588
+ whopFieldFontSize: branding.whopFieldFontSize,
10589
+ whopFieldWeight: branding.whopFieldWeight,
10590
+ whopFocusRing: branding.whopFocusRing,
10371
10591
  paypalValidTint: String(branding.paypalValidTint),
10372
10592
  nomupayFormStyle: branding.nomupayFormStyle,
10373
10593
  nomupayShowLabels: String(branding.nomupayShowLabels),
@@ -10775,6 +10995,52 @@ function parseImportedBranding(raw) {
10775
10995
  CARD_FOCUS_RINGS,
10776
10996
  dflt.micropaymentFocusRing
10777
10997
  ),
10998
+ whopCardPreset: pickEnum(
10999
+ root["whopCardPreset"],
11000
+ WHOP_CARD_PRESETS,
11001
+ dflt.whopCardPreset
11002
+ ),
11003
+ whopAccentColor: pickEnum(
11004
+ root["whopAccentColor"],
11005
+ WHOP_ACCENT_COLORS,
11006
+ dflt.whopAccentColor
11007
+ ),
11008
+ whopGrayColor: pickEnum(
11009
+ root["whopGrayColor"],
11010
+ WHOP_GRAY_COLORS,
11011
+ dflt.whopGrayColor
11012
+ ),
11013
+ whopBillingDetails: pickEnum(
11014
+ root["whopBillingDetails"],
11015
+ WHOP_BILLING_DETAILS,
11016
+ dflt.whopBillingDetails
11017
+ ),
11018
+ whopSeparated: parseBool(root["whopSeparated"], dflt.whopSeparated),
11019
+ whopEmailLabel: pickEnum(
11020
+ root["whopEmailLabel"],
11021
+ WHOP_EMAIL_LABELS,
11022
+ dflt.whopEmailLabel
11023
+ ),
11024
+ whopFieldChrome: pickEnum(
11025
+ root["whopFieldChrome"],
11026
+ CARD_FIELD_CHROMES,
11027
+ dflt.whopFieldChrome
11028
+ ),
11029
+ whopFieldFontSize: pickEnum(
11030
+ root["whopFieldFontSize"],
11031
+ CARD_FIELD_FONT_SIZES,
11032
+ dflt.whopFieldFontSize
11033
+ ),
11034
+ whopFieldWeight: pickEnum(
11035
+ root["whopFieldWeight"],
11036
+ CARD_FIELD_WEIGHTS,
11037
+ dflt.whopFieldWeight
11038
+ ),
11039
+ whopFocusRing: pickEnum(
11040
+ root["whopFocusRing"],
11041
+ CARD_FOCUS_RINGS,
11042
+ dflt.whopFocusRing
11043
+ ),
10778
11044
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
10779
11045
  nomupayFormStyle: pickEnum(
10780
11046
  root["nomupayFormStyle"],
@@ -11314,11 +11580,29 @@ var CheckoutSession = class {
11314
11580
  * reports the vault as enabled and still expects its cards cloaked. The same
11315
11581
  * status also covers a payment that does not exist.
11316
11582
  *
11583
+ * `params.appearance` asks for a form styled to match the page (Enigma
11584
+ * Vault). The answer then carries `height`, the frame height to use. If the
11585
+ * vault refuses the styled form the answer is the plain one, without
11586
+ * `height`. `params.locale` is the buyer's locale.
11587
+ *
11317
11588
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11318
11589
  */
11319
- async vaultCollectSession(options) {
11590
+ async vaultCollectSession(options, params) {
11591
+ const look = params?.appearance;
11320
11592
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11321
11593
  ...options,
11594
+ query: {
11595
+ locale: params?.locale,
11596
+ form_surface: look?.surface,
11597
+ form_text: look?.text,
11598
+ form_border: look?.border,
11599
+ form_accent: look?.accent,
11600
+ form_danger: look?.danger,
11601
+ form_font: look?.font,
11602
+ form_radius: look?.radius,
11603
+ form_size: look?.size,
11604
+ form_labels: look?.labels
11605
+ },
11322
11606
  headers: this.bearerHeaders(options?.headers)
11323
11607
  });
11324
11608
  }
@@ -11907,9 +12191,10 @@ function encodePanes(panes) {
11907
12191
  };
11908
12192
  });
11909
12193
  }
12194
+ 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}$/;
11910
12195
  function focusedCheckoutUrl(params) {
11911
12196
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
11912
- const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12197
+ const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
11913
12198
  params.paymentId
11914
12199
  )}`;
11915
12200
  const query = new URLSearchParams({ pane: params.method });
@@ -12031,6 +12316,15 @@ export {
12031
12316
  GOOGLE_PAY_BUTTON_COLORS,
12032
12317
  resolveGooglePayButtonColor,
12033
12318
  GOOGLE_PAY_BUTTON_TYPES,
12319
+ WHOP_CARD_PRESETS,
12320
+ whopCardElement,
12321
+ WHOP_ACCENT_COLORS,
12322
+ whopAccentSwatch,
12323
+ nearestWhopAccent,
12324
+ resolveWhopAccent,
12325
+ WHOP_EMAIL_LABELS,
12326
+ WHOP_GRAY_COLORS,
12327
+ WHOP_BILLING_DETAILS,
12034
12328
  surchargeShowsLabel,
12035
12329
  surchargeFigurePlan,
12036
12330
  readableInkOn,
@@ -12067,6 +12361,7 @@ export {
12067
12361
  verticalGapValue,
12068
12362
  inputPadValue,
12069
12363
  buttonPadValue,
12364
+ vaultFormAppearance,
12070
12365
  logoDimensions,
12071
12366
  isHexColor,
12072
12367
  WCAG_AA_TEXT,
@@ -12174,4 +12469,4 @@ export {
12174
12469
  decodeNativePanes,
12175
12470
  encodeNativePanes
12176
12471
  };
12177
- //# sourceMappingURL=chunk-UVKPIUOO.js.map
12472
+ //# sourceMappingURL=chunk-3I5BQEA4.js.map