@delopay/sdk 0.136.0 → 0.137.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
@@ -20,6 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AIRWALLEX_AUTOFILL_TREATMENTS: () => AIRWALLEX_AUTOFILL_TREATMENTS,
24
+ AIRWALLEX_CARD_LAYOUTS: () => AIRWALLEX_CARD_LAYOUTS,
25
+ AIRWALLEX_CARD_PRESETS: () => AIRWALLEX_CARD_PRESETS,
26
+ AIRWALLEX_CARD_PRESET_FALLBACK: () => AIRWALLEX_CARD_PRESET_FALLBACK,
27
+ AIRWALLEX_FIELD_CHROMES: () => AIRWALLEX_FIELD_CHROMES,
28
+ AIRWALLEX_FIELD_FONT_SIZES: () => AIRWALLEX_FIELD_FONT_SIZES,
29
+ AIRWALLEX_FIELD_WEIGHTS: () => AIRWALLEX_FIELD_WEIGHTS,
30
+ AIRWALLEX_FOCUS_RINGS: () => AIRWALLEX_FOCUS_RINGS,
31
+ AIRWALLEX_LABEL_STYLES: () => AIRWALLEX_LABEL_STYLES,
32
+ AIRWALLEX_NETWORK_MARKS: () => AIRWALLEX_NETWORK_MARKS,
23
33
  ALL_CUSTOM_FIELD_CONDITION_SOURCES: () => ALL_CUSTOM_FIELD_CONDITION_SOURCES,
24
34
  ALL_CUSTOM_FIELD_OPERATORS: () => ALL_CUSTOM_FIELD_OPERATORS,
25
35
  ALL_CUSTOM_FIELD_TYPES: () => ALL_CUSTOM_FIELD_TYPES,
