@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.
@@ -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
  *
@@ -8653,6 +8667,114 @@ var WHOP_GRAY_COLORS = [
8653
8667
  "sand"
8654
8668
  ];
8655
8669
  var WHOP_BILLING_DETAILS = ["minimal", "full"];
8670
+ var WHOP_RADII = ["checkout", "square", "small", "medium", "large"];
8671
+ var WHOP_SHADOWS = ["none", "soft"];
8672
+ var WHOP_SELECTIONS = ["radio_tint", "radio", "tint"];
8673
+ var WHOP_LOOKS = [
8674
+ "standard",
8675
+ "clean",
8676
+ "whop",
8677
+ "cards",
8678
+ "tiles",
8679
+ "soft",
8680
+ "minimal"
8681
+ ];
8682
+ var WHOP_LOOK_SETTINGS = {
8683
+ // The fewest fields Whop takes a card with, laid out as Stripe's card
8684
+ // form: the email, the number above expiry and code, then one group of
8685
+ // name, country (preselected) and postal code. Whop refuses a card without
8686
+ // any of them. The wallets are the shop's own express buttons.
8687
+ standard: {
8688
+ whopCardPreset: "card_stacked",
8689
+ whopBillingDetails: "minimal",
8690
+ whopSeparated: false,
8691
+ whopFieldChrome: "outlined",
8692
+ whopEmailLabel: "above",
8693
+ whopRadius: "checkout",
8694
+ whopShadow: "soft",
8695
+ whopMethodIcons: true,
8696
+ whopSelection: "radio_tint"
8697
+ },
8698
+ // Flat fields like the checkout's own, the method list with the chosen
8699
+ // method tinted beside its radio.
8700
+ clean: {
8701
+ whopCardPreset: "accordion",
8702
+ whopBillingDetails: "minimal",
8703
+ whopSeparated: false,
8704
+ whopFieldChrome: "outlined",
8705
+ whopEmailLabel: "above",
8706
+ whopRadius: "checkout",
8707
+ whopShadow: "none",
8708
+ whopMethodIcons: true,
8709
+ whopSelection: "radio_tint"
8710
+ },
8711
+ // Whop's own form: its corners, its soft shadow, its radio dots.
8712
+ whop: {
8713
+ whopCardPreset: "accordion",
8714
+ whopBillingDetails: "minimal",
8715
+ whopSeparated: false,
8716
+ whopFieldChrome: "outlined",
8717
+ whopEmailLabel: "above",
8718
+ whopRadius: "small",
8719
+ whopShadow: "soft",
8720
+ whopMethodIcons: true,
8721
+ whopSelection: "radio"
8722
+ },
8723
+ // Each method its own raised card, the chosen one tinted, no dots.
8724
+ cards: {
8725
+ whopCardPreset: "accordion",
8726
+ whopBillingDetails: "minimal",
8727
+ whopSeparated: true,
8728
+ whopFieldChrome: "outlined",
8729
+ whopEmailLabel: "above",
8730
+ whopRadius: "medium",
8731
+ whopShadow: "soft",
8732
+ whopMethodIcons: true,
8733
+ whopSelection: "tint"
8734
+ },
8735
+ // The methods as tiles above the card's fields.
8736
+ tiles: {
8737
+ whopCardPreset: "tiles",
8738
+ whopBillingDetails: "minimal",
8739
+ whopSeparated: false,
8740
+ whopFieldChrome: "outlined",
8741
+ whopEmailLabel: "above",
8742
+ whopRadius: "checkout",
8743
+ whopShadow: "none",
8744
+ whopMethodIcons: true,
8745
+ whopSelection: "radio_tint"
8746
+ },
8747
+ // Filled fields with the captions inside, round corners.
8748
+ soft: {
8749
+ whopCardPreset: "accordion",
8750
+ whopBillingDetails: "minimal",
8751
+ whopSeparated: false,
8752
+ whopFieldChrome: "filled",
8753
+ whopEmailLabel: "floating",
8754
+ whopRadius: "large",
8755
+ whopShadow: "none",
8756
+ whopMethodIcons: false,
8757
+ whopSelection: "radio_tint"
8758
+ },
8759
+ // The card alone on one line, underlined, captions inside.
8760
+ minimal: {
8761
+ whopCardPreset: "card_compact",
8762
+ whopBillingDetails: "minimal",
8763
+ whopSeparated: false,
8764
+ whopFieldChrome: "underline",
8765
+ whopEmailLabel: "floating",
8766
+ whopRadius: "square",
8767
+ whopShadow: "none",
8768
+ whopMethodIcons: true,
8769
+ whopSelection: "radio_tint"
8770
+ }
8771
+ };
8772
+ function matchWhopLook(settings) {
8773
+ const keys = Object.keys(WHOP_LOOK_SETTINGS.clean);
8774
+ return WHOP_LOOKS.find(
8775
+ (look) => keys.every((key) => WHOP_LOOK_SETTINGS[look][key] === settings[key])
8776
+ ) ?? null;
8777
+ }
8656
8778
 
