@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.
package/dist/internal.cjs CHANGED
@@ -150,6 +150,11 @@ __export(internal_exports, {
150
150
  UNKNOWN_SECTION_ORDER: () => UNKNOWN_SECTION_ORDER,
151
151
  WCAG_AA_TEXT: () => WCAG_AA_TEXT,
152
152
  WCAG_AA_UI: () => WCAG_AA_UI,
153
+ WHOP_ACCENT_COLORS: () => WHOP_ACCENT_COLORS,
154
+ WHOP_BILLING_DETAILS: () => WHOP_BILLING_DETAILS,
155
+ WHOP_CARD_PRESETS: () => WHOP_CARD_PRESETS,
156
+ WHOP_EMAIL_LABELS: () => WHOP_EMAIL_LABELS,
157
+ WHOP_GRAY_COLORS: () => WHOP_GRAY_COLORS,
153
158
  Webhooks: () => Webhooks,
154
159
  WhopResolutionCases: () => WhopResolutionCases,
155
160
  airwallexCardLayout: () => airwallexCardLayout,
@@ -223,6 +228,7 @@ __export(internal_exports, {
223
228
  leaf: () => leaf,
224
229
  logoDimensions: () => logoDimensions,
225
230
  nativePaneMethodInfo: () => nativePaneMethodInfo,
231
+ nearestWhopAccent: () => nearestWhopAccent,
226
232
  noticeText: () => noticeText,
227
233
  noticesIn: () => noticesIn,
228
234
  offerablePaneMethods: () => offerablePaneMethods,
@@ -243,6 +249,7 @@ __export(internal_exports, {
243
249
  resolveGooglePayButtonColor: () => resolveGooglePayButtonColor,
244
250
  resolveNoticesAndBadges: () => resolveNoticesAndBadges,
245
251
  resolveStripeTheme: () => resolveStripeTheme,
252
+ resolveWhopAccent: () => resolveWhopAccent,
246
253
  ruleMatchToTree: () => ruleMatchToTree,
247
254
  sanitizeCustomCss: () => sanitizeCustomCss,
248
255
  sectionLabel: () => sectionLabel,
@@ -257,8 +264,11 @@ __export(internal_exports, {
257
264
  surfacePadValue: () => surfacePadValue,
258
265
  validSectionOrder: () => validSectionOrder,
259
266
  validatePanes: () => validatePanes,
267
+ vaultFormAppearance: () => vaultFormAppearance,
260
268
  verticalGapValue: () => verticalGapValue,
261
- visibleCustomFields: () => visibleCustomFields
269
+ visibleCustomFields: () => visibleCustomFields,
270
+ whopAccentSwatch: () => whopAccentSwatch,
271
+ whopCardElement: () => whopCardElement
262
272
  });
263
273
  module.exports = __toCommonJS(internal_exports);
264
274
 
@@ -2107,6 +2117,20 @@ var PaymentLinks = class {
2107
2117
  async retrieve(linkId) {
2108
2118
  return this.request("GET", `/payment-link/${encodeURIComponent(linkId)}`);
2109
2119
  }
2120
+ /**
2121
+ * The merchant and payment an opaque checkout link opens.
2122
+ *
2123
+ * A link the API issues today is `/pay/{payment_link_id}`, so it names
2124
+ * neither the merchant nor the payment. This answers which ones it means.
2125
+ * Unauthenticated, like the checkout render it precedes: no credential is
2126
+ * needed or sent beyond what the client already carries. An unknown id is a
2127
+ * 404.
2128
+ *
2129
+ * `GET /payment-link/resolve/{payment_link_id}`
2130
+ */
2131
+ async resolve(paymentLinkId) {
2132
+ return this.request("GET", `/payment-link/resolve/${encodeURIComponent(paymentLinkId)}`);
2133
+ }
2110
2134
  /**
2111
2135
  * List payment links, optionally filtered by status or date range.
2112
2136
  *
@@ -8790,6 +8814,133 @@ var GOOGLE_PAY_BUTTON_TYPES = [
8790
8814
  "subscribe",
8791
8815
  "donate"
8792
8816
  ];
8817
+ var WHOP_CARD_PRESETS = ["accordion", "tiles", "card_stacked", "card_compact"];
8818
+ function whopCardElement(preset) {
8819
+ switch (preset) {
8820
+ case "tiles":
8821
+ return { element: "payment", layout: "horizontal" };
8822
+ case "card_stacked":
8823
+ return { element: "card", layout: "stacked" };
8824
+ case "card_compact":
8825
+ return { element: "card", layout: "compact" };
8826
+ default:
8827
+ return { element: "payment", layout: "accordion" };
8828
+ }
8829
+ }
8830
+ var WHOP_ACCENT_COLORS = [
8831
+ "auto",
8832
+ "gray",
8833
+ "blue",
8834
+ "indigo",
8835
+ "iris",
8836
+ "violet",
8837
+ "purple",
8838
+ "plum",
8839
+ "pink",
8840
+ "crimson",
8841
+ "ruby",
8842
+ "red",
8843
+ "tomato",
8844
+ "orange",
8845
+ "amber",
8846
+ "yellow",
8847
+ "lime",
8848
+ "grass",
8849
+ "green",
8850
+ "jade",
8851
+ "teal",
8852
+ "cyan",
8853
+ "sky",
8854
+ "mint",
8855
+ "brown",
8856
+ "bronze",
8857
+ "gold"
8858
+ ];
8859
+ var WHOP_ACCENT_SWATCHES = {
8860
+ blue: "#0090ff",
8861
+ indigo: "#3e63dd",
8862
+ iris: "#5b5bd6",
8863
+ violet: "#6e56cf",
8864
+ purple: "#8e4ec6",
8865
+ plum: "#ab4aba",
8866
+ pink: "#d6409f",
8867
+ crimson: "#e93d82",
8868
+ ruby: "#e54666",
8869
+ red: "#e5484d",
8870
+ tomato: "#e54d2e",
8871
+ orange: "#f76b15",
8872
+ amber: "#ffc53d",
8873
+ yellow: "#ffe629",
8874
+ lime: "#bdee63",
8875
+ grass: "#46a758",
8876
+ green: "#30a46c",
8877
+ jade: "#29a383",
8878
+ teal: "#12a594",
8879
+ cyan: "#00a2c7",
8880
+ sky: "#7ce2fe",
8881
+ mint: "#86ead4",
8882
+ brown: "#ad7f58",
8883
+ bronze: "#a18072",
8884
+ gold: "#978365"
8885
+ };
8886
+ function whopAccentSwatch(accent) {
8887
+ return accent === "gray" ? "#8d8d8d" : WHOP_ACCENT_SWATCHES[accent];
8888
+ }
8889
+ function hexRgb(hex) {
8890
+ const raw = hex.trim().replace(/^#/, "");
8891
+ const full = raw.length === 3 ? raw.replace(/./g, (c) => c + c) : raw;
8892
+ if (!/^[0-9a-f]{6}$/i.test(full)) return null;
8893
+ const n = Number.parseInt(full, 16);
8894
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
8895
+ }
8896
+ function oklab([r, g, b]) {
8897
+ const lin = (c) => {
8898
+ const v = c / 255;
8899
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
8900
+ };
8901
+ const [lr, lg, lb] = [lin(r), lin(g), lin(b)];
8902
+ const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
8903
+ const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
8904
+ const s2 = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
8905
+ return [
8906
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s2,
8907
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s2,
8908
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s2
8909
+ ];
8910
+ }
8911
+ function nearestWhopAccent(hex) {
8912
+ const rgb = hexRgb(hex);
8913
+ if (!rgb) return "blue";
8914
+ const [L, a, b] = oklab(rgb);
8915
+ if (Math.hypot(a, b) < 0.04) return "gray";
8916
+ let best = "blue";
8917
+ let bestDistance = Number.POSITIVE_INFINITY;
8918
+ for (const [name, swatch] of Object.entries(WHOP_ACCENT_SWATCHES)) {
8919
+ const swatchRgb = hexRgb(swatch);
8920
+ if (!swatchRgb) continue;
8921
+ const [sL, sa, sb] = oklab(swatchRgb);
8922
+ const distance = Math.hypot((L - sL) * 0.5, a - sa, b - sb);
8923
+ if (distance < bestDistance) {
8924
+ bestDistance = distance;
8925
+ best = name;
8926
+ }
8927
+ }
8928
+ return best;
8929
+ }
8930
+ function resolveWhopAccent(accent, primaryHex) {
8931
+ return accent === "auto" ? nearestWhopAccent(primaryHex) : accent;
8932
+ }
8933
+ var WHOP_EMAIL_LABELS = ["above", "floating"];
8934
+ var WHOP_GRAY_COLORS = [
8935
+ "auto",
8936
+ "gray",
8937
+ "mauve",
8938
+ "slate",
8939
+ "sage",
8940
+ "olive",
8941
+ "sand"
8942
+ ];
8943
+ var WHOP_BILLING_DETAILS = ["minimal", "full"];
8793
8944
 
8794
8945
  // src/branding.ts
8795
8946
  function surchargeShowsLabel(labelMode, style, position) {
@@ -9064,6 +9215,19 @@ function inputPadValue(size) {
9064
9215
  function buttonPadValue(size) {
9065
9216
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
9066
9217
  }
9218
+ function vaultFormAppearance(b, danger) {
9219
+ return {
9220
+ surface: b.surface,
9221
+ text: b.text,
9222
+ border: b.border,
9223
+ accent: b.primary,
9224
+ ...danger ? { danger } : {},
9225
+ font: b.fontFamily,
9226
+ radius: b.radiusInput,
9227
+ size: b.inputSize,
9228
+ labels: b.labelStyle
9229
+ };
9230
+ }
9067
9231
  function logoDimensions(size) {
9068
9232
  switch (size) {
9069
9233
  case "sm":
@@ -9543,6 +9707,16 @@ var DEFAULT_BRANDING_BASE = {
9543
9707
  micropaymentFieldFontSize: "md",
9544
9708
  micropaymentFieldWeight: "regular",
9545
9709
  micropaymentFocusRing: "strong",
9710
+ whopCardPreset: "accordion",
9711
+ whopAccentColor: "auto",
9712
+ whopGrayColor: "auto",
9713
+ whopBillingDetails: "minimal",
9714
+ whopSeparated: false,
9715
+ whopEmailLabel: "above",
9716
+ whopFieldChrome: "outlined",
9717
+ whopFieldFontSize: "md",
9718
+ whopFieldWeight: "regular",
9719
+ whopFocusRing: "strong",
9546
9720
  customCss: ""
9547
9721
  };
9548
9722
  var DEFAULT_BRANDING = {
@@ -10485,6 +10659,52 @@ function decodeBranding(source) {
10485
10659
  CARD_FOCUS_RINGS,
10486
10660
  DEFAULT_BRANDING.micropaymentFocusRing
10487
10661
  ),
10662
+ whopCardPreset: pickEnum(
10663
+ extras["whopCardPreset"],
10664
+ WHOP_CARD_PRESETS,
10665
+ DEFAULT_BRANDING.whopCardPreset
10666
+ ),
10667
+ whopAccentColor: pickEnum(
10668
+ extras["whopAccentColor"],
10669
+ WHOP_ACCENT_COLORS,
10670
+ DEFAULT_BRANDING.whopAccentColor
10671
+ ),
10672
+ whopGrayColor: pickEnum(
10673
+ extras["whopGrayColor"],
10674
+ WHOP_GRAY_COLORS,
10675
+ DEFAULT_BRANDING.whopGrayColor
10676
+ ),
10677
+ whopBillingDetails: pickEnum(
10678
+ extras["whopBillingDetails"],
10679
+ WHOP_BILLING_DETAILS,
10680
+ DEFAULT_BRANDING.whopBillingDetails
10681
+ ),
10682
+ whopSeparated: parseBool(extras["whopSeparated"], DEFAULT_BRANDING.whopSeparated),
10683
+ whopEmailLabel: pickEnum(
10684
+ extras["whopEmailLabel"],
10685
+ WHOP_EMAIL_LABELS,
10686
+ DEFAULT_BRANDING.whopEmailLabel
10687
+ ),
10688
+ whopFieldChrome: pickEnum(
10689
+ extras["whopFieldChrome"],
10690
+ CARD_FIELD_CHROMES,
10691
+ DEFAULT_BRANDING.whopFieldChrome
10692
+ ),
10693
+ whopFieldFontSize: pickEnum(
10694
+ extras["whopFieldFontSize"],
10695
+ CARD_FIELD_FONT_SIZES,
10696
+ DEFAULT_BRANDING.whopFieldFontSize
10697
+ ),
10698
+ whopFieldWeight: pickEnum(
10699
+ extras["whopFieldWeight"],
10700
+ CARD_FIELD_WEIGHTS,
10701
+ DEFAULT_BRANDING.whopFieldWeight
10702
+ ),
10703
+ whopFocusRing: pickEnum(
10704
+ extras["whopFocusRing"],
10705
+ CARD_FOCUS_RINGS,
10706
+ DEFAULT_BRANDING.whopFocusRing
10707
+ ),
10488
10708
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
10489
10709
  nomupayFormStyle: pickEnum(
10490
10710
  extras["nomupayFormStyle"],
@@ -10632,6 +10852,16 @@ function encodeBranding(branding, base) {
10632
10852
  micropaymentFieldFontSize: branding.micropaymentFieldFontSize,
10633
10853
  micropaymentFieldWeight: branding.micropaymentFieldWeight,
10634
10854
  micropaymentFocusRing: branding.micropaymentFocusRing,
10855
+ whopCardPreset: branding.whopCardPreset,
10856
+ whopAccentColor: branding.whopAccentColor,
10857
+ whopGrayColor: branding.whopGrayColor,
10858
+ whopBillingDetails: branding.whopBillingDetails,
10859
+ whopSeparated: String(branding.whopSeparated),
10860
+ whopEmailLabel: branding.whopEmailLabel,
10861
+ whopFieldChrome: branding.whopFieldChrome,
10862
+ whopFieldFontSize: branding.whopFieldFontSize,
10863
+ whopFieldWeight: branding.whopFieldWeight,
10864
+ whopFocusRing: branding.whopFocusRing,
10635
10865
  paypalValidTint: String(branding.paypalValidTint),
10636
10866
  nomupayFormStyle: branding.nomupayFormStyle,
10637
10867
  nomupayShowLabels: String(branding.nomupayShowLabels),
@@ -11039,6 +11269,52 @@ function parseImportedBranding(raw) {
11039
11269
  CARD_FOCUS_RINGS,
11040
11270
  dflt.micropaymentFocusRing
11041
11271
  ),
11272
+ whopCardPreset: pickEnum(
11273
+ root["whopCardPreset"],
11274
+ WHOP_CARD_PRESETS,
11275
+ dflt.whopCardPreset
11276
+ ),
11277
+ whopAccentColor: pickEnum(
11278
+ root["whopAccentColor"],
11279
+ WHOP_ACCENT_COLORS,
11280
+ dflt.whopAccentColor
11281
+ ),
11282
+ whopGrayColor: pickEnum(
11283
+ root["whopGrayColor"],
11284
+ WHOP_GRAY_COLORS,
11285
+ dflt.whopGrayColor
11286
+ ),
11287
+ whopBillingDetails: pickEnum(
11288
+ root["whopBillingDetails"],
11289
+ WHOP_BILLING_DETAILS,
11290
+ dflt.whopBillingDetails
11291
+ ),
11292
+ whopSeparated: parseBool(root["whopSeparated"], dflt.whopSeparated),
11293
+ whopEmailLabel: pickEnum(
11294
+ root["whopEmailLabel"],
11295
+ WHOP_EMAIL_LABELS,
11296
+ dflt.whopEmailLabel
11297
+ ),
11298
+ whopFieldChrome: pickEnum(
11299
+ root["whopFieldChrome"],
11300
+ CARD_FIELD_CHROMES,
11301
+ dflt.whopFieldChrome
11302
+ ),
11303
+ whopFieldFontSize: pickEnum(
11304
+ root["whopFieldFontSize"],
11305
+ CARD_FIELD_FONT_SIZES,
11306
+ dflt.whopFieldFontSize
11307
+ ),
11308
+ whopFieldWeight: pickEnum(
11309
+ root["whopFieldWeight"],
11310
+ CARD_FIELD_WEIGHTS,
11311
+ dflt.whopFieldWeight
11312
+ ),
11313
+ whopFocusRing: pickEnum(
11314
+ root["whopFocusRing"],
11315
+ CARD_FOCUS_RINGS,
11316
+ dflt.whopFocusRing
11317
+ ),
11042
11318
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
11043
11319
  nomupayFormStyle: pickEnum(
11044
11320
  root["nomupayFormStyle"],
@@ -11578,11 +11854,29 @@ var CheckoutSession = class {
11578
11854
  * reports the vault as enabled and still expects its cards cloaked. The same
11579
11855
  * status also covers a payment that does not exist.
11580
11856
  *
11857
+ * `params.appearance` asks for a form styled to match the page (Enigma
11858
+ * Vault). The answer then carries `height`, the frame height to use. If the
11859
+ * vault refuses the styled form the answer is the plain one, without
11860
+ * `height`. `params.locale` is the buyer's locale.
11861
+ *
11581
11862
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11582
11863
  */
11583
- async vaultCollectSession(options) {
11864
+ async vaultCollectSession(options, params) {
11865
+ const look = params?.appearance;
11584
11866
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11585
11867
  ...options,
11868
+ query: {
11869
+ locale: params?.locale,
11870
+ form_surface: look?.surface,
11871
+ form_text: look?.text,
11872
+ form_border: look?.border,
11873
+ form_accent: look?.accent,
11874
+ form_danger: look?.danger,
11875
+ form_font: look?.font,
11876
+ form_radius: look?.radius,
11877
+ form_size: look?.size,
11878
+ form_labels: look?.labels
11879
+ },
11586
11880
  headers: this.bearerHeaders(options?.headers)
11587
11881
  });
11588
11882
  }
@@ -12171,9 +12465,10 @@ function encodePanes(panes) {
12171
12465
  };
12172
12466
  });
12173
12467
  }
12468
+ 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}$/;
12174
12469
  function focusedCheckoutUrl(params) {
12175
12470
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
12176
- const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12471
+ const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12177
12472
  params.paymentId
12178
12473
  )}`;
12179
12474
  const query = new URLSearchParams({ pane: params.method });
@@ -13902,6 +14197,11 @@ var DelopayInternal = class extends Delopay {
13902
14197
  UNKNOWN_SECTION_ORDER,
13903
14198
  WCAG_AA_TEXT,
13904
14199
  WCAG_AA_UI,
14200
+ WHOP_ACCENT_COLORS,
14201
+ WHOP_BILLING_DETAILS,
14202
+ WHOP_CARD_PRESETS,
14203
+ WHOP_EMAIL_LABELS,
14204
+ WHOP_GRAY_COLORS,
13905
14205
  Webhooks,
13906
14206
  WhopResolutionCases,
13907
14207
  airwallexCardLayout,
@@ -13975,6 +14275,7 @@ var DelopayInternal = class extends Delopay {
13975
14275
  leaf,
13976
14276
  logoDimensions,
13977
14277
  nativePaneMethodInfo,
14278
+ nearestWhopAccent,
13978
14279
  noticeText,
13979
14280
  noticesIn,
13980
14281
  offerablePaneMethods,
@@ -13995,6 +14296,7 @@ var DelopayInternal = class extends Delopay {
13995
14296
  resolveGooglePayButtonColor,
13996
14297
  resolveNoticesAndBadges,
13997
14298
  resolveStripeTheme,
14299
+ resolveWhopAccent,
13998
14300
  ruleMatchToTree,
13999
14301
  sanitizeCustomCss,
14000
14302
  sectionLabel,
@@ -14009,7 +14311,10 @@ var DelopayInternal = class extends Delopay {
14009
14311
  surfacePadValue,
14010
14312
  validSectionOrder,
14011
14313
  validatePanes,
14314
+ vaultFormAppearance,
14012
14315
  verticalGapValue,
14013
- visibleCustomFields
14316
+ visibleCustomFields,
14317
+ whopAccentSwatch,
14318
+ whopCardElement
14014
14319
  });
14015
14320
  //# sourceMappingURL=internal.cjs.map