@@ -90,9 +100,15 @@ __export(index_exports, {
90
100
  WCAG_AA_TEXT: () => WCAG_AA_TEXT,
91
101
  WCAG_AA_UI: () => WCAG_AA_UI,
92
102
  Webhooks: () => Webhooks,
103
+ airwallexCardLayout: () => airwallexCardLayout,
104
+ airwallexCardLayoutIsCoherent: () => airwallexCardLayoutIsCoherent,
105
+ airwallexCellWeight: () => airwallexCellWeight,
106
+ airwallexFieldFontPx: () => airwallexFieldFontPx,
107
+ airwallexFieldWeightValue: () => airwallexFieldWeightValue,
93
108
  allOf: () => allOf,
94
109
  anyOf: () => anyOf,
95
110
  applyBrandingVariables: () => applyBrandingVariables,
111
+ asAirwallexCardPreset: () => asAirwallexCardPreset,
96
112
  buildBrandingExport: () => buildBrandingExport,
97
113
  buttonPadValue: () => buttonPadValue,
98
114
  canonicalSectionId: () => canonicalSectionId,
@@ -156,6 +172,8 @@ __export(index_exports, {
156
172
  programToTree: () => programToTree,
157
173
  radiusValue: () => radiusValue,
158
174
  readableInkOn: () => readableInkOn,
175
+ resolveAirwallexCardPreset: () => resolveAirwallexCardPreset,
176
+ resolveAirwallexLabelStyle: () => resolveAirwallexLabelStyle,
159
177
  ruleMatchToTree: () => ruleMatchToTree,
160
178
  sanitizeCustomCss: () => sanitizeCustomCss,
161
179
  sectionLabel: () => sectionLabel,
@@ -5487,6 +5505,120 @@ function feeProgram() {
5487
5505
  return new FeeProgramBuilder();
5488
5506
  }
5489
5507
 
5508
+ // src/airwallexCard.ts
5509
+ var AIRWALLEX_CARD_PRESETS = [
5510
+ "single_row",
5511
+ "split_fields",
5512
+ "split_fields_labelled",
5513
+ "stacked",
5514
+ "number_expiry_row",
5515
+ "compact"
5516
+ ];
5517
+ var SPLIT = ["cardNumber", "expiry", "cvc"];
5518
+ var AIRWALLEX_CARD_LAYOUTS = {
5519
+ // Airwallex's combined element. One iframe, one row, and the only preset
5520
+ // whose insides are not ours to lay out — which is why it carries no
5521
+ // captions: there is nothing to caption but the row as a whole.
5522
+ single_row: {
5523
+ elements: ["card"],
5524
+ rows: [["card"]],
5525
+ labels: false,
5526
+ density: "default"
5527
+ },
5528
+ // The trio with placeholders carrying the meaning. Shorter than the
5529
+ // labelled variant and fine on a wide surface.
5530
+ split_fields: {
5531
+ elements: SPLIT,
5532
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5533
+ labels: false,
5534
+ density: "default"
5535
+ },
5536
+ // The default. The same geometry, captioned — which is what makes it
5537
+ // survive a narrow embed, where a bare field row stops being self-evident.
5538
+ split_fields_labelled: {
5539
+ elements: SPLIT,
5540
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5541
+ labels: true,
5542
+ density: "default"
5543
+ },
5544
+ // Every field full width. Expiry and CVC side by side start to crowd below
5545
+ // roughly 320px, and this is the layout that does not.
5546
+ stacked: {
5547
+ elements: SPLIT,
5548
+ rows: [["cardNumber"], ["expiry"], ["cvc"]],
5549
+ labels: true,
5550
+ density: "default"
5551
+ },
5552
+ // Two rows instead of two-plus-one: shorter than the split forms without
5553
+ // the ambiguity of a single combined field.
5554
+ //
5555
+ // 3:2, not an even split. A card number is nineteen characters and an expiry
5556
+ // is five, so halving the row clipped the number's own placeholder at 460px
5557
+ // — seen in the preview before this was weighted. The proposal drew it even;
5558
+ // the merchant-facing decision was taken on the two drawn side by side and
5559
+ // the weighted one was chosen, so do not "restore" the even split to match
5560
+ // the original mock.
5561
+ number_expiry_row: {
5562
+ elements: SPLIT,
5563
+ rows: [["cardNumber", "expiry"], ["cvc"]],
5564
+ weights: { cardNumber: 3, expiry: 2 },
5565
+ labels: true,
5566
+ density: "default"
5567
+ },
5568
+ // Split geometry at reduced density and type size, for a checkout embedded
5569
+ // in a page that already has its own chrome.
5570
+ compact: {
5571
+ elements: SPLIT,
5572
+ rows: [["cardNumber"], ["expiry", "cvc"]],
5573
+ labels: false,
5574
+ density: "compact"
5575
+ }
5576
+ };
5577
+ var AIRWALLEX_CARD_PRESET_FALLBACK = "split_fields_labelled";
5578
+ function resolveAirwallexCardPreset(fromBranding, fromConnector) {
5579
+ return asPreset(fromBranding) ?? asPreset(fromConnector) ?? AIRWALLEX_CARD_PRESET_FALLBACK;
5580
+ }
5581
+ function asAirwallexCardPreset(value) {
5582
+ return asPreset(value);
5583
+ }
5584
+ function asPreset(value) {
5585
+ if (typeof value !== "string") return null;
5586
+ const trimmed = value.trim().toLowerCase();
5587
+ return AIRWALLEX_CARD_PRESETS.includes(trimmed) ? trimmed : null;
5588
+ }
5589
+ function airwallexCardLayout(preset) {
5590
+ return AIRWALLEX_CARD_LAYOUTS[preset];
5591
+ }
5592
+ function airwallexCellWeight(layout, field) {
5593
+ const weight = layout.weights?.[field];
5594
+ return typeof weight === "number" && Number.isFinite(weight) && weight > 0 ? weight : 1;
5595
+ }
5596
+ function airwallexCardLayoutIsCoherent(layout) {
5597
+ const drawn = layout.rows.flat();
5598
+ if (drawn.length !== layout.elements.length) return false;
5599
+ return layout.elements.every((field) => drawn.filter((f) => f === field).length === 1);
5600
+ }
5601
+ var AIRWALLEX_LABEL_STYLES = ["above", "inline", "floating", "none"];
5602
+ function resolveAirwallexLabelStyle(override, layout) {
5603
+ if (typeof override === "string" && AIRWALLEX_LABEL_STYLES.includes(override)) {
5604
+ return override;
5605
+ }
5606
+ return layout.labels ? "above" : "none";
5607
+ }
5608
+ var AIRWALLEX_FIELD_CHROMES = ["outlined", "filled", "underline"];
5609
+ var AIRWALLEX_FOCUS_RINGS = ["none", "subtle", "strong"];
5610
+ var AIRWALLEX_AUTOFILL_TREATMENTS = ["system", "brand", "neutral"];
5611
+ var AIRWALLEX_FIELD_FONT_SIZES = ["sm", "md", "lg"];
5612
+ var AIRWALLEX_FIELD_WEIGHTS = ["regular", "medium", "semibold"];
5613
+ function airwallexFieldFontPx(size, density) {
5614
+ const base = size === "sm" ? 14 : size === "lg" ? 18 : 16;
5615
+ return density === "compact" ? Math.max(13, base - 1) : base;
5616
+ }
5617
+ function airwallexFieldWeightValue(weight) {
5618
+ return weight === "regular" ? 400 : weight === "semibold" ? 600 : 500;
5619
+ }
5620
+ var AIRWALLEX_NETWORK_MARKS = ["visa", "mastercard", "amex", "discover"];
5621
+
5490
5622
  // src/branding.ts
5491
5623
  function surchargeShowsLabel(labelMode, style, position) {
5492
5624
  if (labelMode !== "labelled") return false;
@@ -6022,6 +6154,25 @@ var DEFAULT_BRANDING_BASE = {
6022
6154
  paymentLayout: "tabs",
6023
6155
  labelStyle: "above",
6024
6156
  showPoweredBy: true,
6157
+ // Every one of these defaults to what the Airwallex pane already did before
6158
+ // the section existed, so a merchant who never opens it sees no change:
6159
+ // empty preset (defer to the connector account), an outlined box, 16px /
6160
+ // 500 type, no focus ring, the browser's own autofill highlight, no valid
6161
+ // tint, no marks. The single deliberate change of behaviour is not here —
6162
+ // it is the fallback at the END of `resolveAirwallexCardPreset`, which
6163
+ // moves a shop that configured NOTHING from the combined row to the
6164
+ // labelled split form.
6165
+ airwallexCardPreset: "",
6166
+ // Off. With this on, no buyer can pay by card on the shop.
6167
+ airwallexHideCard: false,
6168
+ airwallexFieldChrome: "outlined",
6169
+ airwallexLabelStyle: "",
6170
+ airwallexFieldFontSize: "md",
6171
+ airwallexFieldWeight: "medium",
6172
+ airwallexFocusRing: "none",
6173
+ airwallexAutofill: "system",
6174
+ airwallexValidTint: false,
6175
+ airwallexNetworkMarks: false,
6025
6176
  customCss: ""
6026
6177
  };
6027
6178
  var DEFAULT_BRANDING = {
@@ -6131,6 +6282,10 @@ function pickEnum(value, allowed, fallback) {
6131
6282
  if (typeof value !== "string") return fallback;
6132
6283
  return allowed.includes(value) ? value : fallback;
6133
6284
  }
6285
+ function pickEnumOrEmpty(value, allowed) {
6286
+ if (typeof value !== "string") return "";
6287
+ return allowed.includes(value) ? value : "";
6288
+ }
6134
6289
  function parseBool(value, fallback) {
6135
6290
  if (typeof value === "boolean") return value;
6136
6291
  if (value === "true") return true;
@@ -6701,6 +6856,53 @@ function decodeBranding(source) {
6701
6856
  ),
6702
6857
  labelStyle,
6703
6858
  showPoweredBy: source.branding_visibility !== false,
6859
+ // The two that can be empty use `pickEnumOrEmpty`, not `pickEnum`: a
6860
+ // value this build does not know has to decode to "unset" and defer, the
6861
+ // same as a key that was never written. Sending it to a concrete default
6862
+ // instead would make an older checkout override the connector account of
6863
+ // a merchant who picked a preset a newer dashboard offers.
6864
+ airwallexCardPreset: pickEnumOrEmpty(
6865
+ extras["airwallexCardPreset"],
6866
+ AIRWALLEX_CARD_PRESETS
6867
+ ),
6868
+ airwallexHideCard: parseBool(extras["airwallexHideCard"], DEFAULT_BRANDING.airwallexHideCard),
6869
+ airwallexFieldChrome: pickEnum(
6870
+ extras["airwallexFieldChrome"],
6871
+ AIRWALLEX_FIELD_CHROMES,
6872
+ DEFAULT_BRANDING.airwallexFieldChrome
6873
+ ),
6874
+ airwallexLabelStyle: pickEnumOrEmpty(
6875
+ extras["airwallexLabelStyle"],
6876
+ AIRWALLEX_LABEL_STYLES
6877
+ ),
6878
+ airwallexFieldFontSize: pickEnum(
6879
+ extras["airwallexFieldFontSize"],
6880
+ AIRWALLEX_FIELD_FONT_SIZES,
6881
+ DEFAULT_BRANDING.airwallexFieldFontSize
6882
+ ),
6883
+ airwallexFieldWeight: pickEnum(
6884
+ extras["airwallexFieldWeight"],
6885
+ AIRWALLEX_FIELD_WEIGHTS,
6886
+ DEFAULT_BRANDING.airwallexFieldWeight
6887
+ ),
6888
+ airwallexFocusRing: pickEnum(
6889
+ extras["airwallexFocusRing"],
6890
+ AIRWALLEX_FOCUS_RINGS,
6891
+ DEFAULT_BRANDING.airwallexFocusRing
6892
+ ),
6893
+ airwallexAutofill: pickEnum(
6894
+ extras["airwallexAutofill"],
6895
+ AIRWALLEX_AUTOFILL_TREATMENTS,
6896
+ DEFAULT_BRANDING.airwallexAutofill
6897
+ ),
6898
+ airwallexValidTint: parseBool(
6899
+ extras["airwallexValidTint"],
6900
+ DEFAULT_BRANDING.airwallexValidTint
6901
+ ),
6902
+ airwallexNetworkMarks: parseBool(
6903
+ extras["airwallexNetworkMarks"],
6904
+ DEFAULT_BRANDING.airwallexNetworkMarks
6905
+ ),
6704
6906
  customCss: s(extras["customCss"])
6705
6907
  };
6706
6908
  }
@@ -6756,6 +6958,21 @@ function encodeBranding(branding, base) {
6756
6958
  logoShape: branding.logoShape,
6757
6959
  logoSize: branding.logoSize,
6758
6960
  labelStyle: branding.labelStyle,
6961
+ // Written unconditionally, empty string included. The encoder REPLACES
6962
+ // `sdk_ui_rules.branding` wholesale, so a key it skips is a key it
6963
+ // deletes — and here the empty string is a real value ("no choice made"),
6964
+ // not an absence. Omitting it would be indistinguishable from omitting it
6965
+ // by accident, which is how `summaryOrder` was lost.
6966
+ airwallexCardPreset: branding.airwallexCardPreset,
6967
+ airwallexHideCard: String(branding.airwallexHideCard),
6968
+ airwallexFieldChrome: branding.airwallexFieldChrome,
6969
+ airwallexLabelStyle: branding.airwallexLabelStyle,
6970
+ airwallexFieldFontSize: branding.airwallexFieldFontSize,
6971
+ airwallexFieldWeight: branding.airwallexFieldWeight,
6972
+ airwallexFocusRing: branding.airwallexFocusRing,
6973
+ airwallexAutofill: branding.airwallexAutofill,
6974
+ airwallexValidTint: String(branding.airwallexValidTint),
6975
+ airwallexNetworkMarks: String(branding.airwallexNetworkMarks),
6759
6976
  trustBadges: encodeBadges(branding.trustBadges),
6760
6977
  [METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
6761
6978
  };
@@ -6983,6 +7200,47 @@ function parseImportedBranding(raw) {
6983
7200
  ),
6984
7201
  labelStyle,
6985
7202
  showPoweredBy: parseBool(root["showPoweredBy"], dflt.showPoweredBy),
7203
+ // An imported profile that predates this section carries none of these
7204
+ // and lands on the defaults — which is to say on "defer", so importing an
7205
+ // old export into a shop does not take that shop's connector setting
7206
+ // away. The one field that would be dangerous to import loosely is the
7207
+ // hide switch, and `parseBool` only says true for a literal `true`.
7208
+ airwallexCardPreset: pickEnumOrEmpty(
7209
+ root["airwallexCardPreset"],
7210
+ AIRWALLEX_CARD_PRESETS
7211
+ ),
7212
+ airwallexHideCard: parseBool(root["airwallexHideCard"], dflt.airwallexHideCard),
7213
+ airwallexFieldChrome: pickEnum(
7214
+ root["airwallexFieldChrome"],
7215
+ AIRWALLEX_FIELD_CHROMES,
7216
+ dflt.airwallexFieldChrome
7217
+ ),
7218
+ airwallexLabelStyle: pickEnumOrEmpty(
7219
+ root["airwallexLabelStyle"],
7220
+ AIRWALLEX_LABEL_STYLES
7221
+ ),
7222
+ airwallexFieldFontSize: pickEnum(
7223
+ root["airwallexFieldFontSize"],
7224
+ AIRWALLEX_FIELD_FONT_SIZES,
7225
+ dflt.airwallexFieldFontSize
7226
+ ),
7227
+ airwallexFieldWeight: pickEnum(
7228
+ root["airwallexFieldWeight"],
7229
+ AIRWALLEX_FIELD_WEIGHTS,
7230
+ dflt.airwallexFieldWeight
7231
+ ),
7232
+ airwallexFocusRing: pickEnum(
7233
+ root["airwallexFocusRing"],
7234
+ AIRWALLEX_FOCUS_RINGS,
7235
+ dflt.airwallexFocusRing
7236
+ ),
7237
+ airwallexAutofill: pickEnum(
7238
+ root["airwallexAutofill"],
7239
+ AIRWALLEX_AUTOFILL_TREATMENTS,
7240
+ dflt.airwallexAutofill
7241
+ ),
7242
+ airwallexValidTint: parseBool(root["airwallexValidTint"], dflt.airwallexValidTint),
7243
+ airwallexNetworkMarks: parseBool(root["airwallexNetworkMarks"], dflt.airwallexNetworkMarks),
6986
7244
  customCss: sStr(root["customCss"], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH)
6987
7245
  };
6988
7246
  }
@@ -7821,6 +8079,16 @@ var decodeNativePanes = decodePanes;
7821
8079
  var encodeNativePanes = encodePanes;
7822
8080
  // Annotate the CommonJS export names for ESM import in node:
7823
8081
  0 && (module.exports = {
8082
+ AIRWALLEX_AUTOFILL_TREATMENTS,
8083
+ AIRWALLEX_CARD_LAYOUTS,
8084
+ AIRWALLEX_CARD_PRESETS,
8085
+ AIRWALLEX_CARD_PRESET_FALLBACK,
8086
+ AIRWALLEX_FIELD_CHROMES,
8087
+ AIRWALLEX_FIELD_FONT_SIZES,
8088
+ AIRWALLEX_FIELD_WEIGHTS,
8089
+ AIRWALLEX_FOCUS_RINGS,
8090
+ AIRWALLEX_LABEL_STYLES,
8091
+ AIRWALLEX_NETWORK_MARKS,
7824
8092
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
7825
8093
  ALL_CUSTOM_FIELD_OPERATORS,
7826
8094
  ALL_CUSTOM_FIELD_TYPES,
@@ -7891,9 +8159,15 @@ var encodeNativePanes = encodePanes;
7891
8159
  WCAG_AA_TEXT,
7892
8160
  WCAG_AA_UI,
7893
8161
  Webhooks,
8162
+ airwallexCardLayout,
8163
+ airwallexCardLayoutIsCoherent,
8164
+ airwallexCellWeight,
8165
+ airwallexFieldFontPx,
8166
+ airwallexFieldWeightValue,
7894
8167
  allOf,
7895
8168
  anyOf,
7896
8169
  applyBrandingVariables,
8170
+ asAirwallexCardPreset,
7897
8171
  buildBrandingExport,
7898
8172
  buttonPadValue,
7899
8173
  canonicalSectionId,
@@ -7957,6 +8231,8 @@ var encodeNativePanes = encodePanes;
7957
8231
  programToTree,
7958
8232
  radiusValue,
7959
8233
  readableInkOn,
8234
+ resolveAirwallexCardPreset,
8235
+ resolveAirwallexLabelStyle,
7960
8236
  ruleMatchToTree,
7961
8237
  sanitizeCustomCss,
7962
8238
  sectionLabel,