@delopay/sdk 0.232.0 → 0.235.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.
@@ -8667,6 +8667,114 @@ var WHOP_GRAY_COLORS = [
8667
8667
  "sand"
8668
8668
  ];
8669
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
+ }
8670
8778
 
8671
8779
  // src/branding.ts
8672
8780
  function surchargeShowsLabel(labelMode, style, position) {
@@ -9433,7 +9541,7 @@ var DEFAULT_BRANDING_BASE = {
9433
9541
  micropaymentFieldFontSize: "md",
9434
9542
  micropaymentFieldWeight: "regular",
9435
9543
  micropaymentFocusRing: "strong",
9436
- whopCardPreset: "accordion",
9544
+ whopCardPreset: "card_stacked",
9437
9545
  whopAccentColor: "auto",
9438
9546
  whopGrayColor: "auto",
9439
9547
  whopBillingDetails: "minimal",
@@ -9443,6 +9551,10 @@ var DEFAULT_BRANDING_BASE = {
9443
9551
  whopFieldFontSize: "md",
9444
9552
  whopFieldWeight: "regular",
9445
9553
  whopFocusRing: "strong",
9554
+ whopRadius: "checkout",
9555
+ whopShadow: "soft",
9556
+ whopMethodIcons: true,
9557
+ whopSelection: "radio_tint",
9446
9558
  customCss: ""
9447
9559
  };
9448
9560
  var DEFAULT_BRANDING = {
@@ -10431,6 +10543,18 @@ function decodeBranding(source) {
10431
10543
  CARD_FOCUS_RINGS,
10432
10544
  DEFAULT_BRANDING.whopFocusRing
10433
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
+ ),
10434
10558
  paypalValidTint: parseBool(extras["paypalValidTint"], DEFAULT_BRANDING.paypalValidTint),
10435
10559
  nomupayFormStyle: pickEnum(
10436
10560
  extras["nomupayFormStyle"],
@@ -10588,6 +10712,10 @@ function encodeBranding(branding, base) {
10588
10712
  whopFieldFontSize: branding.whopFieldFontSize,
10589
10713
  whopFieldWeight: branding.whopFieldWeight,
10590
10714
  whopFocusRing: branding.whopFocusRing,
10715
+ whopRadius: branding.whopRadius,
10716
+ whopShadow: branding.whopShadow,
10717
+ whopMethodIcons: String(branding.whopMethodIcons),
10718
+ whopSelection: branding.whopSelection,
10591
10719
  paypalValidTint: String(branding.paypalValidTint),
10592
10720
  nomupayFormStyle: branding.nomupayFormStyle,
10593
10721
  nomupayShowLabels: String(branding.nomupayShowLabels),
@@ -11041,6 +11169,14 @@ function parseImportedBranding(raw) {
11041
11169
  CARD_FOCUS_RINGS,
11042
11170
  dflt.whopFocusRing
11043
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
+ ),
11044
11180
  paypalValidTint: parseBool(root["paypalValidTint"], dflt.paypalValidTint),
11045
11181
  nomupayFormStyle: pickEnum(
11046
11182
  root["nomupayFormStyle"],
@@ -11169,6 +11305,21 @@ function withoutCredentialHeaders(extra) {
11169
11305
  }
11170
11306
  return out;
11171
11307
  }
11308
+ function vaultFormQuery(params) {
11309
+ const look = params?.appearance;
11310
+ return {
11311
+ locale: params?.locale,
11312
+ form_surface: look?.surface,
11313
+ form_text: look?.text,
11314
+ form_border: look?.border,
11315
+ form_accent: look?.accent,
11316
+ form_danger: look?.danger,
11317
+ form_font: look?.font,
11318
+ form_radius: look?.radius,
11319
+ form_size: look?.size,
11320
+ form_labels: look?.labels
11321
+ };
11322
+ }
11172
11323
  function withoutHeader(headers, name) {
11173
11324
  const out = {};
11174
11325
  for (const [key, value] of Object.entries(headers)) {
@@ -11588,21 +11739,31 @@ var CheckoutSession = class {
11588
11739
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11589
11740
  */
11590
11741
  async vaultCollectSession(options, params) {
11591
- const look = params?.appearance;
11592
11742
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11593
11743
  ...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
- },
11744
+ query: vaultFormQuery(params),
11745
+ headers: this.bearerHeaders(options?.headers)
11746
+ });
11747
+ }
11748
+ /**
11749
+ * The saved cards the buyer of this payment can pay with, on a shop whose
11750
+ * vault keeps the security code itself (Enigma Vault): the cards of the
11751
+ * payment's own customer that the shop's vault holds, most recently used
11752
+ * first. A payment without a customer answers an empty list.
11753
+ *
11754
+ * Draw saved cards from this list, not from the customer's payment-method
11755
+ * list: that one also carries cards the security-code form cannot open.
11756
+ * To pay with one, mint its form with {@link vaultSecurityCodeSession},
11757
+ * and confirm with its `payment_token` once the form reports the code
11758
+ * stored.
11759
+ *
11760
+ * A shop without a vault, and a VGS shop, answer `400`.
11761
+ *
11762
+ * `GET /payment-link/{merchantId}/{paymentId}/vault/saved-cards`
11763
+ */
11764
+ async vaultSavedCards(options) {
11765
+ return this.client.request("GET", `${this.linkBase}/vault/saved-cards`, {
11766
+ ...options,
11606
11767
  headers: this.bearerHeaders(options?.headers)
11607
11768
  });
11608
11769
  }
@@ -11612,15 +11773,24 @@ var CheckoutSession = class {
11612
11773
  * vault's own form, so it never reaches the checkout; confirm with the saved
11613
11774
  * card's `payment_token` once the form reports it stored.
11614
11775
  *
11615
- * `paymentToken` is the saved card's token from the payment-method list. A
11776
+ * `paymentToken` is the saved card's token from {@link vaultSavedCards}. A
11616
11777
  * VGS shop answers `400`: VGS re-collects the code with Collect.
11617
11778
  *
11779
+ * `params.appearance` asks for a form styled to match the page, as on
11780
+ * {@link vaultCollectSession}. The styled form is the security-code field
11781
+ * alone, with no label: draw the label beside the frame, and size the frame
11782
+ * to the answer's `height`. `labels` is ignored. If the vault refuses the
11783
+ * styled form the answer is the plain one, without `height`.
11784
+ *
11785
+ * The form stores one code and then disables itself. After a failed
11786
+ * payment, mint a new form before the buyer tries again.
11787
+ *
11618
11788
  * `GET /payment-link/{merchantId}/{paymentId}/vault/security-code-session`
11619
11789
  */
11620
- async vaultSecurityCodeSession(paymentToken, options) {
11790
+ async vaultSecurityCodeSession(paymentToken, options, params) {
11621
11791
  return this.client.request("GET", `${this.linkBase}/vault/security-code-session`, {
11622
11792
  ...options,
11623
- query: { payment_token: paymentToken },
11793
+ query: { payment_token: paymentToken, ...vaultFormQuery(params) },
11624
11794
  headers: this.bearerHeaders(options?.headers)
11625
11795
  });
11626
11796
  }
@@ -12325,6 +12495,12 @@ export {
12325
12495
  WHOP_EMAIL_LABELS,
12326
12496
  WHOP_GRAY_COLORS,
12327
12497
  WHOP_BILLING_DETAILS,
12498
+ WHOP_RADII,
12499
+ WHOP_SHADOWS,
12500
+ WHOP_SELECTIONS,
12501
+ WHOP_LOOKS,
12502
+ WHOP_LOOK_SETTINGS,
12503
+ matchWhopLook,
12328
12504
  surchargeShowsLabel,
12329
12505
  surchargeFigurePlan,
12330
12506
  readableInkOn,
@@ -12469,4 +12645,4 @@ export {
12469
12645
  decodeNativePanes,
12470
12646
  encodeNativePanes
12471
12647
  };
12472
- //# sourceMappingURL=chunk-3I5BQEA4.js.map
12648
+ //# sourceMappingURL=chunk-FRH5BWGL.js.map