@funnelfox/billing 0.12.0 → 0.13.1
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 +679 -8
- package/dist/chunk-index.cjs3.js +1 -1
- package/dist/chunk-index.es.js +679 -8
- package/dist/chunk-index.es3.js +1 -1
- package/dist/funnelfox-billing.js +680 -9
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +82 -2
|
@@ -565,7 +565,7 @@
|
|
|
565
565
|
/**
|
|
566
566
|
* @fileoverview Constants for Funnefox SDK
|
|
567
567
|
*/
|
|
568
|
-
const SDK_VERSION = '0.
|
|
568
|
+
const SDK_VERSION = '0.13.1';
|
|
569
569
|
const DEFAULTS = {
|
|
570
570
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
571
571
|
REGION: 'default',
|
|
@@ -619,6 +619,9 @@
|
|
|
619
619
|
CONFIGURATION_ERROR: 'CONFIGURATION_ERROR',
|
|
620
620
|
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
621
621
|
};
|
|
622
|
+
const PRIMER_DEFAULTS = {
|
|
623
|
+
PAYMENT_HANDLING: 'MANUAL',
|
|
624
|
+
API_VERSION: '2.4'};
|
|
622
625
|
const ALLOWED_BUTTON_PAYMENT_METHODS = [
|
|
623
626
|
exports.PaymentMethod.GOOGLE_PAY,
|
|
624
627
|
exports.PaymentMethod.APPLE_PAY,
|
|
@@ -682,6 +685,13 @@
|
|
|
682
685
|
requiredShippingContactFields: ['emailAddress'],
|
|
683
686
|
},
|
|
684
687
|
};
|
|
688
|
+
/**
|
|
689
|
+
* Backend decline codes that mean "the 3DS check failed" (as opposed to "3DS passed, then the
|
|
690
|
+
* issuer declined"). `null`: the codes cannot tell the two apart, so any decline after a
|
|
691
|
+
* challenge is `3ds_failed` (FFB-704 spike: in production both cases share REFER_TO_CARD_ISSUER,
|
|
692
|
+
* DO_NOT_HONOR and AUTHENTICATION_REQUIRED; human decision 10).
|
|
693
|
+
*/
|
|
694
|
+
const THREE_DS_AUTH_DECLINE_CODES = null;
|
|
685
695
|
|
|
686
696
|
/**
|
|
687
697
|
* @fileoverview Input validation utilities for Funnefox SDK
|
|
@@ -1370,6 +1380,37 @@
|
|
|
1370
1380
|
throw new NetworkError('Network request failed', error);
|
|
1371
1381
|
}
|
|
1372
1382
|
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Sends the request exactly once: no retry and no client timeout (FFB-704, decision 9).
|
|
1385
|
+
* Same URL, headers and error classes as `request()`. Used only by `silentPurchase`'s
|
|
1386
|
+
* `handle3DS` mode for `one_click` and `resume_payment`, which must not be POSTed twice.
|
|
1387
|
+
*/
|
|
1388
|
+
async requestOnce(endpoint, options = {}) {
|
|
1389
|
+
const url = `${this.baseUrl}/${this.orgId}${endpoint}`;
|
|
1390
|
+
const requestOptions = {
|
|
1391
|
+
method: 'GET',
|
|
1392
|
+
headers: {
|
|
1393
|
+
'Content-Type': 'application/json',
|
|
1394
|
+
'X-SDK-Version': SDK_VERSION,
|
|
1395
|
+
...(options.headers || {}),
|
|
1396
|
+
},
|
|
1397
|
+
...options,
|
|
1398
|
+
};
|
|
1399
|
+
try {
|
|
1400
|
+
return await this._makeRequest(url, requestOptions);
|
|
1401
|
+
}
|
|
1402
|
+
catch (error) {
|
|
1403
|
+
if (error instanceof APIError) {
|
|
1404
|
+
// Same instance, enriched: _makeRequest leaves errorCode empty; fill it from the body.
|
|
1405
|
+
error.errorCode ?? (error.errorCode = getResponseErrorCodes(error.response)[0] ?? null);
|
|
1406
|
+
throw error;
|
|
1407
|
+
}
|
|
1408
|
+
if (error instanceof Error && error.name === 'NetworkError') {
|
|
1409
|
+
throw error;
|
|
1410
|
+
}
|
|
1411
|
+
throw new NetworkError('Network request failed', error);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1373
1414
|
async _makeRequest(url, options) {
|
|
1374
1415
|
let response;
|
|
1375
1416
|
try {
|
|
@@ -1561,6 +1602,23 @@
|
|
|
1561
1602
|
body: JSON.stringify(payload),
|
|
1562
1603
|
}));
|
|
1563
1604
|
}
|
|
1605
|
+
/** `one_click`, POSTed exactly once (see `requestOnce`). */
|
|
1606
|
+
async oneClickOnce(payload) {
|
|
1607
|
+
return (await this.requestOnce(API_ENDPOINTS.ONE_CLICK, {
|
|
1608
|
+
method: 'POST',
|
|
1609
|
+
body: JSON.stringify(payload),
|
|
1610
|
+
}));
|
|
1611
|
+
}
|
|
1612
|
+
/** `resume_payment`, POSTed exactly once (see `requestOnce`). */
|
|
1613
|
+
async resumePaymentOnce(params) {
|
|
1614
|
+
return (await this.requestOnce(API_ENDPOINTS.RESUME_PAYMENT, {
|
|
1615
|
+
method: 'POST',
|
|
1616
|
+
body: JSON.stringify({
|
|
1617
|
+
order_id: params.orderId,
|
|
1618
|
+
resume_token: params.resumeToken,
|
|
1619
|
+
}),
|
|
1620
|
+
}));
|
|
1621
|
+
}
|
|
1564
1622
|
async createSimpleClientSession(payload) {
|
|
1565
1623
|
return (await this.request(API_ENDPOINTS.CREATE_SIMPLE_CLIENT_SESSION, {
|
|
1566
1624
|
method: 'POST',
|
|
@@ -1572,6 +1630,19 @@
|
|
|
1572
1630
|
}));
|
|
1573
1631
|
}
|
|
1574
1632
|
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Returns the `error[].code` values of a backend error envelope
|
|
1635
|
+
* (`{status: 'error', error: [{msg, code, type}]}`), e.g. from `APIError.response`.
|
|
1636
|
+
*/
|
|
1637
|
+
function getResponseErrorCodes(response) {
|
|
1638
|
+
const errors = response?.error;
|
|
1639
|
+
if (!Array.isArray(errors)) {
|
|
1640
|
+
return [];
|
|
1641
|
+
}
|
|
1642
|
+
return errors
|
|
1643
|
+
.map(item => item?.code)
|
|
1644
|
+
.filter((code) => typeof code === 'string');
|
|
1645
|
+
}
|
|
1575
1646
|
|
|
1576
1647
|
class SessionService {
|
|
1577
1648
|
constructor() {
|
|
@@ -2906,6 +2977,278 @@
|
|
|
2906
2977
|
}
|
|
2907
2978
|
}
|
|
2908
2979
|
|
|
2980
|
+
/**
|
|
2981
|
+
* @fileoverview 3DS challenge for one-click purchases (FFB-704). Internal module.
|
|
2982
|
+
*
|
|
2983
|
+
* Primer can run a 3DS challenge only from a tokenization handler
|
|
2984
|
+
* (`handler.continueWithNewClientToken`), and a one-click purchase has no tokenization in the
|
|
2985
|
+
* browser: the backend charges the vaulted instrument. Mechanism M1 (proven by the FFB-704 spike
|
|
2986
|
+
* on the Primer sandbox): open a customer-bound CHECKOUT client session, start a headless
|
|
2987
|
+
* checkout, tokenize a vaulted instrument through the vault manager as a stand-in, and in
|
|
2988
|
+
* `onTokenizeSuccess` continue with the one-click `action_required_token` instead. Primer then
|
|
2989
|
+
* shows its 3DS overlay; `onResumeSuccess` yields the resume token for `resume_payment`.
|
|
2990
|
+
*/
|
|
2991
|
+
/** Primer client-token intents that carry a 3DS step. */
|
|
2992
|
+
const PRIMER_3DS_INTENTS = ['3DS_AUTHENTICATION', 'PROCESSOR_3DS'];
|
|
2993
|
+
/** Default `threeDSTimeoutMs`. */
|
|
2994
|
+
const DEFAULT_THREE_DS_TIMEOUT_MS = 600000;
|
|
2995
|
+
/** Close button of Primer's 3DS overlay (Primer Web SDK 2.57.3, verified in the spike). */
|
|
2996
|
+
const PRIMER_OVERLAY_CLOSE_SELECTOR = '[data-testid="OverlayContent.closeButton"]';
|
|
2997
|
+
/** Decodes the `intent` of a Primer client token (a JWT); `null` if it is not one. */
|
|
2998
|
+
function getPrimerTokenIntent(token) {
|
|
2999
|
+
try {
|
|
3000
|
+
const parts = token.split('.');
|
|
3001
|
+
if (parts.length !== 3) {
|
|
3002
|
+
return null;
|
|
3003
|
+
}
|
|
3004
|
+
const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
3005
|
+
const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
|
|
3006
|
+
const payload = JSON.parse(atob(padded));
|
|
3007
|
+
return typeof payload?.intent === 'string' ? payload.intent : null;
|
|
3008
|
+
}
|
|
3009
|
+
catch {
|
|
3010
|
+
return null;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
/** The error Primer reports when the user closes the 3DS overlay (same check as checkout.ts). */
|
|
3014
|
+
function isThreeDSCloseError(error) {
|
|
3015
|
+
return Boolean(error?.stack?.includes('PROCESSOR_3DS') &&
|
|
3016
|
+
error.code === 'RESUME_ERROR' &&
|
|
3017
|
+
error.message?.includes('fetch resume key'));
|
|
3018
|
+
}
|
|
3019
|
+
/**
|
|
3020
|
+
* Picks the vaulted instrument used as the stand-in tokenization. Primer returns the vault
|
|
3021
|
+
* oldest-first and has no "default" flag; the 3DS check runs on the action token, not on this
|
|
3022
|
+
* instrument. Cards are preferred because their vault tokenization is silent (no CVV prompt).
|
|
3023
|
+
*/
|
|
3024
|
+
function pickVaultedMethod(methods) {
|
|
3025
|
+
if (!methods || methods.length === 0) {
|
|
3026
|
+
return null;
|
|
3027
|
+
}
|
|
3028
|
+
return (methods.find(method => method.paymentInstrumentType === 'PAYMENT_CARD') ||
|
|
3029
|
+
methods[0]);
|
|
3030
|
+
}
|
|
3031
|
+
function dismissPrimerOverlay() {
|
|
3032
|
+
if (typeof document === 'undefined') {
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
const button = document.querySelector(PRIMER_OVERLAY_CLOSE_SELECTOR);
|
|
3036
|
+
button?.click();
|
|
3037
|
+
}
|
|
3038
|
+
function toPrimerError(message, error) {
|
|
3039
|
+
return error instanceof PrimerError ? error : new PrimerError(message, error);
|
|
3040
|
+
}
|
|
3041
|
+
function callSafely(fn) {
|
|
3042
|
+
try {
|
|
3043
|
+
fn();
|
|
3044
|
+
}
|
|
3045
|
+
catch {
|
|
3046
|
+
// Primer handler calls are best effort once the result is decided.
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Runs the 3DS challenge for a one-click order and, when Primer hands back a resume token,
|
|
3051
|
+
* calls `resume_payment` once. Never rejects; the caller maps the result to an outcome.
|
|
3052
|
+
*/
|
|
3053
|
+
async function runOneClickThreeDS(params) {
|
|
3054
|
+
const { apiClient, region, priceId, externalId, orderId, actionToken } = params;
|
|
3055
|
+
const intent = getPrimerTokenIntent(actionToken);
|
|
3056
|
+
if (!intent || !PRIMER_3DS_INTENTS.includes(intent)) {
|
|
3057
|
+
return {
|
|
3058
|
+
kind: 'error',
|
|
3059
|
+
error: new PrimerError('Unsupported one-click action: the action token is not a Primer 3DS client token', { intent }),
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
const timeoutMs = Number.isFinite(params.timeoutMs) && params.timeoutMs > 0
|
|
3063
|
+
? params.timeoutMs
|
|
3064
|
+
: DEFAULT_THREE_DS_TIMEOUT_MS;
|
|
3065
|
+
return new Promise(resolve => {
|
|
3066
|
+
let settled = false;
|
|
3067
|
+
let tokenized = false;
|
|
3068
|
+
// True only while create_client_session is in flight.
|
|
3069
|
+
let sessionInFlight = false;
|
|
3070
|
+
let timer = null;
|
|
3071
|
+
let headless = null;
|
|
3072
|
+
const settle = (result) => {
|
|
3073
|
+
if (settled) {
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
settled = true;
|
|
3077
|
+
if (timer) {
|
|
3078
|
+
clearTimeout(timer);
|
|
3079
|
+
timer = null;
|
|
3080
|
+
}
|
|
3081
|
+
headless = null;
|
|
3082
|
+
resolve(result);
|
|
3083
|
+
};
|
|
3084
|
+
timer = setTimeout(() => {
|
|
3085
|
+
timer = null;
|
|
3086
|
+
if (tokenized) {
|
|
3087
|
+
// The challenge was shown and the customer did not finish it.
|
|
3088
|
+
settle({ kind: 'abandoned' });
|
|
3089
|
+
// Close Primer's overlay; the close error it raises is ignored (already settled).
|
|
3090
|
+
dismissPrimerOverlay();
|
|
3091
|
+
return;
|
|
3092
|
+
}
|
|
3093
|
+
// No challenge was shown yet: this is a setup failure, not an abandoned challenge.
|
|
3094
|
+
if (sessionInFlight) {
|
|
3095
|
+
settle({
|
|
3096
|
+
kind: 'error',
|
|
3097
|
+
error: new NetworkError('create_client_session did not respond within threeDSTimeoutMs'),
|
|
3098
|
+
failedRequest: 'create_client_session',
|
|
3099
|
+
});
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3102
|
+
settle({
|
|
3103
|
+
kind: 'error',
|
|
3104
|
+
error: new PrimerError('Timed out before the 3DS challenge was shown (threeDSTimeoutMs)'),
|
|
3105
|
+
});
|
|
3106
|
+
}, timeoutMs);
|
|
3107
|
+
const onTokenizeSuccess = (_data, handler) => {
|
|
3108
|
+
if (settled) {
|
|
3109
|
+
callSafely(() => handler.handleFailure());
|
|
3110
|
+
return;
|
|
3111
|
+
}
|
|
3112
|
+
tokenized = true;
|
|
3113
|
+
// Ignore the stand-in vaulted token: run the one-click 3DS action instead.
|
|
3114
|
+
handler.continueWithNewClientToken(actionToken);
|
|
3115
|
+
};
|
|
3116
|
+
const onResumeSuccess = async (data, handler) => {
|
|
3117
|
+
if (settled) {
|
|
3118
|
+
callSafely(() => handler.handleFailure());
|
|
3119
|
+
return;
|
|
3120
|
+
}
|
|
3121
|
+
// The challenge is over: the timeout bounds only the challenge, never the POST.
|
|
3122
|
+
if (timer) {
|
|
3123
|
+
clearTimeout(timer);
|
|
3124
|
+
timer = null;
|
|
3125
|
+
}
|
|
3126
|
+
let response;
|
|
3127
|
+
try {
|
|
3128
|
+
response = await apiClient.resumePaymentOnce({
|
|
3129
|
+
orderId,
|
|
3130
|
+
resumeToken: data.resumeToken,
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
catch (error) {
|
|
3134
|
+
callSafely(() => handler.handleFailure());
|
|
3135
|
+
settle({
|
|
3136
|
+
kind: 'error',
|
|
3137
|
+
error: error,
|
|
3138
|
+
failedRequest: 'resume_payment',
|
|
3139
|
+
});
|
|
3140
|
+
return;
|
|
3141
|
+
}
|
|
3142
|
+
const resumeData = response?.data;
|
|
3143
|
+
if (response?.status === 'success' &&
|
|
3144
|
+
resumeData?.checkout_status === 'succeeded' &&
|
|
3145
|
+
!resumeData.action_required_token) {
|
|
3146
|
+
callSafely(() => handler.handleSuccess());
|
|
3147
|
+
}
|
|
3148
|
+
else {
|
|
3149
|
+
// A chained action token is never continued (no second challenge).
|
|
3150
|
+
callSafely(() => handler.handleFailure(resumeData?.failed_message_for_user || undefined));
|
|
3151
|
+
}
|
|
3152
|
+
settle({ kind: 'resumed', response });
|
|
3153
|
+
};
|
|
3154
|
+
const onResumeError = (error) => {
|
|
3155
|
+
if (isThreeDSCloseError(error)) {
|
|
3156
|
+
settle({ kind: 'abandoned' });
|
|
3157
|
+
return;
|
|
3158
|
+
}
|
|
3159
|
+
settle({
|
|
3160
|
+
kind: 'failed',
|
|
3161
|
+
error: toPrimerError('3DS authentication failed', error),
|
|
3162
|
+
});
|
|
3163
|
+
};
|
|
3164
|
+
const onCheckoutFail = (error) => {
|
|
3165
|
+
if (tokenized) {
|
|
3166
|
+
settle({
|
|
3167
|
+
kind: 'failed',
|
|
3168
|
+
error: toPrimerError('3DS authentication failed', error),
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
else {
|
|
3172
|
+
settle({
|
|
3173
|
+
kind: 'error',
|
|
3174
|
+
error: toPrimerError('Primer checkout failed before the 3DS challenge', error),
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
};
|
|
3178
|
+
const onTokenizeError = (error) => {
|
|
3179
|
+
settle({
|
|
3180
|
+
kind: 'error',
|
|
3181
|
+
error: toPrimerError('Failed to tokenize the saved payment method', error),
|
|
3182
|
+
});
|
|
3183
|
+
};
|
|
3184
|
+
(async () => {
|
|
3185
|
+
await new PrimerWrapper().ensurePrimerLoaded();
|
|
3186
|
+
if (settled) {
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3189
|
+
let clientToken;
|
|
3190
|
+
sessionInFlight = true;
|
|
3191
|
+
try {
|
|
3192
|
+
const session = await apiClient.createClientSession({
|
|
3193
|
+
priceId,
|
|
3194
|
+
externalId,
|
|
3195
|
+
region,
|
|
3196
|
+
clientMetadata: {},
|
|
3197
|
+
});
|
|
3198
|
+
clientToken = apiClient.processSessionResponse(session).clientToken;
|
|
3199
|
+
sessionInFlight = false;
|
|
3200
|
+
}
|
|
3201
|
+
catch (error) {
|
|
3202
|
+
sessionInFlight = false;
|
|
3203
|
+
settle({
|
|
3204
|
+
kind: 'error',
|
|
3205
|
+
error: error,
|
|
3206
|
+
failedRequest: 'create_client_session',
|
|
3207
|
+
});
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
if (settled) {
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3213
|
+
// A dedicated instance, not the HeadlessManager cache used by checkouts.
|
|
3214
|
+
const instance = await window.Primer.createHeadless(clientToken, {
|
|
3215
|
+
paymentHandling: PRIMER_DEFAULTS.PAYMENT_HANDLING,
|
|
3216
|
+
apiVersion: PRIMER_DEFAULTS.API_VERSION,
|
|
3217
|
+
onAvailablePaymentMethodsLoad: () => { },
|
|
3218
|
+
onTokenizeSuccess,
|
|
3219
|
+
onTokenizeError,
|
|
3220
|
+
onResumeSuccess,
|
|
3221
|
+
onResumeError,
|
|
3222
|
+
onCheckoutFail,
|
|
3223
|
+
});
|
|
3224
|
+
headless = await instance;
|
|
3225
|
+
await headless.start();
|
|
3226
|
+
if (settled) {
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
const vaultManager = headless.createVaultManager();
|
|
3230
|
+
const methods = await vaultManager.fetchVaultedPaymentMethods();
|
|
3231
|
+
const method = pickVaultedMethod(methods);
|
|
3232
|
+
if (!method) {
|
|
3233
|
+
settle({
|
|
3234
|
+
kind: 'error',
|
|
3235
|
+
error: new PrimerError('No saved payment method found for the one-click 3DS challenge'),
|
|
3236
|
+
});
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
if (settled) {
|
|
3240
|
+
return;
|
|
3241
|
+
}
|
|
3242
|
+
await vaultManager.startPaymentFlow(method.id);
|
|
3243
|
+
})().catch(error => {
|
|
3244
|
+
settle({
|
|
3245
|
+
kind: 'error',
|
|
3246
|
+
error: toPrimerError('Failed to start the one-click 3DS challenge', error),
|
|
3247
|
+
});
|
|
3248
|
+
});
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
3251
|
+
|
|
2909
3252
|
/**
|
|
2910
3253
|
* @fileoverview Public API with configuration and orchestration logic
|
|
2911
3254
|
*/
|
|
@@ -2972,20 +3315,46 @@
|
|
|
2972
3315
|
});
|
|
2973
3316
|
return apiClient.processSessionResponse(sessionResponse);
|
|
2974
3317
|
}
|
|
2975
|
-
|
|
2976
|
-
|
|
3318
|
+
/**
|
|
3319
|
+
* Builds the `one_click` body. The CIT fields are added only when the caller set them.
|
|
3320
|
+
*/
|
|
3321
|
+
function buildOneClickRequest(options) {
|
|
3322
|
+
const payload = {
|
|
3323
|
+
pp_ident: options.priceId,
|
|
3324
|
+
external_id: options.externalId,
|
|
3325
|
+
client_metadata: options.clientMetadata,
|
|
3326
|
+
};
|
|
3327
|
+
if (options.initiationType !== undefined) {
|
|
3328
|
+
payload.initiation_type = options.initiationType;
|
|
3329
|
+
}
|
|
3330
|
+
if (options.citCardNetworks !== undefined) {
|
|
3331
|
+
payload.cit_card_networks = options.citCardNetworks;
|
|
3332
|
+
}
|
|
3333
|
+
if (options.citGooglePayPanOnly !== undefined) {
|
|
3334
|
+
payload.cit_google_pay_pan_only = options.citGooglePayPanOnly;
|
|
3335
|
+
}
|
|
3336
|
+
return payload;
|
|
3337
|
+
}
|
|
3338
|
+
function silentPurchase(options) {
|
|
3339
|
+
if (options?.handle3DS === true) {
|
|
3340
|
+
return silentPurchaseDetailed(options);
|
|
3341
|
+
}
|
|
3342
|
+
return silentPurchaseLegacy(options);
|
|
3343
|
+
}
|
|
3344
|
+
async function silentPurchaseLegacy(options) {
|
|
3345
|
+
const { orgId, baseUrl } = options;
|
|
2977
3346
|
const apiClient = new APIClient({
|
|
2978
3347
|
baseUrl: baseUrl,
|
|
2979
3348
|
orgId: orgId,
|
|
2980
3349
|
timeout: DEFAULTS.REQUEST_TIMEOUT,
|
|
2981
3350
|
retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
|
|
2982
3351
|
});
|
|
3352
|
+
if (options.initiationType === 'cit') {
|
|
3353
|
+
// eslint-disable-next-line no-console
|
|
3354
|
+
console.warn('[FunnelfoxSDK] silentPurchase: initiationType "cit" can trigger a 3DS challenge, which only silentPurchase({ handle3DS: true }) handles.');
|
|
3355
|
+
}
|
|
2983
3356
|
try {
|
|
2984
|
-
const response = await apiClient.oneClick(
|
|
2985
|
-
pp_ident: priceId,
|
|
2986
|
-
external_id: externalId,
|
|
2987
|
-
client_metadata: clientMetadata,
|
|
2988
|
-
});
|
|
3357
|
+
const response = await apiClient.oneClick(buildOneClickRequest(options));
|
|
2989
3358
|
if (response.status !== 'success' &&
|
|
2990
3359
|
response.error.some(({ code }) => code === 'double_purchase')) {
|
|
2991
3360
|
throw new APIError('This product was already purchased');
|
|
@@ -3005,6 +3374,308 @@
|
|
|
3005
3374
|
throw error;
|
|
3006
3375
|
}
|
|
3007
3376
|
}
|
|
3377
|
+
const ONE_CLICK_IN_PROGRESS = 'one_click_in_progress';
|
|
3378
|
+
const DOUBLE_PURCHASE = 'double_purchase';
|
|
3379
|
+
const oneClickInFlight = new Set();
|
|
3380
|
+
function declineFields(data) {
|
|
3381
|
+
return {
|
|
3382
|
+
failedMessageForUser: data.failed_message_for_user ?? null,
|
|
3383
|
+
declineCode: data.decline_code ?? null,
|
|
3384
|
+
declineCodeSource: data.decline_code_source ?? null,
|
|
3385
|
+
};
|
|
3386
|
+
}
|
|
3387
|
+
function envelopeError(response, fallbackMessage) {
|
|
3388
|
+
const firstError = response?.error?.[0];
|
|
3389
|
+
return new APIError(firstError?.msg || fallbackMessage, null, {
|
|
3390
|
+
errorCode: firstError?.code,
|
|
3391
|
+
errorType: firstError?.type,
|
|
3392
|
+
response,
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
/** Maps a 2xx `one_click` response (rows 1-4, plus "needs action"). */
|
|
3396
|
+
function mapOneClickResponse(response) {
|
|
3397
|
+
const data = response?.data;
|
|
3398
|
+
if (response?.status !== 'success' || !data) {
|
|
3399
|
+
if (getResponseErrorCodes(response).includes(DOUBLE_PURCHASE)) {
|
|
3400
|
+
return {
|
|
3401
|
+
kind: 'result',
|
|
3402
|
+
result: {
|
|
3403
|
+
outcome: 'already_purchased',
|
|
3404
|
+
orderId: null,
|
|
3405
|
+
threeDSChallenged: false,
|
|
3406
|
+
},
|
|
3407
|
+
};
|
|
3408
|
+
}
|
|
3409
|
+
return {
|
|
3410
|
+
kind: 'result',
|
|
3411
|
+
result: {
|
|
3412
|
+
outcome: 'error',
|
|
3413
|
+
orderId: data?.order_id ?? null,
|
|
3414
|
+
threeDSChallenged: false,
|
|
3415
|
+
error: envelopeError(response, 'One-click purchase failed'),
|
|
3416
|
+
failedRequest: 'one_click',
|
|
3417
|
+
},
|
|
3418
|
+
};
|
|
3419
|
+
}
|
|
3420
|
+
const orderId = data.order_id ?? null;
|
|
3421
|
+
if (data.action_required_token) {
|
|
3422
|
+
return { kind: 'action', orderId, actionToken: data.action_required_token };
|
|
3423
|
+
}
|
|
3424
|
+
switch (data.checkout_status) {
|
|
3425
|
+
case 'succeeded':
|
|
3426
|
+
return {
|
|
3427
|
+
kind: 'result',
|
|
3428
|
+
result: { outcome: 'succeeded', orderId, threeDSChallenged: false },
|
|
3429
|
+
};
|
|
3430
|
+
case 'failed':
|
|
3431
|
+
return {
|
|
3432
|
+
kind: 'result',
|
|
3433
|
+
result: {
|
|
3434
|
+
outcome: 'declined',
|
|
3435
|
+
orderId,
|
|
3436
|
+
threeDSChallenged: false,
|
|
3437
|
+
...declineFields(data),
|
|
3438
|
+
},
|
|
3439
|
+
};
|
|
3440
|
+
case 'processing':
|
|
3441
|
+
return {
|
|
3442
|
+
kind: 'result',
|
|
3443
|
+
result: { outcome: 'processing', orderId, threeDSChallenged: false },
|
|
3444
|
+
};
|
|
3445
|
+
case 'cancelled':
|
|
3446
|
+
return {
|
|
3447
|
+
kind: 'result',
|
|
3448
|
+
result: {
|
|
3449
|
+
outcome: 'error',
|
|
3450
|
+
orderId,
|
|
3451
|
+
threeDSChallenged: false,
|
|
3452
|
+
error: new APIError('Payment was cancelled', null, { response }),
|
|
3453
|
+
},
|
|
3454
|
+
};
|
|
3455
|
+
default:
|
|
3456
|
+
return {
|
|
3457
|
+
kind: 'result',
|
|
3458
|
+
result: {
|
|
3459
|
+
outcome: 'error',
|
|
3460
|
+
orderId,
|
|
3461
|
+
threeDSChallenged: false,
|
|
3462
|
+
error: new APIError(`Unhandled checkout status: ${data.checkout_status}`, null, { response }),
|
|
3463
|
+
},
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
/** Maps a `resume_payment` response after a challenge (rows 5, 6, 6b, 6c, 7, 8). */
|
|
3468
|
+
function mapResumeResponse(response, orderId, threeDSAuthDeclineCodes = THREE_DS_AUTH_DECLINE_CODES) {
|
|
3469
|
+
const data = response?.data;
|
|
3470
|
+
if (response?.status !== 'success' || !data) {
|
|
3471
|
+
return {
|
|
3472
|
+
threeDS: 'error',
|
|
3473
|
+
result: {
|
|
3474
|
+
outcome: 'error',
|
|
3475
|
+
orderId,
|
|
3476
|
+
threeDSChallenged: true,
|
|
3477
|
+
error: envelopeError(response, 'Resume payment failed'),
|
|
3478
|
+
failedRequest: 'resume_payment',
|
|
3479
|
+
},
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
if (data.action_required_token) {
|
|
3483
|
+
// Chained action: not supported, no second challenge (human decision F3).
|
|
3484
|
+
return {
|
|
3485
|
+
threeDS: 'error',
|
|
3486
|
+
result: {
|
|
3487
|
+
outcome: 'error',
|
|
3488
|
+
orderId,
|
|
3489
|
+
threeDSChallenged: true,
|
|
3490
|
+
error: new FunnefoxSDKError('resume_payment returned another action token; chained 3DS is not supported', 'one_click_chained_action'),
|
|
3491
|
+
},
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
switch (data.checkout_status) {
|
|
3495
|
+
case 'succeeded':
|
|
3496
|
+
return {
|
|
3497
|
+
threeDS: 'passed',
|
|
3498
|
+
result: { outcome: 'succeeded', orderId, threeDSChallenged: true },
|
|
3499
|
+
};
|
|
3500
|
+
case 'processing':
|
|
3501
|
+
return {
|
|
3502
|
+
threeDS: 'passed',
|
|
3503
|
+
result: { outcome: 'processing', orderId, threeDSChallenged: true },
|
|
3504
|
+
};
|
|
3505
|
+
case 'failed': {
|
|
3506
|
+
const authFailed = threeDSAuthDeclineCodes === null ||
|
|
3507
|
+
threeDSAuthDeclineCodes.includes(data.decline_code ?? '');
|
|
3508
|
+
return {
|
|
3509
|
+
threeDS: authFailed ? 'failed' : 'passed',
|
|
3510
|
+
result: {
|
|
3511
|
+
outcome: authFailed ? '3ds_failed' : 'declined',
|
|
3512
|
+
orderId,
|
|
3513
|
+
threeDSChallenged: true,
|
|
3514
|
+
...declineFields(data),
|
|
3515
|
+
},
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
default:
|
|
3519
|
+
return {
|
|
3520
|
+
threeDS: 'error',
|
|
3521
|
+
result: {
|
|
3522
|
+
outcome: 'error',
|
|
3523
|
+
orderId,
|
|
3524
|
+
threeDSChallenged: true,
|
|
3525
|
+
error: new APIError(data.checkout_status === 'cancelled'
|
|
3526
|
+
? 'Payment was cancelled'
|
|
3527
|
+
: `Unhandled checkout status: ${data.checkout_status}`, null, { response }),
|
|
3528
|
+
},
|
|
3529
|
+
};
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
function mapThreeDSRun(run, orderId) {
|
|
3533
|
+
switch (run.kind) {
|
|
3534
|
+
case 'resumed':
|
|
3535
|
+
return mapResumeResponse(run.response, orderId);
|
|
3536
|
+
case 'failed':
|
|
3537
|
+
return {
|
|
3538
|
+
threeDS: 'failed',
|
|
3539
|
+
result: {
|
|
3540
|
+
outcome: '3ds_failed',
|
|
3541
|
+
orderId,
|
|
3542
|
+
threeDSChallenged: true,
|
|
3543
|
+
error: run.error,
|
|
3544
|
+
},
|
|
3545
|
+
};
|
|
3546
|
+
case 'abandoned':
|
|
3547
|
+
return {
|
|
3548
|
+
threeDS: 'abandoned',
|
|
3549
|
+
result: { outcome: '3ds_abandoned', orderId, threeDSChallenged: true },
|
|
3550
|
+
};
|
|
3551
|
+
default: {
|
|
3552
|
+
const result = {
|
|
3553
|
+
outcome: 'error',
|
|
3554
|
+
orderId,
|
|
3555
|
+
threeDSChallenged: true,
|
|
3556
|
+
error: run.error,
|
|
3557
|
+
};
|
|
3558
|
+
if (run.failedRequest) {
|
|
3559
|
+
result.failedRequest = run.failedRequest;
|
|
3560
|
+
}
|
|
3561
|
+
return { threeDS: 'error', result };
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
function callHook(name, hook, info) {
|
|
3566
|
+
if (typeof hook !== 'function') {
|
|
3567
|
+
return;
|
|
3568
|
+
}
|
|
3569
|
+
try {
|
|
3570
|
+
hook(info);
|
|
3571
|
+
}
|
|
3572
|
+
catch (error) {
|
|
3573
|
+
// eslint-disable-next-line no-console
|
|
3574
|
+
console.error(`[FunnelfoxSDK] silentPurchase ${name} hook threw`, error);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
async function silentPurchaseDetailed(options) {
|
|
3578
|
+
for (const field of ['orgId', 'baseUrl', 'priceId', 'externalId']) {
|
|
3579
|
+
if (!options?.[field]) {
|
|
3580
|
+
throw new ValidationError(field, 'is required', options?.[field]);
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
const { orgId, baseUrl, externalId } = options;
|
|
3584
|
+
const inFlightKey = `${orgId}\u0000${externalId}`;
|
|
3585
|
+
if (oneClickInFlight.has(inFlightKey)) {
|
|
3586
|
+
return {
|
|
3587
|
+
outcome: 'error',
|
|
3588
|
+
orderId: null,
|
|
3589
|
+
threeDSChallenged: false,
|
|
3590
|
+
error: new FunnefoxSDKError('A one-click purchase is already in progress for this customer', ONE_CLICK_IN_PROGRESS),
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
oneClickInFlight.add(inFlightKey);
|
|
3594
|
+
try {
|
|
3595
|
+
const result = await runSilentPurchaseDetailed(options);
|
|
3596
|
+
if (result.outcome === 'error' && result.error) {
|
|
3597
|
+
const error = result.error;
|
|
3598
|
+
getErrorImage(orgId, {
|
|
3599
|
+
baseUrl,
|
|
3600
|
+
message: error.message,
|
|
3601
|
+
code: error.code,
|
|
3602
|
+
req_id: error.response?.req_id,
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
return result;
|
|
3606
|
+
}
|
|
3607
|
+
finally {
|
|
3608
|
+
oneClickInFlight.delete(inFlightKey);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
async function runSilentPurchaseDetailed(options) {
|
|
3612
|
+
const apiClient = new APIClient({
|
|
3613
|
+
baseUrl: options.baseUrl,
|
|
3614
|
+
orgId: options.orgId,
|
|
3615
|
+
timeout: DEFAULTS.REQUEST_TIMEOUT,
|
|
3616
|
+
retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
|
|
3617
|
+
});
|
|
3618
|
+
let response;
|
|
3619
|
+
try {
|
|
3620
|
+
response = await apiClient.oneClickOnce(buildOneClickRequest(options));
|
|
3621
|
+
}
|
|
3622
|
+
catch (error) {
|
|
3623
|
+
if (error instanceof APIError &&
|
|
3624
|
+
getResponseErrorCodes(error.response).includes(DOUBLE_PURCHASE)) {
|
|
3625
|
+
return {
|
|
3626
|
+
outcome: 'already_purchased',
|
|
3627
|
+
orderId: null,
|
|
3628
|
+
threeDSChallenged: false,
|
|
3629
|
+
};
|
|
3630
|
+
}
|
|
3631
|
+
return {
|
|
3632
|
+
outcome: 'error',
|
|
3633
|
+
orderId: null,
|
|
3634
|
+
threeDSChallenged: false,
|
|
3635
|
+
error: error,
|
|
3636
|
+
failedRequest: 'one_click',
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
const step = mapOneClickResponse(response);
|
|
3640
|
+
if (step.kind === 'result') {
|
|
3641
|
+
return step.result;
|
|
3642
|
+
}
|
|
3643
|
+
const { orderId, actionToken } = step;
|
|
3644
|
+
let ended = false;
|
|
3645
|
+
const end = (result) => {
|
|
3646
|
+
if (ended) {
|
|
3647
|
+
return;
|
|
3648
|
+
}
|
|
3649
|
+
ended = true;
|
|
3650
|
+
callHook('onThreeDSEnd', options.onThreeDSEnd, { result });
|
|
3651
|
+
};
|
|
3652
|
+
callHook('onThreeDSStart', options.onThreeDSStart, { orderId });
|
|
3653
|
+
try {
|
|
3654
|
+
const run = await runOneClickThreeDS({
|
|
3655
|
+
apiClient,
|
|
3656
|
+
region: defaultConfig?.region || DEFAULTS.REGION,
|
|
3657
|
+
priceId: options.priceId,
|
|
3658
|
+
externalId: options.externalId,
|
|
3659
|
+
orderId,
|
|
3660
|
+
actionToken,
|
|
3661
|
+
timeoutMs: options.threeDSTimeoutMs ?? DEFAULT_THREE_DS_TIMEOUT_MS,
|
|
3662
|
+
});
|
|
3663
|
+
const mapped = mapThreeDSRun(run, orderId);
|
|
3664
|
+
end(mapped.threeDS);
|
|
3665
|
+
return mapped.result;
|
|
3666
|
+
}
|
|
3667
|
+
catch (error) {
|
|
3668
|
+
end('error');
|
|
3669
|
+
return {
|
|
3670
|
+
outcome: 'error',
|
|
3671
|
+
orderId,
|
|
3672
|
+
threeDSChallenged: true,
|
|
3673
|
+
error: error instanceof Error
|
|
3674
|
+
? error
|
|
3675
|
+
: new FunnefoxSDKError('One-click 3DS step failed', undefined, error),
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3008
3679
|
async function initMethod(method, element, options) {
|
|
3009
3680
|
try {
|
|
3010
3681
|
const checkoutInstance = new CheckoutInstance({
|
|
@@ -3225,7 +3896,7 @@
|
|
|
3225
3896
|
|
|
3226
3897
|
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";
|
|
3227
3898
|
|
|
3228
|
-
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:
|
|
3899
|
+
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: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n grid-template-rows: repeat(3, auto);\n grid-auto-flow: column;\n column-gap: 10px;\n }\n\n /* Label, input and error of both columns share grid rows, so a label that wraps in one column\n moves both inputs down together, and an error under one input does not move the other. */\n .card-form-row > div {\n display: contents;\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: #df1b41;\n font-size: 15px;\n line-height: 1.15;\n margin: 4px 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";
|
|
3229
3900
|
|
|
3230
3901
|
class CardSkin {
|
|
3231
3902
|
constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
|