@delopay/sdk 0.230.0 → 0.234.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
@@ -139,6 +139,11 @@ __export(index_exports, {
139
139
  WHOP_CARD_PRESETS: () => WHOP_CARD_PRESETS,
140
140
  WHOP_EMAIL_LABELS: () => WHOP_EMAIL_LABELS,
141
141
  WHOP_GRAY_COLORS: () => WHOP_GRAY_COLORS,
142
+ WHOP_LOOKS: () => WHOP_LOOKS,
143
+ WHOP_LOOK_SETTINGS: () => WHOP_LOOK_SETTINGS,
144
+ WHOP_RADII: () => WHOP_RADII,
145
+ WHOP_SELECTIONS: () => WHOP_SELECTIONS,
146
+ WHOP_SHADOWS: () => WHOP_SHADOWS,
142
147
  Webhooks: () => Webhooks,
143
148
  WhopResolutionCases: () => WhopResolutionCases,
144
149
  airwallexCardLayout: () => airwallexCardLayout,
@@ -211,6 +216,7 @@ __export(index_exports, {
211
216
  knownSectionLabelKey: () => knownSectionLabelKey,
212
217
  leaf: () => leaf,
213
218
  logoDimensions: () => logoDimensions,
219
+ matchWhopLook: () => matchWhopLook,
214
220
  nativePaneMethodInfo: () => nativePaneMethodInfo,
215
221
  nearestWhopAccent: () => nearestWhopAccent,
216
222
  noticeText: () => noticeText,
@@ -248,6 +254,7 @@ __export(index_exports, {
248
254
  surfacePadValue: () => surfacePadValue,
249
255
  validSectionOrder: () => validSectionOrder,
250
256
  validatePanes: () => validatePanes,
257
+ vaultFormAppearance: () => vaultFormAppearance,
251
258
  verticalGapValue: () => verticalGapValue,
252
259
  visibleCustomFields: () => visibleCustomFields,
253
260
  whopAccentSwatch: () => whopAccentSwatch,
@@ -2100,6 +2107,20 @@ var PaymentLinks = class {
2100
2107
  async retrieve(linkId) {
2101
2108
  return this.request("GET", `/payment-link/${encodeURIComponent(linkId)}`);
2102
2109
  }
2110
+ /**
2111
+ * The merchant and payment an opaque checkout link opens.
2112
+ *
2113
+ * A link the API issues today is `/pay/{payment_link_id}`, so it names
2114
+ * neither the merchant nor the payment. This answers which ones it means.
2115
+ * Unauthenticated, like the checkout render it precedes: no credential is
2116
+ * needed or sent beyond what the client already carries. An unknown id is a
2117
+ * 404.
2118
+ *
2119
+ * `GET /payment-link/resolve/{payment_link_id}`
2120
+ */
2121
+ async resolve(paymentLinkId) {
2122
+ return this.request("GET", `/payment-link/resolve/${encodeURIComponent(paymentLinkId)}`);
2123
+ }
2103
2124
  /**
2104
2125
  * List payment links, optionally filtered by status or date range.
2105
2126
  *
@@ -8910,6 +8931,114 @@ var WHOP_GRAY_COLORS = [
8910
8931
  "sand"
8911
8932
  ];
8912
8933
  var WHOP_BILLING_DETAILS = ["minimal", "full"];
8934
+ var WHOP_RADII = ["checkout", "square", "small", "medium", "large"];
8935
+ var WHOP_SHADOWS = ["none", "soft"];
8936
+ var WHOP_SELECTIONS = ["radio_tint", "radio", "tint"];
8937
+ var WHOP_LOOKS = [
8938
+ "standard",
8939
+ "clean",
8940
+ "whop",
8941
+ "cards",
8942
+ "tiles",
8943
+ "soft",
8944
+ "minimal"
8945
+ ];
8946
+ var WHOP_LOOK_SETTINGS = {
8947
+ // The fewest fields Whop takes a card with, laid out as Stripe's card
8948
+ // form: the email, the number above expiry and code, then one group of
8949
+ // name, country (preselected) and postal code. Whop refuses a card without
8950
+ // any of them. The wallets are the shop's own express buttons.
8951
+ standard: {
8952
+ whopCardPreset: "card_stacked",
8953
+ whopBillingDetails: "minimal",
8954
+ whopSeparated: false,
8955
+ whopFieldChrome: "outlined",
8956
+ whopEmailLabel: "above",
8957
+ whopRadius: "checkout",
8958
+ whopShadow: "soft",
8959
+ whopMethodIcons: true,
8960
+ whopSelection: "radio_tint"
8961
+ },
8962
+ // Flat fields like the checkout's own, the method list with the chosen
8963
+ // method tinted beside its radio.
8964
+ clean: {
8965
+ whopCardPreset: "accordion",
8966
+ whopBillingDetails: "minimal",
8967
+ whopSeparated: false,
8968
+ whopFieldChrome: "outlined",
8969
+ whopEmailLabel: "above",
8970
+ whopRadius: "checkout",
8971
+ whopShadow: "none",
8972
+ whopMethodIcons: true,
8973
+ whopSelection: "radio_tint"
8974
+ },
8975
+ // Whop's own form: its corners, its soft shadow, its radio dots.
8976
+ whop: {
8977
+ whopCardPreset: "accordion",
8978
+ whopBillingDetails: "minimal",
8979
+ whopSeparated: false,
8980
+ whopFieldChrome: "outlined",
8981
+ whopEmailLabel: "above",
8982
+ whopRadius: "small",
8983
+ whopShadow: "soft",
8984
+ whopMethodIcons: true,
8985
+ whopSelection: "radio"
8986
+ },
8987
+ // Each method its own raised card, the chosen one tinted, no dots.
8988
+ cards: {
8989
+ whopCardPreset: "accordion",
8990
+ whopBillingDetails: "minimal",
8991
+ whopSeparated: true,
8992
+ whopFieldChrome: "outlined",
8993
+ whopEmailLabel: "above",
8994
+ whopRadius: "medium",
8995
+ whopShadow: "soft",
8996
+ whopMethodIcons: true,
8997
+ whopSelection: "tint"
8998
+ },
8999
+ // The methods as tiles above the card's fields.
9000
+ tiles: {
9001
+ whopCardPreset: "tiles",
9002
+ whopBillingDetails: "minimal",
9003
+ whopSeparated: false,
9004
+ whopFieldChrome: "outlined",
9005
+ whopEmailLabel: "above",
9006
+ whopRadius: "checkout",
9007
+ whopShadow: "none",
9008
+ whopMethodIcons: true,
9009
+ whopSelection: "radio_tint"
9010
+ },
9011
+ // Filled fields with the captions inside, round corners.
9012
+ soft: {
9013
+ whopCardPreset: "accordion",
9014
+ whopBillingDetails: "minimal",
9015
+ whopSeparated: false,
9016
+ whopFieldChrome: "filled",
9017
+ whopEmailLabel: "floating",
9018
+ whopRadius: "large",
9019
+ whopShadow: "none",
9020
+ whopMethodIcons: false,
9021
+ whopSelection: "radio_tint"
9022
+ },
9023
+ // The card alone on one line, underlined, captions inside.
9024
+ minimal: {
9025
+ whopCardPreset: "card_compact",
9026
+ whopBillingDetails: "minimal",
9027
+ whopSeparated: false,
9028
+ whopFieldChrome: "underline",
9029
+ whopEmailLabel: "floating",
9030
+ whopRadius: "square",
9031
+ whopShadow: "none",
9032
+ whopMethodIcons: true,
9033
+ whopSelection: "radio_tint"
9034
+ }
9035
+ };
9036
+ function matchWhopLook(settings) {
9037
+ const keys = Object.keys(WHOP_LOOK_SETTINGS.clean);
9038
+ return WHOP_LOOKS.find(
9039
+ (look) => keys.every((key) => WHOP_LOOK_SETTINGS[look][key] === settings[key])
9040
+ ) ?? null;
9041
+ }
8913
9042
 
8914
9043
  // src/branding.ts
8915
9044
  function surchargeShowsLabel(labelMode, style, position) {
@@ -9184,6 +9313,19 @@ function inputPadValue(size) {
9184
9313
  function buttonPadValue(size) {
9185
9314
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
9186
9315
  }
9316
+ function vaultFormAppearance(b, danger) {
9317
+ return {
9318
+ surface: b.surface,
9319
+ text: b.text,
9320
+ border: b.border,
9321
+ accent: b.primary,
9322
+ ...danger ? { danger } : {},
9323
+ font: b.fontFamily,
9324
+ radius: b.radiusInput,
9325
+ size: b.inputSize,
9326
+ labels: b.labelStyle
9327
+ };
9328
+ }
9187
9329
  function logoDimensions(size) {
9188
9330
  switch (size) {
9189
9331
  case "sm":
@@ -9663,7 +9805,7 @@ var DEFAULT_BRANDING_BASE = {
9663
9805
  micropaymentFieldFontSize: "md",
9664
9806
  micropaymentFieldWeight: "regular",
9665
9807
  micropaymentFocusRing: "strong",
9666
- whopCardPreset: "accordion",
9808
+ whopCardPreset: "card_stacked",
9667
9809
  whopAccentColor: "auto",
9668
9810
  whopGrayColor: "auto",
9669
9811
  whopBillingDetails: "minimal",
@@ -9673,6 +9815,10 @@ var DEFAULT_BRANDING_BASE = {
9673
9815
  whopFieldFontSize: "md",
9674
9816
  whopFieldWeight: "regular",
9675
9817
  whopFocusRing: "strong",
9818
+ whopRadius: "checkout",
9819
+ whopShadow: "soft",
9820
+ whopMethodIcons: true,
9821
+ whopSelection: "radio_tint",
9676
9822
  customCss: ""
9677
9823
  };
9678
9824
  var DEFAULT_BRANDING = {
@@ -10661,6 +10807,18 @@ function decodeBranding(source) {
10661
10807
  CARD_FOCUS_RINGS,
10662
10808
  DEFAULT_BRANDING.whopFocusRing
10663
10809
  ),
10810
+ whopRadius: pickEnum(extras["whopRadius"], WHOP_RADII, DEFAULT_BRANDING.whopRadius),
10811
+ whopShadow: pickEnum(
10812
+ extras["whopShadow"],
10813
+ WHOP_SHADOWS,
10814
+ DEFAULT_BRANDING.whopShadow
10815
+ ),
10816
+ whopMethodIcons: parseBool(extras["whopMethodIcons"], DEFAULT_BRANDING.whopMethodIcons),
10817
+ whopSelection: pickEnum(
10818
+ extras["whopSelection"],
10819
+ WHOP_SELECTIONS,
10820
+ DEFAULT_BRANDING.whopSelection
10821
+ ),
10664
10822
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
10665
10823
  nomupayFormStyle: pickEnum(
10666
10824
  extras["nomupayFormStyle"],
@@ -10818,6 +10976,10 @@ function encodeBranding(branding, base) {
10818
10976
  whopFieldFontSize: branding.whopFieldFontSize,
10819
10977
  whopFieldWeight: branding.whopFieldWeight,
10820
10978
  whopFocusRing: branding.whopFocusRing,
10979
+ whopRadius: branding.whopRadius,
10980
+ whopShadow: branding.whopShadow,
10981
+ whopMethodIcons: String(branding.whopMethodIcons),
10982
+ whopSelection: branding.whopSelection,
10821
10983
  paypalValidTint: String(branding.paypalValidTint),
10822
10984
  nomupayFormStyle: branding.nomupayFormStyle,
10823
10985
  nomupayShowLabels: String(branding.nomupayShowLabels),
@@ -11271,6 +11433,14 @@ function parseImportedBranding(raw) {
11271
11433
  CARD_FOCUS_RINGS,
11272
11434
  dflt.whopFocusRing
11273
11435
  ),
11436
+ whopRadius: pickEnum(root["whopRadius"], WHOP_RADII, dflt.whopRadius),
11437
+ whopShadow: pickEnum(root["whopShadow"], WHOP_SHADOWS, dflt.whopShadow),
11438
+ whopMethodIcons: parseBool(root["whopMethodIcons"], dflt.whopMethodIcons),
11439
+ whopSelection: pickEnum(
11440
+ root["whopSelection"],
11441
+ WHOP_SELECTIONS,
11442
+ dflt.whopSelection
11443
+ ),
11274
11444
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
11275
11445
  nomupayFormStyle: pickEnum(
11276
11446
  root["nomupayFormStyle"],
@@ -11810,11 +11980,29 @@ var CheckoutSession = class {
11810
11980
  * reports the vault as enabled and still expects its cards cloaked. The same
11811
11981
  * status also covers a payment that does not exist.
11812
11982
  *
11983
+ * `params.appearance` asks for a form styled to match the page (Enigma
11984
+ * Vault). The answer then carries `height`, the frame height to use. If the
11985
+ * vault refuses the styled form the answer is the plain one, without
11986
+ * `height`. `params.locale` is the buyer's locale.
11987
+ *
11813
11988
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11814
11989
  */
11815
- async vaultCollectSession(options) {
11990
+ async vaultCollectSession(options, params) {
11991
+ const look = params?.appearance;
11816
11992
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11817
11993
  ...options,
11994
+ query: {
11995
+ locale: params?.locale,
11996
+ form_surface: look?.surface,
11997
+ form_text: look?.text,
11998
+ form_border: look?.border,
11999
+ form_accent: look?.accent,
12000
+ form_danger: look?.danger,
12001
+ form_font: look?.font,
12002
+ form_radius: look?.radius,
12003
+ form_size: look?.size,
12004
+ form_labels: look?.labels
12005
+ },
11818
12006
  headers: this.bearerHeaders(options?.headers)
11819
12007
  });
11820
12008
  }
@@ -12403,9 +12591,10 @@ function encodePanes(panes) {
12403
12591
  };
12404
12592
  });
12405
12593
  }
12594
+ 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
12595
  function focusedCheckoutUrl(params) {
12407
12596
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
12408
- const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12597
+ const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12409
12598
  params.paymentId
12410
12599
  )}`;
12411
12600
  const query = new URLSearchParams({ pane: params.method });
@@ -12564,6 +12753,11 @@ var encodeNativePanes = encodePanes;
12564
12753
  WHOP_CARD_PRESETS,
12565
12754
  WHOP_EMAIL_LABELS,
12566
12755
  WHOP_GRAY_COLORS,
12756
+ WHOP_LOOKS,
12757
+ WHOP_LOOK_SETTINGS,
12758
+ WHOP_RADII,
12759
+ WHOP_SELECTIONS,
12760
+ WHOP_SHADOWS,
12567
12761
  Webhooks,
12568
12762
  WhopResolutionCases,
12569
12763
  airwallexCardLayout,
@@ -12636,6 +12830,7 @@ var encodeNativePanes = encodePanes;
12636
12830
  knownSectionLabelKey,
12637
12831
  leaf,
12638
12832
  logoDimensions,
12833
+ matchWhopLook,
12639
12834
  nativePaneMethodInfo,
12640
12835
  nearestWhopAccent,
12641
12836
  noticeText,
@@ -12673,6 +12868,7 @@ var encodeNativePanes = encodePanes;
12673
12868
  surfacePadValue,
12674
12869
  validSectionOrder,
12675
12870
  validatePanes,
12871
+ vaultFormAppearance,
12676
12872
  verticalGapValue,
12677
12873
  visibleCustomFields,
12678
12874
  whopAccentSwatch,