8657
8779
  // src/branding.ts
8658
8780
  function surchargeShowsLabel(labelMode, style, position) {
@@ -8927,6 +9049,19 @@ function inputPadValue(size) {
8927
9049
  function buttonPadValue(size) {
8928
9050
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
8929
9051
  }
9052
+ function vaultFormAppearance(b, danger) {
9053
+ return {
9054
+ surface: b.surface,
9055
+ text: b.text,
9056
+ border: b.border,
9057
+ accent: b.primary,
9058
+ ...danger ? { danger } : {},
9059
+ font: b.fontFamily,
9060
+ radius: b.radiusInput,
9061
+ size: b.inputSize,
9062
+ labels: b.labelStyle
9063
+ };
9064
+ }
8930
9065
  function logoDimensions(size) {
8931
9066
  switch (size) {
8932
9067
  case "sm":
@@ -9406,7 +9541,7 @@ var DEFAULT_BRANDING_BASE = {
9406
9541
  micropaymentFieldFontSize: "md",
9407
9542
  micropaymentFieldWeight: "regular",
9408
9543
  micropaymentFocusRing: "strong",
9409
- whopCardPreset: "accordion",
9544
+ whopCardPreset: "card_stacked",
9410
9545
  whopAccentColor: "auto",
9411
9546
  whopGrayColor: "auto",
9412
9547
  whopBillingDetails: "minimal",
@@ -9416,6 +9551,10 @@ var DEFAULT_BRANDING_BASE = {
9416
9551
  whopFieldFontSize: "md",
9417
9552
  whopFieldWeight: "regular",
9418
9553
  whopFocusRing: "strong",
9554
+ whopRadius: "checkout",
9555
+ whopShadow: "soft",
9556
+ whopMethodIcons: true,
9557
+ whopSelection: "radio_tint",
9419
9558
  customCss: ""
9420
9559
  };
9421
9560
  var DEFAULT_BRANDING = {
@@ -10404,6 +10543,18 @@ function decodeBranding(source) {
10404
10543
  CARD_FOCUS_RINGS,
10405
10544
  DEFAULT_BRANDING.whopFocusRing
10406
10545
  ),
10546
+ whopRadius: pickEnum(extras["whopRadius"], WHOP_RADII, DEFAULT_BRANDING.whopRadius),
10547
+ whopShadow: pickEnum(
10548
+ extras["whopShadow"],
10549
+ WHOP_SHADOWS,
10550
+ DEFAULT_BRANDING.whopShadow
10551
+ ),
10552
+ whopMethodIcons: parseBool(extras["whopMethodIcons"], DEFAULT_BRANDING.whopMethodIcons),
10553
+ whopSelection: pickEnum(
10554
+ extras["whopSelection"],
10555
+ WHOP_SELECTIONS,
10556
+ DEFAULT_BRANDING.whopSelection
10557
+ ),
10407
10558
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
10408
10559
  nomupayFormStyle: pickEnum(
10409
10560
  extras["nomupayFormStyle"],
@@ -10561,6 +10712,10 @@ function encodeBranding(branding, base) {
10561
10712
  whopFieldFontSize: branding.whopFieldFontSize,
10562
10713
  whopFieldWeight: branding.whopFieldWeight,
10563
10714
  whopFocusRing: branding.whopFocusRing,
10715
+ whopRadius: branding.whopRadius,
10716
+ whopShadow: branding.whopShadow,
10717
+ whopMethodIcons: String(branding.whopMethodIcons),
10718
+ whopSelection: branding.whopSelection,
10564
10719
  paypalValidTint: String(branding.paypalValidTint),
10565
10720
  nomupayFormStyle: branding.nomupayFormStyle,
10566
10721
  nomupayShowLabels: String(branding.nomupayShowLabels),
@@ -11014,6 +11169,14 @@ function parseImportedBranding(raw) {
11014
11169
  CARD_FOCUS_RINGS,
11015
11170
  dflt.whopFocusRing
11016
11171
  ),
11172
+ whopRadius: pickEnum(root["whopRadius"], WHOP_RADII, dflt.whopRadius),
11173
+ whopShadow: pickEnum(root["whopShadow"], WHOP_SHADOWS, dflt.whopShadow),
11174
+ whopMethodIcons: parseBool(root["whopMethodIcons"], dflt.whopMethodIcons),
11175
+ whopSelection: pickEnum(
11176
+ root["whopSelection"],
11177
+ WHOP_SELECTIONS,
11178
+ dflt.whopSelection
11179
+ ),
11017
11180
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
11018
11181
  nomupayFormStyle: pickEnum(
11019
11182
  root["nomupayFormStyle"],
@@ -11553,11 +11716,29 @@ var CheckoutSession = class {
11553
11716
  * reports the vault as enabled and still expects its cards cloaked. The same
11554
11717
  * status also covers a payment that does not exist.
11555
11718
  *
11719
+ * `params.appearance` asks for a form styled to match the page (Enigma
11720
+ * Vault). The answer then carries `height`, the frame height to use. If the
11721
+ * vault refuses the styled form the answer is the plain one, without
11722
+ * `height`. `params.locale` is the buyer's locale.
11723
+ *
11556
11724
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11557
11725
  */
11558
- async vaultCollectSession(options) {
11726
+ async vaultCollectSession(options, params) {
11727
+ const look = params?.appearance;
11559
11728
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11560
11729
  ...options,
11730
+ query: {
11731
+ locale: params?.locale,
11732
+ form_surface: look?.surface,
11733
+ form_text: look?.text,
11734
+ form_border: look?.border,
11735
+ form_accent: look?.accent,
11736
+ form_danger: look?.danger,
11737
+ form_font: look?.font,
11738
+ form_radius: look?.radius,
11739
+ form_size: look?.size,
11740
+ form_labels: look?.labels
11741
+ },
11561
11742
  headers: this.bearerHeaders(options?.headers)
11562
11743
  });
11563
11744
  }
@@ -12146,9 +12327,10 @@ function encodePanes(panes) {
12146
12327
  };
12147
12328
  });
12148
12329
  }
12330
+ 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}$/;
12149
12331
  function focusedCheckoutUrl(params) {
12150
12332
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
12151
- const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12333
+ const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
12152
12334
  params.paymentId
12153
12335
  )}`;
12154
12336
  const query = new URLSearchParams({ pane: params.method });
@@ -12279,6 +12461,12 @@ export {
12279
12461
  WHOP_EMAIL_LABELS,
12280
12462
  WHOP_GRAY_COLORS,
12281
12463
  WHOP_BILLING_DETAILS,
12464
+ WHOP_RADII,
12465
+ WHOP_SHADOWS,
12466
+ WHOP_SELECTIONS,
12467
+ WHOP_LOOKS,
12468
+ WHOP_LOOK_SETTINGS,
12469
+ matchWhopLook,
12282
12470
  surchargeShowsLabel,
12283
12471
  surchargeFigurePlan,
12284
12472
  readableInkOn,
@@ -12315,6 +12503,7 @@ export {
12315
12503
  verticalGapValue,
12316
12504
  inputPadValue,
12317
12505
  buttonPadValue,
12506
+ vaultFormAppearance,
12318
12507
  logoDimensions,
12319
12508
  isHexColor,
12320
12509
  WCAG_AA_TEXT,
@@ -12422,4 +12611,4 @@ export {
12422
12611
  decodeNativePanes,
12423
12612
  encodeNativePanes
12424
12613
  };
12425
- //# sourceMappingURL=chunk-HNQKUUSW.js.map
12614
+ //# sourceMappingURL=chunk-3NOAX6WN.js.map