@funnelfox/billing 0.9.0 → 0.9.3-ffb-apple-pay-continue-button.33
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 +150 -43
- package/dist/chunk-index.cjs2.js +0 -6
- package/dist/chunk-index.cjs3.js +2 -37
- package/dist/chunk-index.es.js +151 -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 +188 -183
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +38 -3
package/dist/chunk-index.es.js
CHANGED
|
@@ -321,20 +321,6 @@ async function loadPrimerSDK(version) {
|
|
|
321
321
|
/**
|
|
322
322
|
* @fileoverview Helper utilities for Funnefox SDK
|
|
323
323
|
*/
|
|
324
|
-
function formatCurrencyAmount(minorAmount, currency) {
|
|
325
|
-
const code = currency?.trim().toUpperCase() || 'USD';
|
|
326
|
-
try {
|
|
327
|
-
const formatter = new Intl.NumberFormat(undefined, {
|
|
328
|
-
style: 'currency',
|
|
329
|
-
currency: code,
|
|
330
|
-
});
|
|
331
|
-
const fractionDigits = formatter.resolvedOptions().maximumFractionDigits ?? 2;
|
|
332
|
-
return formatter.format(minorAmount / 10 ** fractionDigits);
|
|
333
|
-
}
|
|
334
|
-
catch {
|
|
335
|
-
return `${(minorAmount / 100).toFixed(2)} ${code}`;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
324
|
function merge(...objects) {
|
|
339
325
|
const result = {};
|
|
340
326
|
for (const obj of objects) {
|
|
@@ -503,7 +489,7 @@ var PaymentMethod;
|
|
|
503
489
|
/**
|
|
504
490
|
* @fileoverview Constants for Funnefox SDK
|
|
505
491
|
*/
|
|
506
|
-
const SDK_VERSION = '0.9.
|
|
492
|
+
const SDK_VERSION = '0.9.3-ffb-apple-pay-continue-button.33';
|
|
507
493
|
const DEFAULTS = {
|
|
508
494
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
509
495
|
REGION: 'default',
|
|
@@ -640,6 +626,117 @@ function requireString(value, fieldName) {
|
|
|
640
626
|
return true;
|
|
641
627
|
}
|
|
642
628
|
|
|
629
|
+
/**
|
|
630
|
+
* @fileoverview Support for Apple's official <apple-pay-button> custom element.
|
|
631
|
+
*
|
|
632
|
+
* Primer's checkout-web v2 renders the Apple Pay button through the CSS
|
|
633
|
+
* approach (-webkit-appearance: -apple-pay-button), and WebKit only accepts
|
|
634
|
+
* the 7 legacy values for -apple-pay-button-type. Newer types such as
|
|
635
|
+
* 'continue' are silently dropped and fall back to 'plain' (verified in
|
|
636
|
+
* Safari 26 on macOS and iOS — see PRD-1426).
|
|
637
|
+
*
|
|
638
|
+
* Apple's official custom element supports the full set of button types, so
|
|
639
|
+
* for "native-only" types we overlay it on top of the (visually hidden)
|
|
640
|
+
* Primer button and forward clicks, keeping Primer's payment flow untouched.
|
|
641
|
+
*/
|
|
642
|
+
const APPLE_PAY_SDK_URL = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';
|
|
643
|
+
/** How long to wait for the <apple-pay-button> element definition before
|
|
644
|
+
* giving up and falling back to Primer's own button. */
|
|
645
|
+
const ELEMENT_DEFINITION_TIMEOUT_MS = 4000;
|
|
646
|
+
/**
|
|
647
|
+
* Button types WebKit can render through Primer's CSS approach.
|
|
648
|
+
* Everything outside this list requires the native <apple-pay-button> element.
|
|
649
|
+
*/
|
|
650
|
+
const CSS_RENDERABLE_APPLE_PAY_TYPES = [
|
|
651
|
+
'plain',
|
|
652
|
+
'buy',
|
|
653
|
+
'set-up',
|
|
654
|
+
'donate',
|
|
655
|
+
'check-out',
|
|
656
|
+
'book',
|
|
657
|
+
'subscribe',
|
|
658
|
+
];
|
|
659
|
+
/**
|
|
660
|
+
* Returns true when the requested Apple Pay buttonType can only be rendered
|
|
661
|
+
* with Apple's native <apple-pay-button> element.
|
|
662
|
+
*/
|
|
663
|
+
function isNativeOnlyApplePayButtonType(type) {
|
|
664
|
+
return !!type && !CSS_RENDERABLE_APPLE_PAY_TYPES.includes(type);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Loads Apple's apple-pay-sdk.js (defines the <apple-pay-button> custom
|
|
668
|
+
* element). Resolves to true when the element is available.
|
|
669
|
+
*/
|
|
670
|
+
async function loadApplePayButtonElement() {
|
|
671
|
+
if (typeof window === 'undefined' || !window.customElements) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
if (window.customElements.get('apple-pay-button')) {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
try {
|
|
678
|
+
await loadScript$1({
|
|
679
|
+
src: APPLE_PAY_SDK_URL,
|
|
680
|
+
crossOrigin: 'anonymous',
|
|
681
|
+
appendTo: 'head',
|
|
682
|
+
});
|
|
683
|
+
// Never hang on a script that loaded but did not define the element —
|
|
684
|
+
// fall back to Primer's own button instead.
|
|
685
|
+
const defined = window.customElements
|
|
686
|
+
.whenDefined('apple-pay-button')
|
|
687
|
+
.then(() => true);
|
|
688
|
+
const timeout = new Promise(resolve => {
|
|
689
|
+
setTimeout(() => resolve(false), ELEMENT_DEFINITION_TIMEOUT_MS);
|
|
690
|
+
});
|
|
691
|
+
return await Promise.race([defined, timeout]);
|
|
692
|
+
}
|
|
693
|
+
catch {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Renders Apple's native <apple-pay-button> stretched over `wrapper` and
|
|
699
|
+
* forwards clicks to the Primer-rendered <button> inside it. The synchronous
|
|
700
|
+
* forwarded click preserves the user activation required by ApplePaySession.
|
|
701
|
+
*
|
|
702
|
+
* Returns the overlay element, or null when the Apple Pay SDK could not be
|
|
703
|
+
* loaded (callers should keep Primer's own button visible as a fallback).
|
|
704
|
+
*/
|
|
705
|
+
async function overlayNativeApplePayButton(wrapper, options) {
|
|
706
|
+
const available = await loadApplePayButtonElement();
|
|
707
|
+
if (!available) {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
// The overlay is only safe when Primer's own clickable button is present —
|
|
711
|
+
// otherwise there is nothing to forward the click to.
|
|
712
|
+
if (!wrapper.querySelector('button')) {
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
715
|
+
const native = document.createElement('apple-pay-button');
|
|
716
|
+
native.setAttribute('type', options.buttonType);
|
|
717
|
+
native.setAttribute('buttonstyle', options.buttonStyle || 'black');
|
|
718
|
+
native.setAttribute('locale', (typeof navigator !== 'undefined' && navigator.language) || 'en-US');
|
|
719
|
+
native.style.cssText = [
|
|
720
|
+
'position:absolute',
|
|
721
|
+
'inset:0',
|
|
722
|
+
'width:100%',
|
|
723
|
+
'height:100%',
|
|
724
|
+
'--apple-pay-button-width:100%',
|
|
725
|
+
'--apple-pay-button-height:100%',
|
|
726
|
+
'--apple-pay-button-border-radius:28px',
|
|
727
|
+
'display:block',
|
|
728
|
+
'cursor:pointer',
|
|
729
|
+
'z-index:1',
|
|
730
|
+
].join(';');
|
|
731
|
+
wrapper.style.position = 'relative';
|
|
732
|
+
native.addEventListener('click', () => {
|
|
733
|
+
const primerButton = wrapper.querySelector('button');
|
|
734
|
+
primerButton?.click();
|
|
735
|
+
});
|
|
736
|
+
wrapper.appendChild(native);
|
|
737
|
+
return native;
|
|
738
|
+
}
|
|
739
|
+
|
|
643
740
|
/**
|
|
644
741
|
* @fileoverview Primer SDK integration wrapper
|
|
645
742
|
*/
|
|
@@ -678,6 +775,7 @@ class PrimerWrapper {
|
|
|
678
775
|
}
|
|
679
776
|
async createHeadlessCheckout(clientToken, options, method) {
|
|
680
777
|
await this.ensurePrimerLoaded();
|
|
778
|
+
this.applePayOptions = options.applePay;
|
|
681
779
|
this.currentHeadless = PrimerWrapper.headlessManager.getOrCreate(clientToken, options, method);
|
|
682
780
|
return this.currentHeadless;
|
|
683
781
|
}
|
|
@@ -724,16 +822,53 @@ class PrimerWrapper {
|
|
|
724
822
|
}
|
|
725
823
|
htmlNode.appendChild(wrapper);
|
|
726
824
|
/* end hack */
|
|
825
|
+
/* PRD-1426: WebKit cannot render newer Apple Pay button types (e.g.
|
|
826
|
+
* 'continue') through the CSS approach Primer v2 uses. For those types
|
|
827
|
+
* we overlay Apple's official <apple-pay-button> element on top of the
|
|
828
|
+
* visually hidden Primer button and forward clicks, keeping Primer's
|
|
829
|
+
* payment flow untouched. The Primer button is hidden BEFORE it renders
|
|
830
|
+
* to avoid a flash of the plain button; if the Apple SDK fails to load,
|
|
831
|
+
* the rule is removed and Primer's own button stays visible (graceful
|
|
832
|
+
* fallback to 'plain'). */
|
|
833
|
+
const applePayConfig = this.applePayOptions;
|
|
834
|
+
const nativeButtonType = allowedPaymentMethod === PaymentMethod.APPLE_PAY &&
|
|
835
|
+
applePayConfig?.buttonType &&
|
|
836
|
+
isNativeOnlyApplePayButtonType(applePayConfig.buttonType)
|
|
837
|
+
? applePayConfig.buttonType
|
|
838
|
+
: null;
|
|
839
|
+
let hideRuleIndex = null;
|
|
840
|
+
if (nativeButtonType && sheet) {
|
|
841
|
+
hideRuleIndex = sheet.insertRule(`
|
|
842
|
+
.${wrapper.className} > button {
|
|
843
|
+
opacity: 0 !important;
|
|
844
|
+
}
|
|
845
|
+
`);
|
|
846
|
+
}
|
|
727
847
|
button = pmManager.createButton();
|
|
728
848
|
await button.render(wrapper, {});
|
|
849
|
+
let nativeOverlay = null;
|
|
850
|
+
if (nativeButtonType) {
|
|
851
|
+
nativeOverlay = await overlayNativeApplePayButton(wrapper, {
|
|
852
|
+
buttonType: nativeButtonType,
|
|
853
|
+
buttonStyle: applePayConfig?.buttonStyle,
|
|
854
|
+
});
|
|
855
|
+
if (!nativeOverlay && sheet && hideRuleIndex !== null) {
|
|
856
|
+
sheet.deleteRule(hideRuleIndex);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
729
859
|
this.destroyCallbacks.push(() => button.clean());
|
|
730
860
|
onMethodRender(allowedPaymentMethod);
|
|
731
861
|
return {
|
|
732
862
|
setDisabled: (disabled) => {
|
|
733
863
|
button.setDisabled(disabled);
|
|
864
|
+
if (nativeOverlay) {
|
|
865
|
+
nativeOverlay.style.pointerEvents = disabled ? 'none' : '';
|
|
866
|
+
nativeOverlay.style.opacity = disabled ? '0.5' : '';
|
|
867
|
+
}
|
|
734
868
|
},
|
|
735
869
|
destroy: () => {
|
|
736
870
|
styleEl.remove();
|
|
871
|
+
nativeOverlay?.remove();
|
|
737
872
|
button.clean();
|
|
738
873
|
},
|
|
739
874
|
};
|
|
@@ -1893,14 +2028,6 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1893
2028
|
this.emitTaxInfo(info);
|
|
1894
2029
|
}
|
|
1895
2030
|
};
|
|
1896
|
-
// Re-render the current tax figures to a skin that subscribed after the estimate was first
|
|
1897
|
-
// emitted (the initMethod card path wires the skin only once the method mounts).
|
|
1898
|
-
this.renderTaxToSkin = () => {
|
|
1899
|
-
const info = this.lastTaxInfo ?? this.getSessionTaxInfo();
|
|
1900
|
-
if (info) {
|
|
1901
|
-
this.emit(EVENTS.TAX_CHANGE, info);
|
|
1902
|
-
}
|
|
1903
|
-
};
|
|
1904
2031
|
this.runTaxRecalc = async () => {
|
|
1905
2032
|
const orderId = this.orderId;
|
|
1906
2033
|
const countryCode = this.getSelectedCountryCode();
|
|
@@ -1957,11 +2084,6 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1957
2084
|
this.handleMethodRender = (method) => {
|
|
1958
2085
|
this.emit(EVENTS.METHOD_RENDER, method);
|
|
1959
2086
|
};
|
|
1960
|
-
this.handleTaxMethodRender = (method) => {
|
|
1961
|
-
if (method === PaymentMethod.PAYMENT_CARD && this.isTaxEnabled()) {
|
|
1962
|
-
this.renderTaxToSkin();
|
|
1963
|
-
}
|
|
1964
|
-
};
|
|
1965
2087
|
this.handleMethodRenderError = (method) => {
|
|
1966
2088
|
this.emit(EVENTS.METHOD_RENDER_ERROR, method);
|
|
1967
2089
|
};
|
|
@@ -2534,13 +2656,6 @@ class CheckoutInstance extends EventEmitter {
|
|
|
2534
2656
|
const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
|
|
2535
2657
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
2536
2658
|
this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
|
|
2537
|
-
if (skin.onTaxChange) {
|
|
2538
|
-
this.on(EVENTS.TAX_CHANGE, skin.onTaxChange);
|
|
2539
|
-
}
|
|
2540
|
-
if (skin.onTaxPending) {
|
|
2541
|
-
this.on(EVENTS.TAX_PENDING, skin.onTaxPending);
|
|
2542
|
-
}
|
|
2543
|
-
this.on(EVENTS.METHOD_RENDER, this.handleTaxMethodRender);
|
|
2544
2659
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
2545
2660
|
this.on(EVENTS.LOADER_CHANGE, skin.onLoaderChange);
|
|
2546
2661
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
@@ -2558,13 +2673,6 @@ class CheckoutInstance extends EventEmitter {
|
|
|
2558
2673
|
skin.init();
|
|
2559
2674
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
2560
2675
|
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
2561
|
-
if (skin.onTaxChange) {
|
|
2562
|
-
this.on(EVENTS.TAX_CHANGE, skin.onTaxChange);
|
|
2563
|
-
}
|
|
2564
|
-
if (skin.onTaxPending) {
|
|
2565
|
-
this.on(EVENTS.TAX_PENDING, skin.onTaxPending);
|
|
2566
|
-
}
|
|
2567
|
-
this.on(EVENTS.METHOD_RENDER, this.handleTaxMethodRender);
|
|
2568
2676
|
this.on(EVENTS.SUCCESS, skin.onDestroy);
|
|
2569
2677
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
2570
2678
|
return skin.getCheckoutOptions();
|
|
@@ -2970,4 +3078,4 @@ if (typeof window !== 'undefined') {
|
|
|
2970
3078
|
}
|
|
2971
3079
|
console.debug('Billing SDK inited');
|
|
2972
3080
|
|
|
2973
|
-
export { APIError as A, Billing as B, CheckoutError as C, DEFAULT_BUTTONS_OPTIONS as D, EVENTS as E, FunnefoxSDKError as F, NetworkError as N, PaymentMethod as P, SDK_VERSION as S, ValidationError as V, PrimerError as a, ConfigurationError as b, DEFAULTS as c, CHECKOUT_STATES as d, ERROR_CODES as e,
|
|
3081
|
+
export { APIError as A, Billing as B, CheckoutError as C, DEFAULT_BUTTONS_OPTIONS as D, EVENTS as E, FunnefoxSDKError as F, NetworkError as N, PaymentMethod as P, SDK_VERSION as S, ValidationError as V, PrimerError as a, ConfigurationError as b, DEFAULTS as c, CHECKOUT_STATES as d, ERROR_CODES as e, configure as f, createCheckout as g, createClientSession as h, getAvailablePaymentMethods as i, loadStripe as l };
|
package/dist/chunk-index.es2.js
CHANGED
|
@@ -81,12 +81,6 @@ class DefaultSkin {
|
|
|
81
81
|
this.onInputError = (event) => {
|
|
82
82
|
this.cardInstance.onInputError(event);
|
|
83
83
|
};
|
|
84
|
-
this.onTaxChange = (info) => {
|
|
85
|
-
this.cardInstance.onTaxChange(info);
|
|
86
|
-
};
|
|
87
|
-
this.onTaxPending = () => {
|
|
88
|
-
this.cardInstance.onTaxPending();
|
|
89
|
-
};
|
|
90
84
|
this.onMethodRender = (paymentMethod) => {
|
|
91
85
|
const methodKey = paymentMethod.replace('_', '-').toLowerCase();
|
|
92
86
|
const methodContainer = this.containerEl.querySelector(`.ff-payment-method-${methodKey}`);
|
package/dist/chunk-index.es3.js
CHANGED
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
* @author Funnelfox
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
import { f as formatCurrencyAmount } from './chunk-index.es.js';
|
|
8
|
+
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";
|
|
9
9
|
|
|
10
|
-
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";
|
|
11
|
-
|
|
12
|
-
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\n.ff-tax-summary {\n margin-top: 12px;\n padding-top: 12px;\n border-top: 1px solid rgb(0 0 0 / 10%);\n font-size: 16px;\n transition: opacity 0.2s ease;\n}\n\n.ff-tax-summary[hidden] {\n display: none;\n}\n\n.ff-tax-summary--updating {\n opacity: 0.55;\n}\n\n.ff-tax-row {\n display: flex;\n justify-content: space-between;\n gap: 10px;\n margin-bottom: 6px;\n}\n\n.ff-tax-row.ff-tax-total {\n margin-top: 8px;\n margin-bottom: 0;\n font-weight: 600;\n}";
|
|
10
|
+
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";
|
|
13
11
|
|
|
14
12
|
class CardSkin {
|
|
15
13
|
constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
|
|
@@ -44,39 +42,6 @@ class CardSkin {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
|
-
this.onTaxChange = (info) => {
|
|
48
|
-
const summary = this.containerEl.querySelector('#ffTaxSummary');
|
|
49
|
-
if (!summary) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// taxAmount is the tax added on top of the price; it is 0 for tax-inclusive pricing and for
|
|
53
|
-
// non-taxed locations — in both cases there is nothing to itemise, so the summary stays hidden.
|
|
54
|
-
if (!(info.taxAmount > 0)) {
|
|
55
|
-
summary.hidden = true;
|
|
56
|
-
summary.classList.remove('ff-tax-summary--updating');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const subtotal = this.containerEl.querySelector('#ffTaxSubtotal');
|
|
60
|
-
const tax = this.containerEl.querySelector('#ffTaxAmount');
|
|
61
|
-
const total = this.containerEl.querySelector('#ffTaxTotal');
|
|
62
|
-
if (subtotal) {
|
|
63
|
-
subtotal.textContent = formatCurrencyAmount(info.amountTotal - info.taxAmount, info.currency);
|
|
64
|
-
}
|
|
65
|
-
if (tax) {
|
|
66
|
-
tax.textContent = formatCurrencyAmount(info.taxAmount, info.currency);
|
|
67
|
-
}
|
|
68
|
-
if (total) {
|
|
69
|
-
total.textContent = formatCurrencyAmount(info.amountTotal, info.currency);
|
|
70
|
-
}
|
|
71
|
-
summary.hidden = false;
|
|
72
|
-
summary.classList.remove('ff-tax-summary--updating');
|
|
73
|
-
};
|
|
74
|
-
this.onTaxPending = () => {
|
|
75
|
-
const summary = this.containerEl.querySelector('#ffTaxSummary');
|
|
76
|
-
if (summary && !summary.hidden) {
|
|
77
|
-
summary.classList.add('ff-tax-summary--updating');
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
45
|
this.onMethodRender = () => {
|
|
81
46
|
this.containerEl.style.display = 'block';
|
|
82
47
|
};
|
|
@@ -8,70 +8,9 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
var stripeLoader = require('./chunk-stripe-loader.cjs.js');
|
|
11
|
-
|
|
11
|
+
require('./chunk-index.cjs.js');
|
|
12
12
|
|
|
13
|
-
const TAX_STYLE_ID = 'ff-stripe-tax-styles';
|
|
14
13
|
const TAX_RECALC_DEBOUNCE_MS = 600;
|
|
15
|
-
// The Stripe card form renders Stripe Elements (not the card skin), so it owns its own subtotal/tax/
|
|
16
|
-
// total summary here — mirroring the hosted card skin so every integration shows tax consistently
|
|
17
|
-
// without the host page reimplementing it.
|
|
18
|
-
function injectTaxStyles() {
|
|
19
|
-
if (typeof document === 'undefined')
|
|
20
|
-
return;
|
|
21
|
-
if (document.getElementById(TAX_STYLE_ID))
|
|
22
|
-
return;
|
|
23
|
-
const style = document.createElement('style');
|
|
24
|
-
style.id = TAX_STYLE_ID;
|
|
25
|
-
style.textContent = [
|
|
26
|
-
'.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}',
|
|
27
|
-
'.ff-tax-summary[hidden]{display:none}',
|
|
28
|
-
'.ff-tax-summary--updating{opacity:.55}',
|
|
29
|
-
'.ff-tax-row{display:flex;justify-content:space-between;gap:10px;margin-bottom:6px}',
|
|
30
|
-
'.ff-tax-row.ff-tax-total{margin-top:8px;margin-bottom:0;font-weight:600}',
|
|
31
|
-
].join('\n');
|
|
32
|
-
document.head.appendChild(style);
|
|
33
|
-
}
|
|
34
|
-
function createTaxSummary() {
|
|
35
|
-
const root = document.createElement('div');
|
|
36
|
-
root.className = 'ff-tax-summary';
|
|
37
|
-
root.hidden = true;
|
|
38
|
-
const makeRow = (label, isTotal = false) => {
|
|
39
|
-
const rowEl = document.createElement('div');
|
|
40
|
-
rowEl.className = isTotal ? 'ff-tax-row ff-tax-total' : 'ff-tax-row';
|
|
41
|
-
const labelEl = document.createElement('span');
|
|
42
|
-
labelEl.textContent = label;
|
|
43
|
-
const valueEl = document.createElement('span');
|
|
44
|
-
rowEl.append(labelEl, valueEl);
|
|
45
|
-
root.appendChild(rowEl);
|
|
46
|
-
return valueEl;
|
|
47
|
-
};
|
|
48
|
-
const subtotalEl = makeRow('Subtotal');
|
|
49
|
-
const taxEl = makeRow('Tax');
|
|
50
|
-
const totalEl = makeRow('Total', true);
|
|
51
|
-
return {
|
|
52
|
-
root,
|
|
53
|
-
// taxAmount is the tax added on top of the price; it is 0 for tax-inclusive pricing and for
|
|
54
|
-
// non-taxed locations — in both cases there is nothing to itemise, so the summary stays hidden.
|
|
55
|
-
render(info) {
|
|
56
|
-
root.classList.remove('ff-tax-summary--updating');
|
|
57
|
-
if (!info || !(info.taxAmount > 0)) {
|
|
58
|
-
root.hidden = true;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
subtotalEl.textContent = index.formatCurrencyAmount(info.amountTotal - info.taxAmount, info.currency);
|
|
62
|
-
taxEl.textContent = index.formatCurrencyAmount(info.taxAmount, info.currency);
|
|
63
|
-
totalEl.textContent = index.formatCurrencyAmount(info.amountTotal, info.currency);
|
|
64
|
-
root.hidden = false;
|
|
65
|
-
},
|
|
66
|
-
setPending() {
|
|
67
|
-
if (!root.hidden)
|
|
68
|
-
root.classList.add('ff-tax-summary--updating');
|
|
69
|
-
},
|
|
70
|
-
setIdle() {
|
|
71
|
-
root.classList.remove('ff-tax-summary--updating');
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
14
|
async function mountStripeCardForm(element, session, params) {
|
|
76
15
|
const { stripe_public_key, amount, currency, order_id, is_link_enabled, tax_amount, amount_total, } = session.data;
|
|
77
16
|
// Tax flow is driven by the tenant setting (session.tax_enabled); enableTax is a legacy override.
|
|
@@ -81,8 +20,6 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
81
20
|
throw new Error('Failed to load Stripe');
|
|
82
21
|
// Remounting (e.g. picking another price) must replace the form, not stack a second one.
|
|
83
22
|
element.replaceChildren();
|
|
84
|
-
injectTaxStyles();
|
|
85
|
-
const taxSummary = createTaxSummary();
|
|
86
23
|
const stripeElements = stripe.elements({
|
|
87
24
|
mode: 'subscription',
|
|
88
25
|
amount,
|
|
@@ -105,21 +42,22 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
105
42
|
terms: { card: 'never' },
|
|
106
43
|
fields: {
|
|
107
44
|
billingDetails: {
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
address
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
: 'auto',
|
|
45
|
+
// Field visibility is owned by the org settings (Taxes → Settings) and is independent of
|
|
46
|
+
// whether tax is enabled: show the country selector and/or postal code only when configured,
|
|
47
|
+
// and always hide the rest of the address (supplied to createPaymentMethod below). Previously
|
|
48
|
+
// the untaxed path fell back to Stripe's default billing (country + postal), showing those
|
|
49
|
+
// fields even when the org had turned them off.
|
|
50
|
+
address: {
|
|
51
|
+
line1: 'never',
|
|
52
|
+
line2: 'never',
|
|
53
|
+
city: 'never',
|
|
54
|
+
state: 'never',
|
|
55
|
+
country: showCountry ? 'auto' : 'never',
|
|
56
|
+
postalCode: showPostal ? 'auto' : 'never',
|
|
57
|
+
},
|
|
120
58
|
},
|
|
121
59
|
},
|
|
122
|
-
...(session.data.detected_country_code &&
|
|
60
|
+
...(session.data.detected_country_code && showCountry
|
|
123
61
|
? {
|
|
124
62
|
defaultValues: {
|
|
125
63
|
billingDetails: {
|
|
@@ -130,16 +68,16 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
130
68
|
: {}),
|
|
131
69
|
});
|
|
132
70
|
// Address fields we hid (fields=never) must still be supplied to createPaymentMethod. Only country +
|
|
133
|
-
// postal matter for tax; country is
|
|
134
|
-
// no location at all.
|
|
71
|
+
// postal matter for tax; country is supplied when its selector is off, postal when its field is off.
|
|
135
72
|
const hiddenBillingAddress = { line1: '', line2: '', city: '', state: '' };
|
|
136
73
|
if (!showCountry)
|
|
137
74
|
hiddenBillingAddress.country = session.data.detected_country_code ?? '';
|
|
138
|
-
if (!
|
|
75
|
+
if (!showPostal)
|
|
139
76
|
hiddenBillingAddress.postal_code = '';
|
|
140
|
-
// Tax needs only the country + postal code. When the org collects location on the form we read it
|
|
141
|
-
// the Payment Element's change events as the buyer types
|
|
142
|
-
// calculation id to the charge. When it does not, tax follows the
|
|
77
|
+
// Tax needs only the country + postal code. When the org collects location on the form we read it
|
|
78
|
+
// from the Payment Element's change events as the buyer types, recalculate tax live (reported via
|
|
79
|
+
// onTaxChange), and attach the calculation id to the charge. When it does not, tax follows the
|
|
80
|
+
// IP-derived session estimate.
|
|
143
81
|
let taxCalc;
|
|
144
82
|
let recalcSeq = 0;
|
|
145
83
|
if (taxEnabled && session.data.tax_calculation_id) {
|
|
@@ -155,7 +93,6 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
155
93
|
const country = taxAddress.country;
|
|
156
94
|
const postal = taxAddress.postalCode;
|
|
157
95
|
if (!country) {
|
|
158
|
-
taxSummary.setIdle();
|
|
159
96
|
return;
|
|
160
97
|
}
|
|
161
98
|
const seq = ++recalcSeq;
|
|
@@ -169,13 +106,11 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
169
106
|
if (seq !== recalcSeq)
|
|
170
107
|
return; // a newer recalc superseded this one
|
|
171
108
|
taxCalc = { id: tax.tax_calculation_id, country, postal };
|
|
172
|
-
|
|
109
|
+
params.onTaxChange?.({
|
|
173
110
|
amountTotal: tax.amount_total,
|
|
174
111
|
taxAmount: tax.tax_amount,
|
|
175
112
|
currency: tax.currency,
|
|
176
|
-
};
|
|
177
|
-
taxSummary.render(info);
|
|
178
|
-
params.onTaxChange?.(info);
|
|
113
|
+
});
|
|
179
114
|
}
|
|
180
115
|
catch (err) {
|
|
181
116
|
if (seq !== recalcSeq)
|
|
@@ -184,7 +119,6 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
184
119
|
taxCalc = undefined;
|
|
185
120
|
params.onTaxError?.(err);
|
|
186
121
|
}
|
|
187
|
-
taxSummary.setIdle();
|
|
188
122
|
}
|
|
189
123
|
};
|
|
190
124
|
paymentElement.mount(element);
|
|
@@ -209,19 +143,21 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
209
143
|
};
|
|
210
144
|
if (!taxAddress.country)
|
|
211
145
|
return;
|
|
212
|
-
taxSummary.setPending();
|
|
213
146
|
if (debounce)
|
|
214
147
|
clearTimeout(debounce);
|
|
215
148
|
debounce = setTimeout(runRecalc, TAX_RECALC_DEBOUNCE_MS);
|
|
216
149
|
});
|
|
217
150
|
}
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
151
|
+
// The form renders no tax lines; the host re-renders its own prices off onTaxChange. Report the
|
|
152
|
+
// session estimate as the first calculation, then (when the org collects location) refine it
|
|
153
|
+
// against the pre-filled country right away — later address edits keep firing it via the recalc.
|
|
154
|
+
if (taxEnabled && amount_total != null) {
|
|
155
|
+
params.onTaxChange?.({
|
|
156
|
+
amountTotal: amount_total,
|
|
157
|
+
taxAmount: tax_amount ?? 0,
|
|
158
|
+
currency,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
225
161
|
if (taxEnabled && collectLocation)
|
|
226
162
|
void runRecalc();
|
|
227
163
|
await new Promise((resolve, reject) => {
|
|
@@ -243,10 +179,10 @@ async function mountStripeCardForm(element, session, params) {
|
|
|
243
179
|
const { error, paymentMethod } = await stripe.createPaymentMethod({
|
|
244
180
|
elements: stripeElements,
|
|
245
181
|
// Supply the address fields we hid on the Payment Element (fields=never); Stripe requires
|
|
246
|
-
// them here.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
182
|
+
// them here. We always hide line1/line2/city/state (and country/postal per the org
|
|
183
|
+
// settings), so these must be supplied regardless of tax mode. Country/postal shown on the
|
|
184
|
+
// element are filled by Stripe automatically.
|
|
185
|
+
params: { billing_details: { address: hiddenBillingAddress } },
|
|
250
186
|
});
|
|
251
187
|
if (error)
|
|
252
188
|
throw error;
|