@paypercut/checkout-js 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -1
- package/dist/developer-assistance.cjs +2668 -0
- package/dist/developer-assistance.cjs.map +1 -0
- package/dist/developer-assistance.d.cts +2 -0
- package/dist/developer-assistance.d.mts +2 -0
- package/dist/developer-assistance.mjs +2665 -0
- package/dist/developer-assistance.mjs.map +1 -0
- package/dist/index.cjs +382 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +898 -0
- package/dist/index.d.mts +898 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +381 -149
- package/dist/index.mjs.map +1 -1
- package/dist/paypercut-checkout.iife.min.js +1 -1
- package/dist/paypercut-checkout.iife.min.js.map +1 -1
- package/dist/paypercut-developer-assistance.iife.min.js +2 -0
- package/dist/paypercut-developer-assistance.iife.min.js.map +1 -0
- package/package.json +16 -6
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
5
6
|
/**
|
|
6
7
|
* Simple event emitter for handling checkout events
|
|
7
8
|
* Supports subscribing, unsubscribing, and emitting events
|
|
@@ -104,6 +105,8 @@ class Emitter {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
const SDK_VERSION = "1.4.0";
|
|
109
|
+
|
|
107
110
|
/**
|
|
108
111
|
* Build-time configuration
|
|
109
112
|
*
|
|
@@ -115,8 +118,7 @@ class Emitter {
|
|
|
115
118
|
* Production configuration (for merchants)
|
|
116
119
|
*/
|
|
117
120
|
const productionConfig = {
|
|
118
|
-
version:
|
|
119
|
-
mode: 'production',
|
|
121
|
+
version: SDK_VERSION,
|
|
120
122
|
defaultCheckoutOrigin: 'https://buy.paypercut.io',
|
|
121
123
|
defaultApiOrigin: 'https://api.paypercut.io',
|
|
122
124
|
defaultVaultApiUrl: 'https://api.basistheory.com',
|
|
@@ -2450,6 +2452,7 @@ const ElementsControllerCommandType = {
|
|
|
2450
2452
|
CancelComponentSubmission: 'PAYPERCUT_ELEMENTS_CONTROLLER_CANCEL_COMPONENT_SUBMISSION',
|
|
2451
2453
|
AttachActionChannel: 'PAYPERCUT_ELEMENTS_CONTROLLER_ATTACH_ACTION_CHANNEL',
|
|
2452
2454
|
UpdateOptions: 'PAYPERCUT_ELEMENTS_CONTROLLER_UPDATE_OPTIONS',
|
|
2455
|
+
DiscoverDeveloperPresets: 'PAYPERCUT_ELEMENTS_CONTROLLER_DISCOVER_DEVELOPER_PRESETS',
|
|
2453
2456
|
ApplyDeveloperPreset: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLY_DEVELOPER_PRESET',
|
|
2454
2457
|
ApplePayCapabilities: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLE_PAY_CAPABILITIES',
|
|
2455
2458
|
ApplePayValidateMerchant: 'PAYPERCUT_ELEMENTS_CONTROLLER_APPLE_PAY_VALIDATE_MERCHANT',
|
|
@@ -2971,144 +2974,147 @@ const isDeveloperPreset = (value) => isRecord$2(value) &&
|
|
|
2971
2974
|
/^\d{4}$/.test(value.last4) &&
|
|
2972
2975
|
['success', 'challenge', 'warning', 'danger'].includes(String(value.tone));
|
|
2973
2976
|
|
|
2974
|
-
const
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
buttonExpressCheckoutBorderRadius: '4px',
|
|
3000
|
-
buttonPadding: '12px',
|
|
3001
|
-
};
|
|
3002
|
-
const DARK_VARIABLES = {
|
|
3003
|
-
...LIGHT_VARIABLES,
|
|
3004
|
-
colorBackground: '#15171c',
|
|
3005
|
-
colorSurface: '#1d2027',
|
|
3006
|
-
colorText: '#f3f4f6',
|
|
3007
|
-
colorTextSecondary: '#aeb7c7',
|
|
3008
|
-
colorTextPlaceholder: '#8f99aa',
|
|
3009
|
-
colorBorder: '#3a404b',
|
|
3010
|
-
colorFocus: '#7db7ff',
|
|
3011
|
-
colorMuted: '#252932',
|
|
3012
|
-
};
|
|
3013
|
-
const VARIABLE_NAMES = new Set(Object.keys(LIGHT_VARIABLES));
|
|
3014
|
-
const PUBLIC_VARIABLE_REFERENCE = /var\(\s*--([A-Za-z][A-Za-z0-9]*)\s*\)/g;
|
|
3015
|
-
function resolveCardFieldAppearance(appearance) {
|
|
3016
|
-
const theme = appearance?.theme ?? 'light';
|
|
3017
|
-
const themeVariables = theme === 'dark' ? DARK_VARIABLES : LIGHT_VARIABLES;
|
|
3018
|
-
const overrides = Object.fromEntries(Object.entries(appearance?.variables ?? {}).filter(([name, value]) => VARIABLE_NAMES.has(name) && typeof value === 'string'));
|
|
3019
|
-
return {
|
|
3020
|
-
theme,
|
|
3021
|
-
disableAnimations: appearance?.disableAnimations ?? false,
|
|
3022
|
-
variables: {
|
|
3023
|
-
...themeVariables,
|
|
3024
|
-
...overrides,
|
|
3025
|
-
},
|
|
3026
|
-
};
|
|
2977
|
+
const DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT = 'paypercut-developer-assistance.iife.min.js';
|
|
2978
|
+
const DEVELOPER_ASSISTANCE_MODULE_ARTIFACT = 'developer-assistance.mjs';
|
|
2979
|
+
const DEVELOPER_ASSISTANCE_LOAD_DIAGNOSTIC = '[Paypercut Elements] developer_assistance_load_failed: Developer Assistant is unavailable. The SDK and Elements continue to work.';
|
|
2980
|
+
const IIFE_ARTIFACT_PATH = /\/paypercut-checkout(?:-dev)?\.iife\.min\.js$/;
|
|
2981
|
+
// Rollup rewrites import.meta.url for CommonJS and classic-script bundles, so
|
|
2982
|
+
// this remains the URL of the exact core artifact that owns the registration
|
|
2983
|
+
// boundary in every supported format.
|
|
2984
|
+
const coreArtifactUrl = typeof __filename === 'string' ? fileUrlFor(__filename) : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href));
|
|
2985
|
+
const classicScriptUrl = typeof document === 'undefined' ? null : (document.currentScript?.getAttribute('src') ?? null);
|
|
2986
|
+
let loadRequested = false;
|
|
2987
|
+
function requestDeveloperAssistance(isInstalled) {
|
|
2988
|
+
if (loadRequested || isInstalled())
|
|
2989
|
+
return;
|
|
2990
|
+
loadRequested = true;
|
|
2991
|
+
if (!canLoadDeveloperAssistance()) {
|
|
2992
|
+
warnDeveloperAssistanceUnavailable();
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
void Promise.resolve()
|
|
2996
|
+
.then(loadDeveloperAssistance)
|
|
2997
|
+
.then(() => {
|
|
2998
|
+
if (!isInstalled())
|
|
2999
|
+
throw new Error();
|
|
3000
|
+
})
|
|
3001
|
+
.catch(warnDeveloperAssistanceUnavailable);
|
|
3027
3002
|
}
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
const rule = appearance?.rules?.[selector];
|
|
3031
|
-
if (!rule)
|
|
3032
|
-
return {};
|
|
3033
|
-
const variables = resolveCardFieldAppearance(appearance).variables;
|
|
3034
|
-
return Object.fromEntries(Object.entries(rule).flatMap(([property, value]) => {
|
|
3035
|
-
if (typeof value !== 'string' || !isSafeElementsAppearanceValue(value))
|
|
3036
|
-
return [];
|
|
3037
|
-
return [
|
|
3038
|
-
[
|
|
3039
|
-
property,
|
|
3040
|
-
value.replace(PUBLIC_VARIABLE_REFERENCE, (match, name) => name in variables ? variables[name] : match),
|
|
3041
|
-
],
|
|
3042
|
-
];
|
|
3043
|
-
}));
|
|
3003
|
+
function warnDeveloperAssistanceUnavailable() {
|
|
3004
|
+
console.warn(DEVELOPER_ASSISTANCE_LOAD_DIAGNOSTIC);
|
|
3044
3005
|
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
const
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
const
|
|
3059
|
-
|
|
3060
|
-
|
|
3006
|
+
function canLoadDeveloperAssistance() {
|
|
3007
|
+
return (typeof document !== 'undefined' &&
|
|
3008
|
+
typeof document.createElement === 'function' &&
|
|
3009
|
+
Boolean(document.head || document.documentElement));
|
|
3010
|
+
}
|
|
3011
|
+
function loadDeveloperAssistance() {
|
|
3012
|
+
if (classicScriptUrl || isClassicScriptArtifact(coreArtifactUrl)) {
|
|
3013
|
+
return loadClassicScript(resolveBrowserArtifactUrl(coreArtifactUrl));
|
|
3014
|
+
}
|
|
3015
|
+
const moduleUrl = new URL(DEVELOPER_ASSISTANCE_MODULE_ARTIFACT, coreArtifactUrl).href;
|
|
3016
|
+
return import(/* @vite-ignore */ moduleUrl);
|
|
3017
|
+
}
|
|
3018
|
+
function fileUrlFor(filename) {
|
|
3019
|
+
const normalized = filename.replace(/\\/g, '/');
|
|
3020
|
+
return new URL(`file://${normalized.startsWith('/') ? '' : '/'}${normalized}`).href;
|
|
3021
|
+
}
|
|
3022
|
+
function resolveBrowserArtifactUrl(coreUrl) {
|
|
3023
|
+
const url = new URL(coreUrl);
|
|
3024
|
+
if (IIFE_ARTIFACT_PATH.test(url.pathname)) {
|
|
3025
|
+
return new URL(DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT, url).href;
|
|
3026
|
+
}
|
|
3027
|
+
if (/\.js$/.test(url.pathname)) {
|
|
3028
|
+
url.pathname = url.pathname.replace(/[^/]+$/, DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT);
|
|
3029
|
+
}
|
|
3030
|
+
else if (/\/cdn\/?$/.test(url.pathname)) {
|
|
3031
|
+
url.pathname = url.pathname.replace(/\/cdn\/?$/, `/dist/${DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT}`);
|
|
3032
|
+
}
|
|
3033
|
+
else {
|
|
3034
|
+
url.pathname = `${url.pathname.replace(/\/$/, '')}/dist/${DEVELOPER_ASSISTANCE_BROWSER_ARTIFACT}`;
|
|
3035
|
+
}
|
|
3036
|
+
url.search = '';
|
|
3037
|
+
url.hash = '';
|
|
3038
|
+
return url.href;
|
|
3039
|
+
}
|
|
3040
|
+
function isClassicScriptArtifact(url) {
|
|
3041
|
+
try {
|
|
3042
|
+
return IIFE_ARTIFACT_PATH.test(new URL(url).pathname);
|
|
3043
|
+
}
|
|
3044
|
+
catch {
|
|
3045
|
+
return false;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
function loadClassicScript(src) {
|
|
3049
|
+
return new Promise((resolve, reject) => {
|
|
3050
|
+
const script = document.createElement('script');
|
|
3051
|
+
script.async = true;
|
|
3052
|
+
script.src = src;
|
|
3053
|
+
script.addEventListener('load', () => resolve(), { once: true });
|
|
3054
|
+
script.addEventListener('error', () => reject(new Error()), { once: true });
|
|
3055
|
+
(document.head || document.documentElement).appendChild(script);
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
const registryKey = Symbol.for('paypercut.checkout-js.developer-assistance');
|
|
3060
|
+
function getRegistry() {
|
|
3061
|
+
const globals = globalThis;
|
|
3062
|
+
globals[registryKey] ?? (globals[registryKey] = {
|
|
3063
|
+
coreVersions: new Set(),
|
|
3064
|
+
provider: null,
|
|
3065
|
+
registrations: new Set(),
|
|
3066
|
+
});
|
|
3067
|
+
return globals[registryKey];
|
|
3068
|
+
}
|
|
3069
|
+
function announceDeveloperAssistantCore() {
|
|
3070
|
+
const registry = getRegistry();
|
|
3071
|
+
if (registry.provider && registry.provider.version !== SDK_VERSION) {
|
|
3072
|
+
for (const entry of registry.registrations) {
|
|
3073
|
+
safelyUnregister(entry);
|
|
3074
|
+
}
|
|
3075
|
+
registry.provider = null;
|
|
3076
|
+
}
|
|
3077
|
+
registry.coreVersions.add(SDK_VERSION);
|
|
3078
|
+
}
|
|
3079
|
+
function safelyUnregister(entry) {
|
|
3080
|
+
try {
|
|
3081
|
+
entry.delegate?.unregister();
|
|
3082
|
+
}
|
|
3083
|
+
catch {
|
|
3084
|
+
// Developer Assistance is optional and must not interrupt owner teardown.
|
|
3085
|
+
}
|
|
3086
|
+
entry.delegate = null;
|
|
3087
|
+
}
|
|
3088
|
+
function registerDeveloperAssistantTarget(target) {
|
|
3089
|
+
const registry = getRegistry();
|
|
3090
|
+
announceDeveloperAssistantCore();
|
|
3091
|
+
const entry = { target, delegate: null, registered: true };
|
|
3092
|
+
registry.registrations.add(entry);
|
|
3093
|
+
requestDeveloperAssistance(() => registry.provider?.version === SDK_VERSION);
|
|
3094
|
+
if (registry.provider?.version === SDK_VERSION) {
|
|
3095
|
+
try {
|
|
3096
|
+
entry.delegate = registry.provider.register(target);
|
|
3097
|
+
}
|
|
3098
|
+
catch {
|
|
3099
|
+
// Developer Assistance is optional. A registration failure must not
|
|
3100
|
+
// interrupt the Element lifecycle or payment flow.
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3061
3103
|
return {
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
backgroundColor: inputBackgroundColor,
|
|
3069
|
-
color: inputColor,
|
|
3070
|
-
fontFamily: variables.fontFamily,
|
|
3071
|
-
fontSize: variables.fontSizeBase,
|
|
3072
|
-
fontWeight: variables.fontWeightNormal,
|
|
3073
|
-
lineHeight: variables.lineHeight,
|
|
3074
|
-
// The provider is clipped to its own physical region when card brands
|
|
3075
|
-
// are visible. Keep ordinary input padding here so provider- or
|
|
3076
|
-
// extension-owned controls can use that region's far-right edge.
|
|
3077
|
-
padding: !presentation
|
|
3078
|
-
? '12px'
|
|
3079
|
-
: presentation.floatingLabels
|
|
3080
|
-
? presentation.floatingLabelActive
|
|
3081
|
-
? '23px 12px 9px 12px'
|
|
3082
|
-
: '16px 12px 16px 12px'
|
|
3083
|
-
: '12px',
|
|
3084
|
-
'::placeholder': {
|
|
3085
|
-
color: variables.colorTextPlaceholder,
|
|
3086
|
-
},
|
|
3087
|
-
':disabled': {
|
|
3088
|
-
backgroundColor: inputBackgroundColor,
|
|
3089
|
-
},
|
|
3090
|
-
...inputRule,
|
|
3104
|
+
unregister() {
|
|
3105
|
+
if (!entry.registered)
|
|
3106
|
+
return;
|
|
3107
|
+
entry.registered = false;
|
|
3108
|
+
registry.registrations.delete(entry);
|
|
3109
|
+
safelyUnregister(entry);
|
|
3091
3110
|
},
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
// Theory v2 filters custom attribute selectors, but its empty/invalid/
|
|
3096
|
-
// complete state rules are deliberately class-qualified three times.
|
|
3097
|
-
// On CriOS only, matching importance lets those supported state rules
|
|
3098
|
-
// outrank Chrome without disabling native saved-card autofill.
|
|
3099
|
-
backgroundColor: providerStateValue(inputBackgroundColor),
|
|
3100
|
-
color: providerStateValue(inputColor),
|
|
3111
|
+
refresh() {
|
|
3112
|
+
if (entry.registered)
|
|
3113
|
+
entry.delegate?.refresh();
|
|
3101
3114
|
},
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
...invalidRule,
|
|
3106
|
-
backgroundColor: providerStateValue(invalidBackgroundColor),
|
|
3107
|
-
color: providerStateValue(invalidColor),
|
|
3108
|
-
},
|
|
3109
|
-
complete: {
|
|
3110
|
-
backgroundColor: providerStateValue(inputBackgroundColor),
|
|
3111
|
-
color: providerStateValue(inputColor),
|
|
3115
|
+
collapse() {
|
|
3116
|
+
if (entry.registered)
|
|
3117
|
+
entry.delegate?.collapse();
|
|
3112
3118
|
},
|
|
3113
3119
|
};
|
|
3114
3120
|
}
|
|
@@ -4854,12 +4860,40 @@ class CardElementImpl {
|
|
|
4854
4860
|
pending.resolve();
|
|
4855
4861
|
}
|
|
4856
4862
|
registerDeveloperPresets(presets) {
|
|
4857
|
-
{
|
|
4858
|
-
return;
|
|
4859
|
-
}
|
|
4863
|
+
if (this.group.getClientOptions().developerAssistant !== true) {
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
4866
|
+
if (this.developerAssistant) {
|
|
4867
|
+
// Hosted Card republishes the same authorized catalog after an Appearance
|
|
4868
|
+
// replacement. Keep the existing target and controls alive so the pending
|
|
4869
|
+
// request can release its lock and restore focus on the original control.
|
|
4870
|
+
this.developerAssistant.refresh();
|
|
4871
|
+
return;
|
|
4872
|
+
}
|
|
4873
|
+
this.developerAssistant = registerDeveloperAssistantTarget({
|
|
4874
|
+
id: `${this.group.controllerId}:${this.componentId}`,
|
|
4875
|
+
configurationIdentity: this.group.configurationIdentity,
|
|
4876
|
+
appearanceScopeId: this.group.controllerId,
|
|
4877
|
+
presets,
|
|
4878
|
+
isAvailable: () => this.canApplyDeveloperPreset(),
|
|
4879
|
+
isAppearanceAvailable: () => this.isMounted(),
|
|
4880
|
+
appearancePreviewClearsTestData: () => true,
|
|
4881
|
+
canPreview: () => this.group.isAppearancePreviewAvailable(),
|
|
4882
|
+
applyPreset: (presetId) => this.applyDeveloperPreset(presetId),
|
|
4883
|
+
getAppearance: () => this.group.getAppearance(),
|
|
4884
|
+
updateAppearance: (appearance) => this.group.updateAppearance(appearance),
|
|
4885
|
+
replaceAppearance: (appearance) => this.group.replaceAppearance(appearance),
|
|
4886
|
+
prepareAppearance: (appearance) => this.group.prepareAppearance(appearance),
|
|
4887
|
+
prepareAppearanceReplacement: (appearance) => this.group.prepareAppearanceReplacement(appearance),
|
|
4888
|
+
});
|
|
4860
4889
|
}
|
|
4861
4890
|
canApplyDeveloperPreset() {
|
|
4862
|
-
return (
|
|
4891
|
+
return (this.group.getClientOptions().developerAssistant === true &&
|
|
4892
|
+
this.ready &&
|
|
4893
|
+
!this.destroyed &&
|
|
4894
|
+
!this.group.hasPaymentMethodSubmissionState(this.componentId) &&
|
|
4895
|
+
!this.group.hasCompletedPaymentMethodSubmission(this.componentId) &&
|
|
4896
|
+
!this.pendingDeveloperPreset);
|
|
4863
4897
|
}
|
|
4864
4898
|
applyDeveloperPreset(presetId) {
|
|
4865
4899
|
if (!this.canApplyDeveloperPreset()) {
|
|
@@ -5188,7 +5222,7 @@ class ExpressCheckoutElementImpl {
|
|
|
5188
5222
|
this.group.updateExpressCheckoutComponent(this.componentId, this.componentRevision, this.getComponentOptions());
|
|
5189
5223
|
}
|
|
5190
5224
|
getComponentOptions() {
|
|
5191
|
-
return structuredCloneSafe(this.options);
|
|
5225
|
+
return structuredCloneSafe(this.pendingPreview?.nextOptions ?? this.options);
|
|
5192
5226
|
}
|
|
5193
5227
|
isMounted() {
|
|
5194
5228
|
return this.mounted && !this.destroyed;
|
|
@@ -5630,9 +5664,26 @@ class ExpressCheckoutElementImpl {
|
|
|
5630
5664
|
};
|
|
5631
5665
|
}
|
|
5632
5666
|
registerDeveloperAssistant() {
|
|
5633
|
-
{
|
|
5634
|
-
return;
|
|
5635
|
-
}
|
|
5667
|
+
if (this.group.getClientOptions().developerAssistant !== true) {
|
|
5668
|
+
return;
|
|
5669
|
+
}
|
|
5670
|
+
this.developerAssistant = registerDeveloperAssistantTarget({
|
|
5671
|
+
id: `${this.group.controllerId}:${this.componentId}:express-checkout`,
|
|
5672
|
+
configurationIdentity: this.group.configurationIdentity,
|
|
5673
|
+
appearanceScopeId: this.group.controllerId,
|
|
5674
|
+
componentDisplayScopeId: this.componentId,
|
|
5675
|
+
isAvailable: () => true,
|
|
5676
|
+
isAppearanceAvailable: () => this.isMounted(),
|
|
5677
|
+
canPreview: () => this.group.isAppearancePreviewAvailable(),
|
|
5678
|
+
getAppearance: () => this.group.getAppearance(),
|
|
5679
|
+
updateAppearance: (appearance) => this.group.updateAppearance(appearance),
|
|
5680
|
+
replaceAppearance: (appearance) => this.group.replaceAppearance(appearance),
|
|
5681
|
+
prepareAppearance: (appearance) => this.group.prepareAppearance(appearance),
|
|
5682
|
+
prepareAppearanceReplacement: (appearance) => this.group.prepareAppearanceReplacement(appearance),
|
|
5683
|
+
getComponentDisplayOptions: () => developerDisplayOptions(this.options),
|
|
5684
|
+
updateComponentDisplayOptions: (options) => this.updateDeveloperDisplayOptions(options),
|
|
5685
|
+
replaceComponentDisplayOptions: (options) => this.replaceDeveloperDisplayOptions(options),
|
|
5686
|
+
});
|
|
5636
5687
|
}
|
|
5637
5688
|
onWindowMessage(event) {
|
|
5638
5689
|
if (this.destroyed ||
|
|
@@ -6459,6 +6510,16 @@ const OPTION_KEYS = new Set([
|
|
|
6459
6510
|
'lineItems',
|
|
6460
6511
|
'shippingRates',
|
|
6461
6512
|
]);
|
|
6513
|
+
function developerDisplayOptions(options) {
|
|
6514
|
+
return structuredCloneSafe({
|
|
6515
|
+
...(options.paymentMethods ? { paymentMethods: options.paymentMethods } : {}),
|
|
6516
|
+
...(options.layout ? { layout: options.layout } : {}),
|
|
6517
|
+
...(options.buttonType ? { buttonType: options.buttonType } : {}),
|
|
6518
|
+
...(options.buttonTheme ? { buttonTheme: options.buttonTheme } : {}),
|
|
6519
|
+
...(options.buttonHeight !== undefined ? { buttonHeight: options.buttonHeight } : {}),
|
|
6520
|
+
...(options.buttonRadius !== undefined ? { buttonRadius: options.buttonRadius } : {}),
|
|
6521
|
+
});
|
|
6522
|
+
}
|
|
6462
6523
|
function mergeDeveloperDisplayOptions(current, update) {
|
|
6463
6524
|
return {
|
|
6464
6525
|
...current,
|
|
@@ -7329,6 +7390,148 @@ class ElementsWalletAttemptOverlay {
|
|
|
7329
7390
|
}
|
|
7330
7391
|
}
|
|
7331
7392
|
|
|
7393
|
+
const LIGHT_VARIABLES = {
|
|
7394
|
+
colorPrimary: '#0570de',
|
|
7395
|
+
colorPrimaryText: '#ffffff',
|
|
7396
|
+
colorBackground: '#ffffff',
|
|
7397
|
+
colorSurface: '#ffffff',
|
|
7398
|
+
colorText: '#2b2d2f',
|
|
7399
|
+
colorTextSecondary: '#6a6c6f',
|
|
7400
|
+
colorTextPlaceholder: '#737474',
|
|
7401
|
+
colorDanger: '#cc1818',
|
|
7402
|
+
colorSuccess: '#30b130',
|
|
7403
|
+
colorWarning: '#e69e2c',
|
|
7404
|
+
colorBorder: '#d7dde0',
|
|
7405
|
+
colorFocus: '#0570de',
|
|
7406
|
+
colorMuted: '#f2f4f5',
|
|
7407
|
+
fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
7408
|
+
fontSizeBase: '16px',
|
|
7409
|
+
fontWeightNormal: '400',
|
|
7410
|
+
fontWeightMedium: '500',
|
|
7411
|
+
lineHeight: '1.5',
|
|
7412
|
+
spacingUnit: '4px',
|
|
7413
|
+
gridColumnSpacing: '12px',
|
|
7414
|
+
gridRowSpacing: '12px',
|
|
7415
|
+
labelSpacing: '6px',
|
|
7416
|
+
borderRadius: '4px',
|
|
7417
|
+
buttonBorderRadius: '4px',
|
|
7418
|
+
buttonExpressCheckoutBorderRadius: '4px',
|
|
7419
|
+
buttonPadding: '12px',
|
|
7420
|
+
};
|
|
7421
|
+
const DARK_VARIABLES = {
|
|
7422
|
+
...LIGHT_VARIABLES,
|
|
7423
|
+
colorBackground: '#15171c',
|
|
7424
|
+
colorSurface: '#1d2027',
|
|
7425
|
+
colorText: '#f3f4f6',
|
|
7426
|
+
colorTextSecondary: '#aeb7c7',
|
|
7427
|
+
colorTextPlaceholder: '#8f99aa',
|
|
7428
|
+
colorBorder: '#3a404b',
|
|
7429
|
+
colorFocus: '#7db7ff',
|
|
7430
|
+
colorMuted: '#252932',
|
|
7431
|
+
};
|
|
7432
|
+
const VARIABLE_NAMES = new Set(Object.keys(LIGHT_VARIABLES));
|
|
7433
|
+
const PUBLIC_VARIABLE_REFERENCE = /var\(\s*--([A-Za-z][A-Za-z0-9]*)\s*\)/g;
|
|
7434
|
+
function resolveCardFieldAppearance(appearance) {
|
|
7435
|
+
const theme = appearance?.theme ?? 'light';
|
|
7436
|
+
const themeVariables = theme === 'dark' ? DARK_VARIABLES : LIGHT_VARIABLES;
|
|
7437
|
+
const overrides = Object.fromEntries(Object.entries(appearance?.variables ?? {}).filter(([name, value]) => VARIABLE_NAMES.has(name) && typeof value === 'string'));
|
|
7438
|
+
return {
|
|
7439
|
+
theme,
|
|
7440
|
+
disableAnimations: appearance?.disableAnimations ?? false,
|
|
7441
|
+
variables: {
|
|
7442
|
+
...themeVariables,
|
|
7443
|
+
...overrides,
|
|
7444
|
+
},
|
|
7445
|
+
};
|
|
7446
|
+
}
|
|
7447
|
+
/** Resolve one semantic public rule to concrete provider/DOM style values. */
|
|
7448
|
+
function resolveCardFieldAppearanceRule(appearance, selector) {
|
|
7449
|
+
const rule = appearance?.rules?.[selector];
|
|
7450
|
+
if (!rule)
|
|
7451
|
+
return {};
|
|
7452
|
+
const variables = resolveCardFieldAppearance(appearance).variables;
|
|
7453
|
+
return Object.fromEntries(Object.entries(rule).flatMap(([property, value]) => {
|
|
7454
|
+
if (typeof value !== 'string' || !isSafeElementsAppearanceValue(value))
|
|
7455
|
+
return [];
|
|
7456
|
+
return [
|
|
7457
|
+
[
|
|
7458
|
+
property,
|
|
7459
|
+
value.replace(PUBLIC_VARIABLE_REFERENCE, (match, name) => name in variables ? variables[name] : match),
|
|
7460
|
+
],
|
|
7461
|
+
];
|
|
7462
|
+
}));
|
|
7463
|
+
}
|
|
7464
|
+
/**
|
|
7465
|
+
* Compile the secure Basis Theory input style from the Hosted Checkout token
|
|
7466
|
+
* baseline. Provider fields cannot inherit merchant-document CSS, so every
|
|
7467
|
+
* public token and variable reference is resolved before crossing the provider
|
|
7468
|
+
* boundary. Physical end-adornment separation is owned by CardFieldSurface.
|
|
7469
|
+
*/
|
|
7470
|
+
function createBasisTheoryCardFieldStyle(appearance, presentation) {
|
|
7471
|
+
const variables = resolveCardFieldAppearance(appearance).variables;
|
|
7472
|
+
const inputRule = resolveCardFieldAppearanceRule(appearance, '.Input');
|
|
7473
|
+
const invalidRule = resolveCardFieldAppearanceRule(appearance, '.Input--invalid');
|
|
7474
|
+
const inputBackgroundColor = inputRule.backgroundColor ?? variables.colorSurface;
|
|
7475
|
+
const inputColor = inputRule.color ?? variables.colorText;
|
|
7476
|
+
const invalidBackgroundColor = invalidRule.backgroundColor ?? inputBackgroundColor;
|
|
7477
|
+
const invalidColor = invalidRule.color ?? inputColor;
|
|
7478
|
+
const chromeIosAttributeAutofill = typeof navigator !== 'undefined' && /\bCriOS\//.test(navigator.userAgent);
|
|
7479
|
+
const providerStateValue = (value) => chromeIosAttributeAutofill ? `${value} !important` : value;
|
|
7480
|
+
return {
|
|
7481
|
+
base: {
|
|
7482
|
+
// Basis Theory v2 derives its high-specificity browser-autofill paint
|
|
7483
|
+
// from the active state's color and backgroundColor. An explicitly
|
|
7484
|
+
// opaque surface prevents Chrome/WebKit's native blue fill from showing
|
|
7485
|
+
// through only the provider iframe while the SDK-owned badge lane keeps
|
|
7486
|
+
// the configured surface color.
|
|
7487
|
+
backgroundColor: inputBackgroundColor,
|
|
7488
|
+
color: inputColor,
|
|
7489
|
+
fontFamily: variables.fontFamily,
|
|
7490
|
+
fontSize: variables.fontSizeBase,
|
|
7491
|
+
fontWeight: variables.fontWeightNormal,
|
|
7492
|
+
lineHeight: variables.lineHeight,
|
|
7493
|
+
// The provider is clipped to its own physical region when card brands
|
|
7494
|
+
// are visible. Keep ordinary input padding here so provider- or
|
|
7495
|
+
// extension-owned controls can use that region's far-right edge.
|
|
7496
|
+
padding: !presentation
|
|
7497
|
+
? '12px'
|
|
7498
|
+
: presentation.floatingLabels
|
|
7499
|
+
? presentation.floatingLabelActive
|
|
7500
|
+
? '23px 12px 9px 12px'
|
|
7501
|
+
: '16px 12px 16px 12px'
|
|
7502
|
+
: '12px',
|
|
7503
|
+
'::placeholder': {
|
|
7504
|
+
color: variables.colorTextPlaceholder,
|
|
7505
|
+
},
|
|
7506
|
+
':disabled': {
|
|
7507
|
+
backgroundColor: inputBackgroundColor,
|
|
7508
|
+
},
|
|
7509
|
+
...inputRule,
|
|
7510
|
+
},
|
|
7511
|
+
empty: {
|
|
7512
|
+
// Chrome on iOS injects a later `[chrome-autofilled]` rule with an
|
|
7513
|
+
// !important blue background inside each secure provider iframe. Basis
|
|
7514
|
+
// Theory v2 filters custom attribute selectors, but its empty/invalid/
|
|
7515
|
+
// complete state rules are deliberately class-qualified three times.
|
|
7516
|
+
// On CriOS only, matching importance lets those supported state rules
|
|
7517
|
+
// outrank Chrome without disabling native saved-card autofill.
|
|
7518
|
+
backgroundColor: providerStateValue(inputBackgroundColor),
|
|
7519
|
+
color: providerStateValue(inputColor),
|
|
7520
|
+
},
|
|
7521
|
+
invalid: {
|
|
7522
|
+
// Paypercut owns the visible validation treatment. Provider text remains
|
|
7523
|
+
// neutral while incomplete input is being edited.
|
|
7524
|
+
...invalidRule,
|
|
7525
|
+
backgroundColor: providerStateValue(invalidBackgroundColor),
|
|
7526
|
+
color: providerStateValue(invalidColor),
|
|
7527
|
+
},
|
|
7528
|
+
complete: {
|
|
7529
|
+
backgroundColor: providerStateValue(inputBackgroundColor),
|
|
7530
|
+
color: providerStateValue(inputColor),
|
|
7531
|
+
},
|
|
7532
|
+
};
|
|
7533
|
+
}
|
|
7534
|
+
|
|
7332
7535
|
const CARD_BRAND_BADGE_WIDTH_PX = 48;
|
|
7333
7536
|
const CARD_BRAND_BADGE_HEIGHT_PX = 28;
|
|
7334
7537
|
const INVALID_CARD_BADGE_WIDTH_PX = 36;
|
|
@@ -10397,7 +10600,7 @@ class CardCollectionRuntime {
|
|
|
10397
10600
|
this.cancelPendingAppearancePreview(error);
|
|
10398
10601
|
}
|
|
10399
10602
|
supportsDeveloperPresets() {
|
|
10400
|
-
return
|
|
10603
|
+
return this.bootstrap?.livemode === false;
|
|
10401
10604
|
}
|
|
10402
10605
|
announceAppearanceCommit() {
|
|
10403
10606
|
if (this.destroyed)
|
|
@@ -11617,7 +11820,16 @@ class ElementsGroupImpl {
|
|
|
11617
11820
|
this.postControl(message);
|
|
11618
11821
|
}
|
|
11619
11822
|
discoverDeveloperPresets(componentId) {
|
|
11620
|
-
|
|
11823
|
+
if (this.clientOptions.developerAssistant !== true)
|
|
11824
|
+
return;
|
|
11825
|
+
const message = {
|
|
11826
|
+
channel: ELEMENTS_COMPONENT_CHANNEL,
|
|
11827
|
+
type: ElementsControllerCommandType.DiscoverDeveloperPresets,
|
|
11828
|
+
controllerId: this.controllerId,
|
|
11829
|
+
componentId,
|
|
11830
|
+
componentType: 'card',
|
|
11831
|
+
};
|
|
11832
|
+
this.postControl(message);
|
|
11621
11833
|
}
|
|
11622
11834
|
applyDeveloperPreset(componentId, requestId, presetId) {
|
|
11623
11835
|
const message = {
|
|
@@ -11769,7 +11981,7 @@ class ElementsGroupImpl {
|
|
|
11769
11981
|
const update = normalizeUpdateOptions(options, this.appearance, this.amount);
|
|
11770
11982
|
const appearanceWasRequested = options.appearance !== undefined;
|
|
11771
11983
|
const appearancePreviewEnabled = this.elementsOptions.appearanceUpdates === 'remount' ||
|
|
11772
|
-
|
|
11984
|
+
this.clientOptions.developerAssistant === true;
|
|
11773
11985
|
const hasMountedPaymentAppearanceTarget = this.hasMountedCardFields() ||
|
|
11774
11986
|
this.getMountedCardElements().length > 0 ||
|
|
11775
11987
|
this.getMountedExpressCheckoutElements().length > 0;
|
|
@@ -12065,9 +12277,29 @@ class ElementsGroupImpl {
|
|
|
12065
12277
|
}
|
|
12066
12278
|
ensureSplitCardDeveloperAssistant() {
|
|
12067
12279
|
if (this.splitCardDeveloperAssistant ||
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12280
|
+
this.clientOptions.developerAssistant !== true ||
|
|
12281
|
+
this.cardFields.size === 0 ||
|
|
12282
|
+
!this.cardCollectionRuntime.supportsDeveloperPresets() ||
|
|
12283
|
+
typeof window === 'undefined' ||
|
|
12284
|
+
typeof document === 'undefined') {
|
|
12285
|
+
return;
|
|
12286
|
+
}
|
|
12287
|
+
this.splitCardDeveloperAssistant = registerDeveloperAssistantTarget({
|
|
12288
|
+
id: `${this.controllerId}:split-card-fields`,
|
|
12289
|
+
configurationIdentity: this.configurationIdentity,
|
|
12290
|
+
appearanceScopeId: this.controllerId,
|
|
12291
|
+
presetSource: 'split-card',
|
|
12292
|
+
isAvailable: () => !this.destroyed && this.cardCollectionRuntime.canApplyDeveloperPreset(),
|
|
12293
|
+
isAppearanceAvailable: () => !this.destroyed && this.hasMountedCardFields(),
|
|
12294
|
+
appearancePreviewClearsTestData: () => true,
|
|
12295
|
+
canPreview: () => this.isAppearancePreviewAvailable(),
|
|
12296
|
+
applyCardValue: (value) => this.cardCollectionRuntime.applyDeveloperPreset(value),
|
|
12297
|
+
getAppearance: () => this.getAppearance(),
|
|
12298
|
+
updateAppearance: (appearance) => this.updateAppearance(appearance),
|
|
12299
|
+
replaceAppearance: (appearance) => this.replaceAppearance(appearance),
|
|
12300
|
+
prepareAppearance: (appearance) => this.prepareAppearance(appearance),
|
|
12301
|
+
prepareAppearanceReplacement: (appearance) => this.prepareAppearanceReplacement(appearance),
|
|
12302
|
+
});
|
|
12071
12303
|
}
|
|
12072
12304
|
unregisterSplitCardDeveloperAssistant() {
|
|
12073
12305
|
this.splitCardDeveloperAssistant?.unregister();
|
|
@@ -12739,6 +12971,7 @@ class PaymentConfirmationCoordinator {
|
|
|
12739
12971
|
}
|
|
12740
12972
|
}
|
|
12741
12973
|
|
|
12974
|
+
announceDeveloperAssistantCore();
|
|
12742
12975
|
const MAX_PAYMENT_METHOD_BILLING_CACHE_SIZE = 16;
|
|
12743
12976
|
const MAX_PUBLISHABLE_KEY_LENGTH = 512;
|
|
12744
12977
|
const MAX_CREATE_PAYMENT_METHOD_OPTION_KEYS = 2;
|