@funnelfox/billing 0.9.0 → 0.9.3-feat-defer-session-on-interaction.34
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/chunk-index.cjs.js +388 -43
- package/dist/chunk-index.cjs2.js +0 -6
- package/dist/chunk-index.cjs3.js +2 -37
- package/dist/chunk-index.es.js +389 -43
- package/dist/chunk-index.es2.js +0 -6
- package/dist/chunk-index.es3.js +2 -37
- package/dist/chunk-stripe-card-form.cjs.js +37 -101
- package/dist/chunk-stripe-card-form.es.js +37 -101
- package/dist/funnelfox-billing.esm.js +1 -1
- package/dist/funnelfox-billing.js +426 -183
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +52 -4
|
@@ -327,20 +327,6 @@
|
|
|
327
327
|
/**
|
|
328
328
|
* @fileoverview Helper utilities for Funnefox SDK
|
|
329
329
|
*/
|
|
330
|
-
function formatCurrencyAmount(minorAmount, currency) {
|
|
331
|
-
const code = currency?.trim().toUpperCase() || 'USD';
|
|
332
|
-
try {
|
|
333
|
-
const formatter = new Intl.NumberFormat(undefined, {
|
|
334
|
-
style: 'currency',
|
|
335
|
-
currency: code,
|
|
336
|
-
});
|
|
337
|
-
const fractionDigits = formatter.resolvedOptions().maximumFractionDigits ?? 2;
|
|
338
|
-
return formatter.format(minorAmount / 10 ** fractionDigits);
|
|
339
|
-
}
|
|
340
|
-
catch {
|
|
341
|
-
return `${(minorAmount / 100).toFixed(2)} ${code}`;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
330
|
function merge(...objects) {
|
|
345
331
|
const result = {};
|
|
346
332
|
for (const obj of objects) {
|
|
@@ -509,7 +495,7 @@
|
|
|
509
495
|
/**
|
|
510
496
|
* @fileoverview Constants for Funnefox SDK
|
|
511
497
|
*/
|
|
512
|
-
const SDK_VERSION = '0.9.
|
|
498
|
+
const SDK_VERSION = '0.9.3-feat-defer-session-on-interaction.34';
|
|
513
499
|
const DEFAULTS = {
|
|
514
500
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
515
501
|
REGION: 'default',
|
|
@@ -646,6 +632,141 @@
|
|
|
646
632
|
return true;
|
|
647
633
|
}
|
|
648
634
|
|
|
635
|
+
/**
|
|
636
|
+
* @fileoverview Support for Apple's official <apple-pay-button> custom element.
|
|
637
|
+
*
|
|
638
|
+
* Primer's checkout-web v2 renders the Apple Pay button through the CSS
|
|
639
|
+
* approach (-webkit-appearance: -apple-pay-button), and WebKit only accepts
|
|
640
|
+
* the 7 legacy values for -apple-pay-button-type. Newer types such as
|
|
641
|
+
* 'continue' are silently dropped and fall back to 'plain' (verified in
|
|
642
|
+
* Safari 26 on macOS and iOS — see PRD-1426).
|
|
643
|
+
*
|
|
644
|
+
* Apple's official custom element supports the full set of button types, so
|
|
645
|
+
* for "native-only" types we overlay it on top of the (visually hidden)
|
|
646
|
+
* Primer button and forward clicks, keeping Primer's payment flow untouched.
|
|
647
|
+
*/
|
|
648
|
+
const APPLE_PAY_SDK_URL = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';
|
|
649
|
+
/** How long to wait for the <apple-pay-button> element definition before
|
|
650
|
+
* giving up and falling back to Primer's own button. */
|
|
651
|
+
const ELEMENT_DEFINITION_TIMEOUT_MS = 4000;
|
|
652
|
+
/**
|
|
653
|
+
* Button types WebKit can render through Primer's CSS approach.
|
|
654
|
+
* Everything outside this list requires the native <apple-pay-button> element.
|
|
655
|
+
*/
|
|
656
|
+
const CSS_RENDERABLE_APPLE_PAY_TYPES = [
|
|
657
|
+
'plain',
|
|
658
|
+
'buy',
|
|
659
|
+
'set-up',
|
|
660
|
+
'donate',
|
|
661
|
+
'check-out',
|
|
662
|
+
'book',
|
|
663
|
+
'subscribe',
|
|
664
|
+
];
|
|
665
|
+
/**
|
|
666
|
+
* Returns true when the requested Apple Pay buttonType can only be rendered
|
|
667
|
+
* with Apple's native <apple-pay-button> element.
|
|
668
|
+
*/
|
|
669
|
+
function isNativeOnlyApplePayButtonType(type) {
|
|
670
|
+
return !!type && !CSS_RENDERABLE_APPLE_PAY_TYPES.includes(type);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Loads Apple's apple-pay-sdk.js (defines the <apple-pay-button> custom
|
|
674
|
+
* element). Resolves to true when the element is available.
|
|
675
|
+
*/
|
|
676
|
+
async function loadApplePayButtonElement() {
|
|
677
|
+
if (typeof window === 'undefined' || !window.customElements) {
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
if (window.customElements.get('apple-pay-button')) {
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
try {
|
|
684
|
+
await loadScript$1({
|
|
685
|
+
src: APPLE_PAY_SDK_URL,
|
|
686
|
+
crossOrigin: 'anonymous',
|
|
687
|
+
appendTo: 'head',
|
|
688
|
+
});
|
|
689
|
+
// Never hang on a script that loaded but did not define the element —
|
|
690
|
+
// fall back to Primer's own button instead.
|
|
691
|
+
const defined = window.customElements
|
|
692
|
+
.whenDefined('apple-pay-button')
|
|
693
|
+
.then(() => true);
|
|
694
|
+
const timeout = new Promise(resolve => {
|
|
695
|
+
setTimeout(() => resolve(false), ELEMENT_DEFINITION_TIMEOUT_MS);
|
|
696
|
+
});
|
|
697
|
+
return await Promise.race([defined, timeout]);
|
|
698
|
+
}
|
|
699
|
+
catch {
|
|
700
|
+
return false;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function createNativeApplePayElement(options) {
|
|
704
|
+
const native = document.createElement('apple-pay-button');
|
|
705
|
+
native.setAttribute('type', options.buttonType);
|
|
706
|
+
native.setAttribute('buttonstyle', options.buttonStyle || 'black');
|
|
707
|
+
native.setAttribute('locale', (typeof navigator !== 'undefined' && navigator.language) || 'en-US');
|
|
708
|
+
native.style.cssText = [
|
|
709
|
+
'position:absolute',
|
|
710
|
+
'inset:0',
|
|
711
|
+
'width:100%',
|
|
712
|
+
'height:100%',
|
|
713
|
+
'--apple-pay-button-width:100%',
|
|
714
|
+
'--apple-pay-button-height:100%',
|
|
715
|
+
'--apple-pay-button-border-radius:28px',
|
|
716
|
+
'display:block',
|
|
717
|
+
'cursor:pointer',
|
|
718
|
+
'z-index:1',
|
|
719
|
+
].join(';');
|
|
720
|
+
return native;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Renders Apple's native <apple-pay-button> stretched over `wrapper` and
|
|
724
|
+
* forwards clicks to the Primer-rendered <button> inside it. The synchronous
|
|
725
|
+
* forwarded click preserves the user activation required by ApplePaySession.
|
|
726
|
+
*
|
|
727
|
+
* Returns the overlay element, or null when the Apple Pay SDK could not be
|
|
728
|
+
* loaded (callers should keep Primer's own button visible as a fallback).
|
|
729
|
+
*/
|
|
730
|
+
async function overlayNativeApplePayButton(wrapper, options) {
|
|
731
|
+
const available = await loadApplePayButtonElement();
|
|
732
|
+
if (!available) {
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
// The overlay is only safe when Primer's own clickable button is present —
|
|
736
|
+
// otherwise there is nothing to forward the click to.
|
|
737
|
+
if (!wrapper.querySelector('button')) {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
const native = createNativeApplePayElement(options);
|
|
741
|
+
wrapper.style.position = 'relative';
|
|
742
|
+
native.addEventListener('click', () => {
|
|
743
|
+
const primerButton = wrapper.querySelector('button');
|
|
744
|
+
primerButton?.click();
|
|
745
|
+
});
|
|
746
|
+
wrapper.appendChild(native);
|
|
747
|
+
return native;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Renders the native button with no Primer button behind it, for the deferred
|
|
751
|
+
* flow: the visitor sees the real Apple Pay button immediately while the
|
|
752
|
+
* client session is still un-created. `onActivate` fires on tap so the caller
|
|
753
|
+
* can start (or await) initialization.
|
|
754
|
+
*
|
|
755
|
+
* Returns null when Apple's SDK is unavailable — callers must fall back to
|
|
756
|
+
* creating the session eagerly so a button of some kind is always rendered.
|
|
757
|
+
*/
|
|
758
|
+
async function renderPlaceholderApplePayButton(wrapper, options) {
|
|
759
|
+
const available = await loadApplePayButtonElement();
|
|
760
|
+
if (!available) {
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
const native = createNativeApplePayElement(options);
|
|
764
|
+
wrapper.style.position = 'relative';
|
|
765
|
+
native.addEventListener('click', options.onActivate);
|
|
766
|
+
wrapper.appendChild(native);
|
|
767
|
+
return native;
|
|
768
|
+
}
|
|
769
|
+
|
|
649
770
|
/**
|
|
650
771
|
* @fileoverview Primer SDK integration wrapper
|
|
651
772
|
*/
|
|
@@ -684,6 +805,7 @@
|
|
|
684
805
|
}
|
|
685
806
|
async createHeadlessCheckout(clientToken, options, method) {
|
|
686
807
|
await this.ensurePrimerLoaded();
|
|
808
|
+
this.applePayOptions = options.applePay;
|
|
687
809
|
this.currentHeadless = PrimerWrapper.headlessManager.getOrCreate(clientToken, options, method);
|
|
688
810
|
return this.currentHeadless;
|
|
689
811
|
}
|
|
@@ -730,16 +852,53 @@
|
|
|
730
852
|
}
|
|
731
853
|
htmlNode.appendChild(wrapper);
|
|
732
854
|
/* end hack */
|
|
855
|
+
/* PRD-1426: WebKit cannot render newer Apple Pay button types (e.g.
|
|
856
|
+
* 'continue') through the CSS approach Primer v2 uses. For those types
|
|
857
|
+
* we overlay Apple's official <apple-pay-button> element on top of the
|
|
858
|
+
* visually hidden Primer button and forward clicks, keeping Primer's
|
|
859
|
+
* payment flow untouched. The Primer button is hidden BEFORE it renders
|
|
860
|
+
* to avoid a flash of the plain button; if the Apple SDK fails to load,
|
|
861
|
+
* the rule is removed and Primer's own button stays visible (graceful
|
|
862
|
+
* fallback to 'plain'). */
|
|
863
|
+
const applePayConfig = this.applePayOptions;
|
|
864
|
+
const nativeButtonType = allowedPaymentMethod === exports.PaymentMethod.APPLE_PAY &&
|
|
865
|
+
applePayConfig?.buttonType &&
|
|
866
|
+
isNativeOnlyApplePayButtonType(applePayConfig.buttonType)
|
|
867
|
+
? applePayConfig.buttonType
|
|
868
|
+
: null;
|
|
869
|
+
let hideRuleIndex = null;
|
|
870
|
+
if (nativeButtonType && sheet) {
|
|
871
|
+
hideRuleIndex = sheet.insertRule(`
|
|
872
|
+
.${wrapper.className} > button {
|
|
873
|
+
opacity: 0 !important;
|
|
874
|
+
}
|
|
875
|
+
`);
|
|
876
|
+
}
|
|
733
877
|
button = pmManager.createButton();
|
|
734
878
|
await button.render(wrapper, {});
|
|
879
|
+
let nativeOverlay = null;
|
|
880
|
+
if (nativeButtonType) {
|
|
881
|
+
nativeOverlay = await overlayNativeApplePayButton(wrapper, {
|
|
882
|
+
buttonType: nativeButtonType,
|
|
883
|
+
buttonStyle: applePayConfig?.buttonStyle,
|
|
884
|
+
});
|
|
885
|
+
if (!nativeOverlay && sheet && hideRuleIndex !== null) {
|
|
886
|
+
sheet.deleteRule(hideRuleIndex);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
735
889
|
this.destroyCallbacks.push(() => button.clean());
|
|
736
890
|
onMethodRender(allowedPaymentMethod);
|
|
737
891
|
return {
|
|
738
892
|
setDisabled: (disabled) => {
|
|
739
893
|
button.setDisabled(disabled);
|
|
894
|
+
if (nativeOverlay) {
|
|
895
|
+
nativeOverlay.style.pointerEvents = disabled ? 'none' : '';
|
|
896
|
+
nativeOverlay.style.opacity = disabled ? '0.5' : '';
|
|
897
|
+
}
|
|
740
898
|
},
|
|
741
899
|
destroy: () => {
|
|
742
900
|
styleEl.remove();
|
|
901
|
+
nativeOverlay?.remove();
|
|
743
902
|
button.clean();
|
|
744
903
|
},
|
|
745
904
|
};
|
|
@@ -1086,6 +1245,32 @@
|
|
|
1086
1245
|
}
|
|
1087
1246
|
PrimerWrapper.headlessManager = new HeadlessManager();
|
|
1088
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* @fileoverview Tags the deferred session request so the warm-up trigger can
|
|
1250
|
+
* be measured without adding a single extra network call.
|
|
1251
|
+
*
|
|
1252
|
+
* The backend already logs every request header, so `X-FF-Warmup` lands in
|
|
1253
|
+
* Elasticsearch for free. That gives us, per session actually created:
|
|
1254
|
+
* - which signal started it (dwell vs interaction vs a cold tap)
|
|
1255
|
+
* - how long after mount it fired
|
|
1256
|
+
*
|
|
1257
|
+
* Which is what tells us whether the dwell can be lengthened (more savings)
|
|
1258
|
+
* or must stay short (cold-tap risk), instead of guessing at an interaction
|
|
1259
|
+
* rate nobody has measured.
|
|
1260
|
+
*/
|
|
1261
|
+
const WARMUP_HEADER = 'X-FF-Warmup';
|
|
1262
|
+
let pendingTag = null;
|
|
1263
|
+
/** Records the trigger for the session request that is about to be sent. */
|
|
1264
|
+
function setWarmupTag(trigger, msSinceMount) {
|
|
1265
|
+
pendingTag = `${trigger};${Math.max(0, Math.round(msSinceMount))}`;
|
|
1266
|
+
}
|
|
1267
|
+
/** Consumes the tag — it describes one request only. */
|
|
1268
|
+
function takeWarmupTag() {
|
|
1269
|
+
const tag = pendingTag;
|
|
1270
|
+
pendingTag = null;
|
|
1271
|
+
return tag;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1089
1274
|
/**
|
|
1090
1275
|
* @fileoverview API client for Funnefox backend integration
|
|
1091
1276
|
*/
|
|
@@ -1103,6 +1288,7 @@
|
|
|
1103
1288
|
headers: {
|
|
1104
1289
|
'Content-Type': 'application/json',
|
|
1105
1290
|
'X-SDK-Version': SDK_VERSION,
|
|
1291
|
+
...warmupHeader(),
|
|
1106
1292
|
...(options.headers || {}),
|
|
1107
1293
|
},
|
|
1108
1294
|
...options,
|
|
@@ -1317,6 +1503,10 @@
|
|
|
1317
1503
|
}));
|
|
1318
1504
|
}
|
|
1319
1505
|
}
|
|
1506
|
+
function warmupHeader() {
|
|
1507
|
+
const tag = takeWarmupTag();
|
|
1508
|
+
return tag ? { [WARMUP_HEADER]: tag } : {};
|
|
1509
|
+
}
|
|
1320
1510
|
|
|
1321
1511
|
class SessionService {
|
|
1322
1512
|
constructor() {
|
|
@@ -1399,6 +1589,96 @@
|
|
|
1399
1589
|
}
|
|
1400
1590
|
};
|
|
1401
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* @fileoverview Decides when a deferred client session should be created.
|
|
1594
|
+
*
|
|
1595
|
+
* Fires on whichever comes first: the visitor's first interaction, or a short
|
|
1596
|
+
* dwell once the page is actually visible. The dwell is what makes the
|
|
1597
|
+
* deferral safe — ApplePaySession must be constructed inside the tap gesture,
|
|
1598
|
+
* so the session has to exist *before* the first tap. A human cannot read a
|
|
1599
|
+
* price and tap in under ~800ms, whereas prerenders, background tabs, crawlers
|
|
1600
|
+
* and instant bounces never reach the dwell at all and so never cost a
|
|
1601
|
+
* session (nor the order row behind it).
|
|
1602
|
+
*/
|
|
1603
|
+
const INTERACTION_EVENTS = [
|
|
1604
|
+
'pointerdown',
|
|
1605
|
+
'touchstart',
|
|
1606
|
+
'keydown',
|
|
1607
|
+
'wheel',
|
|
1608
|
+
'scroll',
|
|
1609
|
+
];
|
|
1610
|
+
/** Long enough to filter prerenders and instant bounces, far shorter than
|
|
1611
|
+
* any realistic time-to-tap on a paywall. */
|
|
1612
|
+
const DEFAULT_WARMUP_DWELL_MS = 800;
|
|
1613
|
+
/** True while the page is prerendering or not visible to the user. */
|
|
1614
|
+
function isPageHidden() {
|
|
1615
|
+
if (typeof document === 'undefined') {
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
if (document.prerendering) {
|
|
1619
|
+
return true;
|
|
1620
|
+
}
|
|
1621
|
+
return document.visibilityState === 'hidden';
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Invokes `handler` once — on first interaction, or after `dwellMs` of visible
|
|
1625
|
+
* time, whichever happens first. Returns a cleanup for the un-fired case.
|
|
1626
|
+
*/
|
|
1627
|
+
function onSessionWarmup(handler, dwellMs = DEFAULT_WARMUP_DWELL_MS) {
|
|
1628
|
+
if (typeof document === 'undefined') {
|
|
1629
|
+
return () => { };
|
|
1630
|
+
}
|
|
1631
|
+
let fired = false;
|
|
1632
|
+
let timer;
|
|
1633
|
+
const cleanup = () => {
|
|
1634
|
+
if (timer !== undefined) {
|
|
1635
|
+
clearTimeout(timer);
|
|
1636
|
+
timer = undefined;
|
|
1637
|
+
}
|
|
1638
|
+
for (const event of INTERACTION_EVENTS) {
|
|
1639
|
+
document.removeEventListener(event, onInteraction, true);
|
|
1640
|
+
}
|
|
1641
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
1642
|
+
document.removeEventListener('prerenderingchange', onVisibilityChange);
|
|
1643
|
+
};
|
|
1644
|
+
const fire = (source) => {
|
|
1645
|
+
if (fired) {
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
fired = true;
|
|
1649
|
+
cleanup();
|
|
1650
|
+
handler(source);
|
|
1651
|
+
};
|
|
1652
|
+
function onInteraction() {
|
|
1653
|
+
if (!isPageHidden()) {
|
|
1654
|
+
fire('interaction');
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
function startDwell() {
|
|
1658
|
+
if (fired || timer !== undefined) {
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
timer = setTimeout(() => fire('dwell'), dwellMs);
|
|
1662
|
+
}
|
|
1663
|
+
function onVisibilityChange() {
|
|
1664
|
+
if (!isPageHidden()) {
|
|
1665
|
+
startDwell();
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
for (const event of INTERACTION_EVENTS) {
|
|
1669
|
+
document.addEventListener(event, onInteraction, {
|
|
1670
|
+
capture: true,
|
|
1671
|
+
passive: true,
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
1675
|
+
document.addEventListener('prerenderingchange', onVisibilityChange);
|
|
1676
|
+
if (!isPageHidden()) {
|
|
1677
|
+
startDwell();
|
|
1678
|
+
}
|
|
1679
|
+
return cleanup;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1402
1682
|
var V3_URL = 'https://js.stripe.com/v3';
|
|
1403
1683
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
1404
1684
|
var EXISTING_SCRIPT_MESSAGE = 'loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used';
|
|
@@ -1899,14 +2179,6 @@
|
|
|
1899
2179
|
this.emitTaxInfo(info);
|
|
1900
2180
|
}
|
|
1901
2181
|
};
|
|
1902
|
-
// Re-render the current tax figures to a skin that subscribed after the estimate was first
|
|
1903
|
-
// emitted (the initMethod card path wires the skin only once the method mounts).
|
|
1904
|
-
this.renderTaxToSkin = () => {
|
|
1905
|
-
const info = this.lastTaxInfo ?? this.getSessionTaxInfo();
|
|
1906
|
-
if (info) {
|
|
1907
|
-
this.emit(EVENTS.TAX_CHANGE, info);
|
|
1908
|
-
}
|
|
1909
|
-
};
|
|
1910
2182
|
this.runTaxRecalc = async () => {
|
|
1911
2183
|
const orderId = this.orderId;
|
|
1912
2184
|
const countryCode = this.getSelectedCountryCode();
|
|
@@ -1963,11 +2235,6 @@
|
|
|
1963
2235
|
this.handleMethodRender = (method) => {
|
|
1964
2236
|
this.emit(EVENTS.METHOD_RENDER, method);
|
|
1965
2237
|
};
|
|
1966
|
-
this.handleTaxMethodRender = (method) => {
|
|
1967
|
-
if (method === exports.PaymentMethod.PAYMENT_CARD && this.isTaxEnabled()) {
|
|
1968
|
-
this.renderTaxToSkin();
|
|
1969
|
-
}
|
|
1970
|
-
};
|
|
1971
2238
|
this.handleMethodRenderError = (method) => {
|
|
1972
2239
|
this.emit(EVENTS.METHOD_RENDER_ERROR, method);
|
|
1973
2240
|
};
|
|
@@ -2540,13 +2807,6 @@
|
|
|
2540
2807
|
const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
|
|
2541
2808
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
2542
2809
|
this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
|
|
2543
|
-
if (skin.onTaxChange) {
|
|
2544
|
-
this.on(EVENTS.TAX_CHANGE, skin.onTaxChange);
|
|
2545
|
-
}
|
|
2546
|
-
if (skin.onTaxPending) {
|
|
2547
|
-
this.on(EVENTS.TAX_PENDING, skin.onTaxPending);
|
|
2548
|
-
}
|
|
2549
|
-
this.on(EVENTS.METHOD_RENDER, this.handleTaxMethodRender);
|
|
2550
2810
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
2551
2811
|
this.on(EVENTS.LOADER_CHANGE, skin.onLoaderChange);
|
|
2552
2812
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
@@ -2564,13 +2824,6 @@
|
|
|
2564
2824
|
skin.init();
|
|
2565
2825
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
2566
2826
|
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
2567
|
-
if (skin.onTaxChange) {
|
|
2568
|
-
this.on(EVENTS.TAX_CHANGE, skin.onTaxChange);
|
|
2569
|
-
}
|
|
2570
|
-
if (skin.onTaxPending) {
|
|
2571
|
-
this.on(EVENTS.TAX_PENDING, skin.onTaxPending);
|
|
2572
|
-
}
|
|
2573
|
-
this.on(EVENTS.METHOD_RENDER, this.handleTaxMethodRender);
|
|
2574
2827
|
this.on(EVENTS.SUCCESS, skin.onDestroy);
|
|
2575
2828
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
2576
2829
|
return skin.getCheckoutOptions();
|
|
@@ -2583,6 +2836,98 @@
|
|
|
2583
2836
|
}
|
|
2584
2837
|
async initMethod(method, element, callbacks) {
|
|
2585
2838
|
this._ensureNotDestroyed();
|
|
2839
|
+
const deferred = await this.initMethodDeferred(method, element, callbacks);
|
|
2840
|
+
if (deferred) {
|
|
2841
|
+
return deferred;
|
|
2842
|
+
}
|
|
2843
|
+
return await this.initMethodNow(method, element, callbacks);
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Renders Apple's native button immediately and postpones session creation
|
|
2847
|
+
* until the visitor interacts. Returns null when deferral does not apply, so
|
|
2848
|
+
* the caller falls back to creating the session on mount.
|
|
2849
|
+
*/
|
|
2850
|
+
async initMethodDeferred(method, element, callbacks) {
|
|
2851
|
+
const applePay = this.checkoutConfig.applePay;
|
|
2852
|
+
const buttonType = applePay?.buttonType;
|
|
2853
|
+
if (this.checkoutConfig.sessionCreation !== 'onInteraction' ||
|
|
2854
|
+
method !== exports.PaymentMethod.APPLE_PAY ||
|
|
2855
|
+
this.isReady() ||
|
|
2856
|
+
!buttonType ||
|
|
2857
|
+
!isNativeOnlyApplePayButtonType(buttonType)) {
|
|
2858
|
+
return null;
|
|
2859
|
+
}
|
|
2860
|
+
let started = null;
|
|
2861
|
+
let real = null;
|
|
2862
|
+
let disabled = false;
|
|
2863
|
+
let stopWaiting = () => { };
|
|
2864
|
+
let placeholder = null;
|
|
2865
|
+
const mountedAt = Date.now();
|
|
2866
|
+
const start = (trigger) => {
|
|
2867
|
+
const fromTap = trigger === 'tap';
|
|
2868
|
+
if (!started) {
|
|
2869
|
+
setWarmupTag(trigger, Date.now() - mountedAt);
|
|
2870
|
+
started = (async () => {
|
|
2871
|
+
stopWaiting();
|
|
2872
|
+
if (fromTap) {
|
|
2873
|
+
callbacks.onLoaderChange?.(true);
|
|
2874
|
+
}
|
|
2875
|
+
try {
|
|
2876
|
+
placeholder?.remove();
|
|
2877
|
+
placeholder = null;
|
|
2878
|
+
const methodInterface = await this.initMethodNow(method, element, callbacks);
|
|
2879
|
+
real = methodInterface;
|
|
2880
|
+
if (disabled) {
|
|
2881
|
+
methodInterface.setDisabled(true);
|
|
2882
|
+
}
|
|
2883
|
+
return methodInterface;
|
|
2884
|
+
}
|
|
2885
|
+
finally {
|
|
2886
|
+
if (fromTap) {
|
|
2887
|
+
callbacks.onLoaderChange?.(false);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
})();
|
|
2891
|
+
}
|
|
2892
|
+
return started;
|
|
2893
|
+
};
|
|
2894
|
+
placeholder = await renderPlaceholderApplePayButton(element, {
|
|
2895
|
+
buttonType,
|
|
2896
|
+
buttonStyle: applePay?.buttonStyle,
|
|
2897
|
+
// Cold tap: the visitor's first interaction is the button itself, so the
|
|
2898
|
+
// session cannot exist yet and ApplePaySession would lose the gesture.
|
|
2899
|
+
// Start now and let the loader cover the (rare) second tap.
|
|
2900
|
+
onActivate: () => void start('tap'),
|
|
2901
|
+
});
|
|
2902
|
+
if (!placeholder) {
|
|
2903
|
+
return null;
|
|
2904
|
+
}
|
|
2905
|
+
// Free head start: Primer's SDK is a static asset on their CDN, so
|
|
2906
|
+
// fetching it now costs no backend call and leaves only the session
|
|
2907
|
+
// request to complete before the first tap.
|
|
2908
|
+
void loadPrimerSDK().catch(() => { });
|
|
2909
|
+
stopWaiting = onSessionWarmup(trigger => void start(trigger));
|
|
2910
|
+
return {
|
|
2911
|
+
setDisabled: (value) => {
|
|
2912
|
+
disabled = value;
|
|
2913
|
+
real?.setDisabled(value);
|
|
2914
|
+
if (placeholder) {
|
|
2915
|
+
placeholder.style.pointerEvents = value ? 'none' : '';
|
|
2916
|
+
placeholder.style.opacity = value ? '0.5' : '';
|
|
2917
|
+
}
|
|
2918
|
+
},
|
|
2919
|
+
destroy: async () => {
|
|
2920
|
+
stopWaiting();
|
|
2921
|
+
placeholder?.remove();
|
|
2922
|
+
placeholder = null;
|
|
2923
|
+
if (started) {
|
|
2924
|
+
await (await started).destroy?.();
|
|
2925
|
+
}
|
|
2926
|
+
await this.destroy();
|
|
2927
|
+
},
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
async initMethodNow(method, element, callbacks) {
|
|
2586
2931
|
if (!this.isReady()) {
|
|
2587
2932
|
await this.createSession();
|
|
2588
2933
|
}
|
|
@@ -2800,6 +3145,7 @@
|
|
|
2800
3145
|
...DEFAULT_BUTTONS_OPTIONS[exports.PaymentMethod.GOOGLE_PAY],
|
|
2801
3146
|
...(options.googlePay || {}),
|
|
2802
3147
|
},
|
|
3148
|
+
sessionCreation: options.sessionCreation,
|
|
2803
3149
|
},
|
|
2804
3150
|
});
|
|
2805
3151
|
return await checkoutInstance.initMethod(method, element, {
|
|
@@ -2988,9 +3334,9 @@
|
|
|
2988
3334
|
|
|
2989
3335
|
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="/* Main container */\n.ff-skin-default {\n display: flex;\n flex-direction: column;\n text-align: left;\n gap: 8px;\n width: 100%;\n max-width: 400px;\n margin: 0 auto;\n color: #000000;\n}\n\n/* Payment method cards */\n.ff-payment-method-card {\n display: none;\n border: 1px solid #e0e0e0;\n border-radius: 8px;\n background-color: #ffffff;\n padding: 20px;\n transition: border-color 0.2s ease;\n height: auto;\n box-shadow: 0px 0px 10px 0px #eee;\n}\n\n.ff-payment-method-card.visible {\n display: block;\n}\n\n.payment-errors-container {\n background-color: #d1000033;\n color: #d10000;\n font-size: 14px;\n padding: 16px 12px;\n border-radius: 8px;\n}\n.payment-errors-container:empty {\n display: none;\n}\n\n/* Label wrapper */\n.ff-payment-method-label {\n display: flex;\n align-items: flex-start;\n gap: 16px;\n cursor: pointer;\n width: 100%;\n}\n\n.ff-google-pay-header {\n align-items: center;\n}\n\n/* Custom radio button styling */\n.ff-payment-method-radio {\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n width: 24px;\n height: 24px;\n min-width: 24px;\n min-height: 24px;\n border: 1px solid #9e9e9e;\n border-radius: 50%;\n background-color: #ffffff;\n cursor: pointer;\n position: relative;\n margin: 0;\n flex-shrink: 0;\n transition: border-color 0.2s ease;\n}\n\n.ff-card-form-submit-button {\n display: block;\n cursor: pointer;\n width: 100%;\n padding: 16px 0;\n border-radius: 16px;\n background-color: #000000;\n color: #ffffff;\n border: none;\n font-size: 16px;\n margin: 12px 0 16px;\n}\n\n.ff-payment-method-radio:checked {\n border-color: #e32f41;\n background-color: #ffffff;\n}\n\n.ff-payment-method-radio:checked::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 16px;\n height: 16px;\n border-radius: 50%;\n background-color: #e32f41;\n}\n\n/* Payment method content */\n.ff-payment-method-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 16px;\n max-height: 0;\n height: 0;\n overflow: hidden;\n opacity: 0;\n transition:\n opacity 0.3s ease,\n margin-top 0.3s ease;\n margin-top: 0;\n}\n\n.ff-payment-method-card.expanded .ff-payment-method-content {\n max-height: 2000px;\n height: auto;\n opacity: 1;\n margin-top: 16px;\n}\n.ff-payment-method-card.expanded .ff-payment-method-label {\n margin-bottom: 16px;\n}\n\n/* Payment method header */\n.ff-payment-method-header {\n display: flex;\n align-items: center;\n}\n\n/* Google Pay Logo */\n.ff-google-pay-logo {\n display: flex;\n align-items: center;\n gap: 4px;\n font-weight: 500;\n font-size: 18px;\n}\n.ff-google-pay-logo img {\n height: 38px;\n}\n\n/* Payment features list */\n.ff-payment-features {\n list-style: none;\n padding: 0;\n margin: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.ff-payment-feature {\n display: flex;\n align-items: baseline;\n text-align: left;\n gap: 8px;\n}\n\n.ff-checkmark-icon {\n width: 20px;\n height: 20px;\n min-width: 20px;\n color: #e32f41;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n.ff-payment-feature span {\n color: #333333;\n font-size: 14px;\n line-height: 1.5;\n}\n\n/* Google Pay button container */\n.ff-google-pay-button-container {\n display: flex;\n justify-content: center;\n}\n\n/* Security message */\n.ff-security-message {\n text-align: center;\n color: #999999;\n font-size: 14px;\n padding: 0;\n margin: 0\n}\n\n/* Card logos container */\n.ff-card-logos {\n display: flex;\n align-items: center;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n/* Card form container */\n.ff-card-form-container {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.loader-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: rgba(255, 255, 255);\n z-index: 2;\n}\n\n.payment-button-loader {\n position: relative;\n height: 50px;\n}\n\n.loader {\n width: 24px;\n height: 24px;\n border: 4px solid #e32f41;\n border-top: 4px solid transparent;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n/* Responsive adjustments */\n@media (max-width: 768px) {\n .ff-payment-method-card {\n padding: 16px;\n }\n\n .ff-payment-method-label {\n gap: 12px;\n }\n\n .ff-card-logos {\n gap: 8px;\n }\n}\n\n.ff-payment-container {\n position: relative;\n}\n\n.success {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 16px;\n}\n";
|
|
2990
3336
|
|
|
2991
|
-
var template = "<div>\n <label class=\"ff-card-form-label\" for=\"cardNumberInput\">Card number</label>\n <div id=\"cardNumberInput\"></div>\n <div class=\"errorContainer\"></div>\n</div>\n<div class=\"card-form-row\">\n <div>\n <label class=\"ff-card-form-label\" for=\"expiryInput\">Expiration date</label>\n <div id=\"expiryInput\"></div>\n <div class=\"errorContainer\"></div>\n </div>\n <div>\n <label class=\"ff-card-form-label\" for=\"cvvInput\">Security code</label>\n <div id=\"cvvInput\">\n <svg width=\"200\" height=\"200\" viewBox=\"0 0 200 200\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect width=\"200\" height=\"200\" fill=\"transparent\"/>\n <g clip-path=\"url(#clip0_0_1)\">\n <path d=\"M157.555 23C168.279 23.0002 177 31.7394 177 42.4854V80.5889C171.946 72.0151 164.749 64.8558 156.146 59.8457H166.394V42.4854C166.393 37.6004 162.43 33.6291 157.555 33.6289H27.4453C22.5704 33.6291 18.6066 37.6004 18.6064 42.4854V59.8457H97.8535C88.9153 65.0512 81.4954 72.5771 76.4189 81.5986H18.6064V127.515C18.6066 132.4 22.5704 136.371 27.4453 136.371H75.3281C77.2742 140.177 79.6285 143.739 82.333 147H27.4453C16.7215 147 8.00019 138.261 8 127.515V42.4854C8.0002 31.7394 16.7215 23.0002 27.4453 23H157.555Z\" fill=\"#93939A\"/>\n <mask id=\"path-2-outside-1_0_1\" maskUnits=\"userSpaceOnUse\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\" fill=\"black\">\n <rect fill=\"white\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\"/>\n </mask>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" fill=\"#93939A\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" stroke=\"transparent\" stroke-width=\"20\" mask=\"url(#path-2-outside-1_0_1)\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_0_1\">\n <rect width=\"200\" height=\"200\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n <div class=\"errorContainer\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Cardholder name</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" type=\"text\" pattern=\"[A-Za-z\\s]+\" placeholder=\"Full name on card\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"emailAddressInput\">Email</label>\n <input class=\"ff-card-form-text-input\" id=\"emailAddressInput\" placeholder=\"Email\" type=\"email\">\n <div class=\"errorContainer\"></div>\n</div>\n<div id=\"countrySelectorField\">\n <label class=\"ff-card-form-label\" for=\"countrySelectorInput\">Country</label>\n <div class=\"ff-select-wrap\">\n <select class=\"ff-card-form-text-input ff-card-form-select\" id=\"countrySelectorInput\"></select>\n <div class=\"ff-select-arrow\" aria-hidden=\"true\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"postalCodeInput\">Zip code</label>\n <input class=\"ff-card-form-text-input\" id=\"postalCodeInput\" placeholder=\"12345\">\n <div class=\"errorContainer\"></div>\n</div>\n<div id=\"ffTaxSummary\" class=\"ff-tax-summary\" hidden>\n <div class=\"ff-tax-row\">\n <span>Subtotal</span>\n <span id=\"ffTaxSubtotal\"></span>\n </div>\n <div class=\"ff-tax-row\">\n <span>Tax</span>\n <span id=\"ffTaxAmount\"></span>\n </div>\n <div class=\"ff-tax-row ff-tax-total\">\n <span>Total</span>\n <span id=\"ffTaxTotal\"></span>\n </div>\n</div>\n";
|
|
3337
|
+
var template = "<div>\n <label class=\"ff-card-form-label\" for=\"cardNumberInput\">Card number</label>\n <div id=\"cardNumberInput\"></div>\n <div class=\"errorContainer\"></div>\n</div>\n<div class=\"card-form-row\">\n <div>\n <label class=\"ff-card-form-label\" for=\"expiryInput\">Expiration date</label>\n <div id=\"expiryInput\"></div>\n <div class=\"errorContainer\"></div>\n </div>\n <div>\n <label class=\"ff-card-form-label\" for=\"cvvInput\">Security code</label>\n <div id=\"cvvInput\">\n <svg width=\"200\" height=\"200\" viewBox=\"0 0 200 200\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect width=\"200\" height=\"200\" fill=\"transparent\"/>\n <g clip-path=\"url(#clip0_0_1)\">\n <path d=\"M157.555 23C168.279 23.0002 177 31.7394 177 42.4854V80.5889C171.946 72.0151 164.749 64.8558 156.146 59.8457H166.394V42.4854C166.393 37.6004 162.43 33.6291 157.555 33.6289H27.4453C22.5704 33.6291 18.6066 37.6004 18.6064 42.4854V59.8457H97.8535C88.9153 65.0512 81.4954 72.5771 76.4189 81.5986H18.6064V127.515C18.6066 132.4 22.5704 136.371 27.4453 136.371H75.3281C77.2742 140.177 79.6285 143.739 82.333 147H27.4453C16.7215 147 8.00019 138.261 8 127.515V42.4854C8.0002 31.7394 16.7215 23.0002 27.4453 23H157.555Z\" fill=\"#93939A\"/>\n <mask id=\"path-2-outside-1_0_1\" maskUnits=\"userSpaceOnUse\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\" fill=\"black\">\n <rect fill=\"white\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\"/>\n </mask>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" fill=\"#93939A\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" stroke=\"transparent\" stroke-width=\"20\" mask=\"url(#path-2-outside-1_0_1)\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_0_1\">\n <rect width=\"200\" height=\"200\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n <div class=\"errorContainer\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Cardholder name</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" type=\"text\" pattern=\"[A-Za-z\\s]+\" placeholder=\"Full name on card\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"emailAddressInput\">Email</label>\n <input class=\"ff-card-form-text-input\" id=\"emailAddressInput\" placeholder=\"Email\" type=\"email\">\n <div class=\"errorContainer\"></div>\n</div>\n<div id=\"countrySelectorField\">\n <label class=\"ff-card-form-label\" for=\"countrySelectorInput\">Country</label>\n <div class=\"ff-select-wrap\">\n <select class=\"ff-card-form-text-input ff-card-form-select\" id=\"countrySelectorInput\"></select>\n <div class=\"ff-select-arrow\" aria-hidden=\"true\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"postalCodeInput\">Zip code</label>\n <input class=\"ff-card-form-text-input\" id=\"postalCodeInput\" placeholder=\"12345\">\n <div class=\"errorContainer\"></div>\n</div>\n";
|
|
2992
3338
|
|
|
2993
|
-
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="\n\n.ff-card-form-label {\n display: block;\n font-size: 16px;\n margin-bottom: 5px;\n }\n \n .card-form-row {\n display: flex;\n flex-direction: row;\n gap: 10px;\n }\n \n .ff-card-form-text-input {\n margin: 0 0 3px;\n padding-left: 10px;\n padding-right: 10px;\n box-sizing: border-box;\n height: 36px;\n width: 100%;\n font-size: 1rem;\n background-color: transparent;\n border: 1px solid rgb(0 0 0 / 10%);\n border-radius: 6px;\n transition: all 0.3s ease;\n box-shadow: none;\n outline: none;\n }\n .ff-card-form-text-input.error {\n border-color: #e32f41;\n }\n\n.ff-select-wrap {\n position: relative;\n}\n\n.ff-card-form-select {\n padding-right: 34px;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n background-image: none;\n}\n\n.ff-card-form-select::-ms-expand {\n display: none;\n}\n\n.ff-card-form-select:disabled {\n color: #6b7280;\n cursor: not-allowed;\n}\n\n.ff-select-arrow {\n position: absolute;\n top: 50%;\n right: 12px;\n width: 8px;\n height: 8px;\n border-right: 1.5px solid #6b7280;\n border-bottom: 1.5px solid #6b7280;\n transform: translateY(-65%) rotate(45deg);\n pointer-events: none;\n}\n\n.ff-select-wrap:focus-within .ff-select-arrow {\n border-right-color: #111827;\n border-bottom-color: #111827;\n}\n \n .errorContainer:not(:empty) {\n color: #d10000;\n font-size: 16px;\n line-height: 1;\n margin: 0 0 10px;\n }\n\n #cvvInput {\n position: relative;\n }\n\n #cvvInput > svg {\n z-index: 1;\n position: absolute;\n top: 5px;\n right: 5px;\n width: 26px;\n height: 26px;\n }\n
|
|
3339
|
+
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="\n\n.ff-card-form-label {\n display: block;\n font-size: 16px;\n margin-bottom: 5px;\n }\n \n .card-form-row {\n display: flex;\n flex-direction: row;\n gap: 10px;\n }\n \n .ff-card-form-text-input {\n margin: 0 0 3px;\n padding-left: 10px;\n padding-right: 10px;\n box-sizing: border-box;\n height: 36px;\n width: 100%;\n font-size: 1rem;\n background-color: transparent;\n border: 1px solid rgb(0 0 0 / 10%);\n border-radius: 6px;\n transition: all 0.3s ease;\n box-shadow: none;\n outline: none;\n }\n .ff-card-form-text-input.error {\n border-color: #e32f41;\n }\n\n.ff-select-wrap {\n position: relative;\n}\n\n.ff-card-form-select {\n padding-right: 34px;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n background-image: none;\n}\n\n.ff-card-form-select::-ms-expand {\n display: none;\n}\n\n.ff-card-form-select:disabled {\n color: #6b7280;\n cursor: not-allowed;\n}\n\n.ff-select-arrow {\n position: absolute;\n top: 50%;\n right: 12px;\n width: 8px;\n height: 8px;\n border-right: 1.5px solid #6b7280;\n border-bottom: 1.5px solid #6b7280;\n transform: translateY(-65%) rotate(45deg);\n pointer-events: none;\n}\n\n.ff-select-wrap:focus-within .ff-select-arrow {\n border-right-color: #111827;\n border-bottom-color: #111827;\n}\n \n .errorContainer:not(:empty) {\n color: #d10000;\n font-size: 16px;\n line-height: 1;\n margin: 0 0 10px;\n }\n\n #cvvInput {\n position: relative;\n }\n\n #cvvInput > svg {\n z-index: 1;\n position: absolute;\n top: 5px;\n right: 5px;\n width: 26px;\n height: 26px;\n }\n";
|
|
2994
3340
|
|
|
2995
3341
|
class CardSkin {
|
|
2996
3342
|
constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
|
|
@@ -3025,39 +3371,6 @@
|
|
|
3025
3371
|
}
|
|
3026
3372
|
}
|
|
3027
3373
|
};
|
|
3028
|
-
this.onTaxChange = (info) => {
|
|
3029
|
-
const summary = this.containerEl.querySelector('#ffTaxSummary');
|
|
3030
|
-
if (!summary) {
|
|
3031
|
-
return;
|
|
3032
|
-
}
|
|
3033
|
-
// taxAmount is the tax added on top of the price; it is 0 for tax-inclusive pricing and for
|
|
3034
|
-
// non-taxed locations — in both cases there is nothing to itemise, so the summary stays hidden.
|
|
3035
|
-
if (!(info.taxAmount > 0)) {
|
|
3036
|
-
summary.hidden = true;
|
|
3037
|
-
summary.classList.remove('ff-tax-summary--updating');
|
|
3038
|
-
return;
|
|
3039
|
-
}
|
|
3040
|
-
const subtotal = this.containerEl.querySelector('#ffTaxSubtotal');
|
|
3041
|
-
const tax = this.containerEl.querySelector('#ffTaxAmount');
|
|
3042
|
-
const total = this.containerEl.querySelector('#ffTaxTotal');
|
|
3043
|
-
if (subtotal) {
|
|
3044
|
-
subtotal.textContent = formatCurrencyAmount(info.amountTotal - info.taxAmount, info.currency);
|
|
3045
|
-
}
|
|
3046
|
-
if (tax) {
|
|
3047
|
-
tax.textContent = formatCurrencyAmount(info.taxAmount, info.currency);
|
|
3048
|
-
}
|
|
3049
|
-
if (total) {
|
|
3050
|
-
total.textContent = formatCurrencyAmount(info.amountTotal, info.currency);
|
|
3051
|
-
}
|
|
3052
|
-
summary.hidden = false;
|
|
3053
|
-
summary.classList.remove('ff-tax-summary--updating');
|
|
3054
|
-
};
|
|
3055
|
-
this.onTaxPending = () => {
|
|
3056
|
-
const summary = this.containerEl.querySelector('#ffTaxSummary');
|
|
3057
|
-
if (summary && !summary.hidden) {
|
|
3058
|
-
summary.classList.add('ff-tax-summary--updating');
|
|
3059
|
-
}
|
|
3060
|
-
};
|
|
3061
3374
|
this.onMethodRender = () => {
|
|
3062
3375
|
this.containerEl.style.display = 'block';
|
|
3063
3376
|
};
|
|
@@ -3281,12 +3594,6 @@
|
|
|
3281
3594
|
this.onInputError = (event) => {
|
|
3282
3595
|
this.cardInstance.onInputError(event);
|
|
3283
3596
|
};
|
|
3284
|
-
this.onTaxChange = (info) => {
|
|
3285
|
-
this.cardInstance.onTaxChange(info);
|
|
3286
|
-
};
|
|
3287
|
-
this.onTaxPending = () => {
|
|
3288
|
-
this.cardInstance.onTaxPending();
|
|
3289
|
-
};
|
|
3290
3597
|
this.onMethodRender = (paymentMethod) => {
|
|
3291
3598
|
const methodKey = paymentMethod.replace('_', '-').toLowerCase();
|
|
3292
3599
|
const methodContainer = this.containerEl.querySelector(`.ff-payment-method-${methodKey}`);
|
|
@@ -3421,68 +3728,7 @@
|
|
|
3421
3728
|
return cache.get(publicKey);
|
|
3422
3729
|
}
|
|
3423
3730
|
|
|
3424
|
-
const TAX_STYLE_ID = 'ff-stripe-tax-styles';
|
|
3425
3731
|
const TAX_RECALC_DEBOUNCE_MS = 600;
|
|
3426
|
-
// The Stripe card form renders Stripe Elements (not the card skin), so it owns its own subtotal/tax/
|
|
3427
|
-
// total summary here — mirroring the hosted card skin so every integration shows tax consistently
|
|
3428
|
-
// without the host page reimplementing it.
|
|
3429
|
-
function injectTaxStyles() {
|
|
3430
|
-
if (typeof document === 'undefined')
|
|
3431
|
-
return;
|
|
3432
|
-
if (document.getElementById(TAX_STYLE_ID))
|
|
3433
|
-
return;
|
|
3434
|
-
const style = document.createElement('style');
|
|
3435
|
-
style.id = TAX_STYLE_ID;
|
|
3436
|
-
style.textContent = [
|
|
3437
|
-
'.ff-tax-summary{margin-top:12px;padding-top:12px;border-top:1px solid rgb(0 0 0 / 10%);font-size:16px;transition:opacity .2s ease}',
|
|
3438
|
-
'.ff-tax-summary[hidden]{display:none}',
|
|
3439
|
-
'.ff-tax-summary--updating{opacity:.55}',
|
|
3440
|
-
'.ff-tax-row{display:flex;justify-content:space-between;gap:10px;margin-bottom:6px}',
|
|
3441
|
-
'.ff-tax-row.ff-tax-total{margin-top:8px;margin-bottom:0;font-weight:600}',
|
|
3442
|
-
].join('\n');
|
|
3443
|
-
document.head.appendChild(style);
|
|
3444
|
-
}
|
|
3445
|
-
function createTaxSummary() {
|
|
3446
|
-
const root = document.createElement('div');
|
|
3447
|
-
root.className = 'ff-tax-summary';
|
|
3448
|
-
root.hidden = true;
|
|
3449
|
-
const makeRow = (label, isTotal = false) => {
|
|
3450
|
-
const rowEl = document.createElement('div');
|
|
3451
|
-
rowEl.className = isTotal ? 'ff-tax-row ff-tax-total' : 'ff-tax-row';
|
|
3452
|
-
const labelEl = document.createElement('span');
|
|
3453
|
-
labelEl.textContent = label;
|
|
3454
|
-
const valueEl = document.createElement('span');
|
|
3455
|
-
rowEl.append(labelEl, valueEl);
|
|
3456
|
-
root.appendChild(rowEl);
|
|
3457
|
-
return valueEl;
|
|
3458
|
-
};
|
|
3459
|
-
const subtotalEl = makeRow('Subtotal');
|
|
3460
|
-
const taxEl = makeRow('Tax');
|
|
3461
|
-
const totalEl = makeRow('Total', true);
|
|
3462
|
-
return {
|
|
3463
|
-
root,
|
|
3464
|
-
// taxAmount is the tax added on top of the price; it is 0 for tax-inclusive pricing and for
|
|
3465
|
-
// non-taxed locations — in both cases there is nothing to itemise, so the summary stays hidden.
|
|
3466
|
-
render(info) {
|
|
3467
|
-
root.classList.remove('ff-tax-summary--updating');
|
|
3468
|
-
if (!info || !(info.taxAmount > 0)) {
|
|
3469
|
-
root.hidden = true;
|
|
3470
|
-
return;
|
|
3471
|
-
}
|
|
3472
|
-
subtotalEl.textContent = formatCurrencyAmount(info.amountTotal - info.taxAmount, info.currency);
|
|
3473
|
-
taxEl.textContent = formatCurrencyAmount(info.taxAmount, info.currency);
|
|
3474
|
-
totalEl.textContent = formatCurrencyAmount(info.amountTotal, info.currency);
|
|
3475
|
-
root.hidden = false;
|
|
3476
|
-
},
|
|
3477
|
-
setPending() {
|
|
3478
|
-
if (!root.hidden)
|
|
3479
|
-
root.classList.add('ff-tax-summary--updating');
|
|
3480
|
-
},
|
|
3481
|
-
setIdle() {
|
|
3482
|
-
root.classList.remove('ff-tax-summary--updating');
|
|
3483
|
-
},
|
|
3484
|
-
};
|
|
3485
|
-
}
|
|
3486
3732
|
async function mountStripeCardForm(element, session, params) {
|
|
3487
3733
|
const { stripe_public_key, amount, currency, order_id, is_link_enabled, tax_amount, amount_total, } = session.data;
|
|
3488
3734
|
// Tax flow is driven by the tenant setting (session.tax_enabled); enableTax is a legacy override.
|
|
@@ -3492,8 +3738,6 @@
|
|
|
3492
3738
|
throw new Error('Failed to load Stripe');
|
|
3493
3739
|
// Remounting (e.g. picking another price) must replace the form, not stack a second one.
|
|
3494
3740
|
element.replaceChildren();
|
|
3495
|
-
injectTaxStyles();
|
|
3496
|
-
const taxSummary = createTaxSummary();
|
|
3497
3741
|
const stripeElements = stripe.elements({
|
|
3498
3742
|
mode: 'subscription',
|
|
3499
3743
|
amount,
|
|
@@ -3516,21 +3760,22 @@
|
|
|
3516
3760
|
terms: { card: 'never' },
|
|
3517
3761
|
fields: {
|
|
3518
3762
|
billingDetails: {
|
|
3519
|
-
//
|
|
3520
|
-
//
|
|
3521
|
-
address
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
: 'auto',
|
|
3763
|
+
// Field visibility is owned by the org settings (Taxes → Settings) and is independent of
|
|
3764
|
+
// whether tax is enabled: show the country selector and/or postal code only when configured,
|
|
3765
|
+
// and always hide the rest of the address (supplied to createPaymentMethod below). Previously
|
|
3766
|
+
// the untaxed path fell back to Stripe's default billing (country + postal), showing those
|
|
3767
|
+
// fields even when the org had turned them off.
|
|
3768
|
+
address: {
|
|
3769
|
+
line1: 'never',
|
|
3770
|
+
line2: 'never',
|
|
3771
|
+
city: 'never',
|
|
3772
|
+
state: 'never',
|
|
3773
|
+
country: showCountry ? 'auto' : 'never',
|
|
3774
|
+
postalCode: showPostal ? 'auto' : 'never',
|
|
3775
|
+
},
|
|
3531
3776
|
},
|
|
3532
3777
|
},
|
|
3533
|
-
...(session.data.detected_country_code &&
|
|
3778
|
+
...(session.data.detected_country_code && showCountry
|
|
3534
3779
|
? {
|
|
3535
3780
|
defaultValues: {
|
|
3536
3781
|
billingDetails: {
|
|
@@ -3541,16 +3786,16 @@
|
|
|
3541
3786
|
: {}),
|
|
3542
3787
|
});
|
|
3543
3788
|
// Address fields we hid (fields=never) must still be supplied to createPaymentMethod. Only country +
|
|
3544
|
-
// postal matter for tax; country is
|
|
3545
|
-
// no location at all.
|
|
3789
|
+
// postal matter for tax; country is supplied when its selector is off, postal when its field is off.
|
|
3546
3790
|
const hiddenBillingAddress = { line1: '', line2: '', city: '', state: '' };
|
|
3547
3791
|
if (!showCountry)
|
|
3548
3792
|
hiddenBillingAddress.country = session.data.detected_country_code ?? '';
|
|
3549
|
-
if (!
|
|
3793
|
+
if (!showPostal)
|
|
3550
3794
|
hiddenBillingAddress.postal_code = '';
|
|
3551
|
-
// Tax needs only the country + postal code. When the org collects location on the form we read it
|
|
3552
|
-
// the Payment Element's change events as the buyer types
|
|
3553
|
-
// calculation id to the charge. When it does not, tax follows the
|
|
3795
|
+
// Tax needs only the country + postal code. When the org collects location on the form we read it
|
|
3796
|
+
// from the Payment Element's change events as the buyer types, recalculate tax live (reported via
|
|
3797
|
+
// onTaxChange), and attach the calculation id to the charge. When it does not, tax follows the
|
|
3798
|
+
// IP-derived session estimate.
|
|
3554
3799
|
let taxCalc;
|
|
3555
3800
|
let recalcSeq = 0;
|
|
3556
3801
|
if (taxEnabled && session.data.tax_calculation_id) {
|
|
@@ -3566,7 +3811,6 @@
|
|
|
3566
3811
|
const country = taxAddress.country;
|
|
3567
3812
|
const postal = taxAddress.postalCode;
|
|
3568
3813
|
if (!country) {
|
|
3569
|
-
taxSummary.setIdle();
|
|
3570
3814
|
return;
|
|
3571
3815
|
}
|
|
3572
3816
|
const seq = ++recalcSeq;
|
|
@@ -3580,13 +3824,11 @@
|
|
|
3580
3824
|
if (seq !== recalcSeq)
|
|
3581
3825
|
return; // a newer recalc superseded this one
|
|
3582
3826
|
taxCalc = { id: tax.tax_calculation_id, country, postal };
|
|
3583
|
-
|
|
3827
|
+
params.onTaxChange?.({
|
|
3584
3828
|
amountTotal: tax.amount_total,
|
|
3585
3829
|
taxAmount: tax.tax_amount,
|
|
3586
3830
|
currency: tax.currency,
|
|
3587
|
-
};
|
|
3588
|
-
taxSummary.render(info);
|
|
3589
|
-
params.onTaxChange?.(info);
|
|
3831
|
+
});
|
|
3590
3832
|
}
|
|
3591
3833
|
catch (err) {
|
|
3592
3834
|
if (seq !== recalcSeq)
|
|
@@ -3595,7 +3837,6 @@
|
|
|
3595
3837
|
taxCalc = undefined;
|
|
3596
3838
|
params.onTaxError?.(err);
|
|
3597
3839
|
}
|
|
3598
|
-
taxSummary.setIdle();
|
|
3599
3840
|
}
|
|
3600
3841
|
};
|
|
3601
3842
|
paymentElement.mount(element);
|
|
@@ -3620,19 +3861,21 @@
|
|
|
3620
3861
|
};
|
|
3621
3862
|
if (!taxAddress.country)
|
|
3622
3863
|
return;
|
|
3623
|
-
taxSummary.setPending();
|
|
3624
3864
|
if (debounce)
|
|
3625
3865
|
clearTimeout(debounce);
|
|
3626
3866
|
debounce = setTimeout(runRecalc, TAX_RECALC_DEBOUNCE_MS);
|
|
3627
3867
|
});
|
|
3628
3868
|
}
|
|
3629
|
-
//
|
|
3630
|
-
//
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3869
|
+
// The form renders no tax lines; the host re-renders its own prices off onTaxChange. Report the
|
|
3870
|
+
// session estimate as the first calculation, then (when the org collects location) refine it
|
|
3871
|
+
// against the pre-filled country right away — later address edits keep firing it via the recalc.
|
|
3872
|
+
if (taxEnabled && amount_total != null) {
|
|
3873
|
+
params.onTaxChange?.({
|
|
3874
|
+
amountTotal: amount_total,
|
|
3875
|
+
taxAmount: tax_amount ?? 0,
|
|
3876
|
+
currency,
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3636
3879
|
if (taxEnabled && collectLocation)
|
|
3637
3880
|
void runRecalc();
|
|
3638
3881
|
await new Promise((resolve, reject) => {
|
|
@@ -3654,10 +3897,10 @@
|
|
|
3654
3897
|
const { error, paymentMethod } = await stripe.createPaymentMethod({
|
|
3655
3898
|
elements: stripeElements,
|
|
3656
3899
|
// Supply the address fields we hid on the Payment Element (fields=never); Stripe requires
|
|
3657
|
-
// them here.
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3900
|
+
// them here. We always hide line1/line2/city/state (and country/postal per the org
|
|
3901
|
+
// settings), so these must be supplied regardless of tax mode. Country/postal shown on the
|
|
3902
|
+
// element are filled by Stripe automatically.
|
|
3903
|
+
params: { billing_details: { address: hiddenBillingAddress } },
|
|
3661
3904
|
});
|
|
3662
3905
|
if (error)
|
|
3663
3906
|
throw error;
|