@paypercut/checkout-js 1.4.1 → 1.4.2
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 +36 -1
- package/dist/developer-assistance.cjs +1 -1
- package/dist/developer-assistance.mjs +1 -1
- package/dist/index.cjs +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +25 -5
- 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 +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -482,8 +482,14 @@ interface ExpressCheckoutStatic {
|
|
|
482
482
|
|
|
483
483
|
/** Options used to initialise the Paypercut browser client. */
|
|
484
484
|
interface PaypercutOptions {
|
|
485
|
-
/** Public browser credential. The value is opaque;
|
|
485
|
+
/** Public browser credential. The value is opaque; Paypercut resolves its account and livemode. */
|
|
486
486
|
publishableKey: string;
|
|
487
|
+
/**
|
|
488
|
+
* Optional opaque connected account context for this client and all its Elements groups.
|
|
489
|
+
* The platform publishable key authenticates the request; Paypercut validates and authorizes the account.
|
|
490
|
+
* Omit to use the credential's default account. Create a new client to change accounts.
|
|
491
|
+
*/
|
|
492
|
+
account?: string;
|
|
487
493
|
/** Internal builds only. Production builds ignore this override. */
|
|
488
494
|
hostedCheckoutUrl?: string;
|
|
489
495
|
/** Internal builds only. Production builds ignore this override. */
|
|
@@ -881,6 +887,7 @@ interface PaypercutInstance {
|
|
|
881
887
|
}
|
|
882
888
|
interface PaypercutStatic {
|
|
883
889
|
(options: PaypercutOptions): PaypercutInstance;
|
|
890
|
+
(publishableKey: string, options?: Omit<PaypercutOptions, 'publishableKey'>): PaypercutInstance;
|
|
884
891
|
version: string;
|
|
885
892
|
}
|
|
886
893
|
|
package/dist/index.d.mts
CHANGED
|
@@ -482,8 +482,14 @@ interface ExpressCheckoutStatic {
|
|
|
482
482
|
|
|
483
483
|
/** Options used to initialise the Paypercut browser client. */
|
|
484
484
|
interface PaypercutOptions {
|
|
485
|
-
/** Public browser credential. The value is opaque;
|
|
485
|
+
/** Public browser credential. The value is opaque; Paypercut resolves its account and livemode. */
|
|
486
486
|
publishableKey: string;
|
|
487
|
+
/**
|
|
488
|
+
* Optional opaque connected account context for this client and all its Elements groups.
|
|
489
|
+
* The platform publishable key authenticates the request; Paypercut validates and authorizes the account.
|
|
490
|
+
* Omit to use the credential's default account. Create a new client to change accounts.
|
|
491
|
+
*/
|
|
492
|
+
account?: string;
|
|
487
493
|
/** Internal builds only. Production builds ignore this override. */
|
|
488
494
|
hostedCheckoutUrl?: string;
|
|
489
495
|
/** Internal builds only. Production builds ignore this override. */
|
|
@@ -881,6 +887,7 @@ interface PaypercutInstance {
|
|
|
881
887
|
}
|
|
882
888
|
interface PaypercutStatic {
|
|
883
889
|
(options: PaypercutOptions): PaypercutInstance;
|
|
890
|
+
(publishableKey: string, options?: Omit<PaypercutOptions, 'publishableKey'>): PaypercutInstance;
|
|
884
891
|
version: string;
|
|
885
892
|
}
|
|
886
893
|
|
package/dist/index.d.ts
CHANGED
|
@@ -482,8 +482,14 @@ interface ExpressCheckoutStatic {
|
|
|
482
482
|
|
|
483
483
|
/** Options used to initialise the Paypercut browser client. */
|
|
484
484
|
interface PaypercutOptions {
|
|
485
|
-
/** Public browser credential. The value is opaque;
|
|
485
|
+
/** Public browser credential. The value is opaque; Paypercut resolves its account and livemode. */
|
|
486
486
|
publishableKey: string;
|
|
487
|
+
/**
|
|
488
|
+
* Optional opaque connected account context for this client and all its Elements groups.
|
|
489
|
+
* The platform publishable key authenticates the request; Paypercut validates and authorizes the account.
|
|
490
|
+
* Omit to use the credential's default account. Create a new client to change accounts.
|
|
491
|
+
*/
|
|
492
|
+
account?: string;
|
|
487
493
|
/** Internal builds only. Production builds ignore this override. */
|
|
488
494
|
hostedCheckoutUrl?: string;
|
|
489
495
|
/** Internal builds only. Production builds ignore this override. */
|
|
@@ -881,6 +887,7 @@ interface PaypercutInstance {
|
|
|
881
887
|
}
|
|
882
888
|
interface PaypercutStatic {
|
|
883
889
|
(options: PaypercutOptions): PaypercutInstance;
|
|
890
|
+
(publishableKey: string, options?: Omit<PaypercutOptions, 'publishableKey'>): PaypercutInstance;
|
|
884
891
|
version: string;
|
|
885
892
|
}
|
|
886
893
|
|
package/dist/index.mjs
CHANGED
|
@@ -100,7 +100,7 @@ class Emitter {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const SDK_VERSION = "1.4.
|
|
103
|
+
const SDK_VERSION = "1.4.2";
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Build-time configuration
|
|
@@ -892,6 +892,7 @@ class ExpressCheckoutImpl {
|
|
|
892
892
|
merchantMcc: data.merchant?.mcc ?? '',
|
|
893
893
|
merchantCountry: data.merchant?.country ?? '',
|
|
894
894
|
merchantUrl: data.merchant?.business_url ?? '',
|
|
895
|
+
threeDSecure: data.three_d_secure ?? null,
|
|
895
896
|
};
|
|
896
897
|
}
|
|
897
898
|
catch (err) {
|
|
@@ -1564,6 +1565,7 @@ class ExpressCheckoutImpl {
|
|
|
1564
1565
|
country: this.expressConfig?.merchantCountry ?? '',
|
|
1565
1566
|
url: this.expressConfig?.merchantUrl ?? '',
|
|
1566
1567
|
},
|
|
1568
|
+
threeDSecure: this.expressConfig?.threeDSecure ?? null,
|
|
1567
1569
|
});
|
|
1568
1570
|
};
|
|
1569
1571
|
session.oncancel = () => {
|
|
@@ -1879,6 +1881,7 @@ class ExpressCheckoutImpl {
|
|
|
1879
1881
|
country: this.expressConfig?.merchantCountry ?? '',
|
|
1880
1882
|
url: this.expressConfig?.merchantUrl ?? '',
|
|
1881
1883
|
},
|
|
1884
|
+
threeDSecure: this.expressConfig?.threeDSecure ?? null,
|
|
1882
1885
|
});
|
|
1883
1886
|
});
|
|
1884
1887
|
// 3DS was triggered — sheet already closed, payment method creation handled in message handler
|
|
@@ -3264,6 +3267,7 @@ function buildCardElementFrameUrl(input) {
|
|
|
3264
3267
|
function setSharedParams(params, input, includeKeyMode = true) {
|
|
3265
3268
|
params.set('controllerId', input.controllerId);
|
|
3266
3269
|
params.set('apiKey', input.clientOptions.publishableKey);
|
|
3270
|
+
set(params, 'account', input.clientOptions.account);
|
|
3267
3271
|
if (includeKeyMode)
|
|
3268
3272
|
params.set('keyMode', inferKeyMode(input.clientOptions.publishableKey));
|
|
3269
3273
|
params.set('locale', input.elementsOptions.locale || navigatorLocale());
|
|
@@ -12788,7 +12792,7 @@ const MAX_CONFIRM_ATTEMPTS = 3;
|
|
|
12788
12792
|
const CLIENT_SECRET_MARKER = '_secret_';
|
|
12789
12793
|
const CLIENT_SECRET_PREFIX_LENGTH = 3;
|
|
12790
12794
|
const MAX_CLIENT_SECRET_LENGTH = 4096;
|
|
12791
|
-
// Shared with
|
|
12795
|
+
// Shared with Paypercut's payment-resource client-secret issuer. Checkout IDs are
|
|
12792
12796
|
// embedded only so the SDK can address the authoritative resource; merchants
|
|
12793
12797
|
// must continue to treat the complete client secret as opaque.
|
|
12794
12798
|
const MAX_RESOURCE_ID_LENGTH = 200;
|
|
@@ -13006,6 +13010,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13006
13010
|
this.billingDetailsFor = billingDetailsFor;
|
|
13007
13011
|
this.inFlight = new Map();
|
|
13008
13012
|
this.activeAction = null;
|
|
13013
|
+
this.account = options.account;
|
|
13009
13014
|
this.apiUrl = getApiOrigin(options.apiUrl);
|
|
13010
13015
|
this.hostedOrigin = new URL(getCheckoutOrigin(options.hostedCheckoutUrl)).origin;
|
|
13011
13016
|
this.actionShell = new ElementsActionShell(this.hostedOrigin, (actionId) => this.rejectActiveAction(actionId, 'elements_action_canceled', 'Payment authentication was canceled.', true), (actionId, code, message, recoverable) => this.rejectActiveAction(actionId, code, message, recoverable));
|
|
@@ -13083,6 +13088,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13083
13088
|
method: 'GET',
|
|
13084
13089
|
headers: {
|
|
13085
13090
|
Accept: 'application/json',
|
|
13091
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13086
13092
|
},
|
|
13087
13093
|
}, 'elements_checkout_status_failed', { deadlineAt });
|
|
13088
13094
|
return parseCheckoutStatus(value, parsed.checkoutSessionId);
|
|
@@ -13096,6 +13102,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13096
13102
|
Accept: 'application/json',
|
|
13097
13103
|
'Content-Type': 'application/json',
|
|
13098
13104
|
'Idempotency-Key': idempotencyKey,
|
|
13105
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13099
13106
|
},
|
|
13100
13107
|
body: JSON.stringify({
|
|
13101
13108
|
key: this.publishableKey,
|
|
@@ -13176,6 +13183,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13176
13183
|
payload: {
|
|
13177
13184
|
protocolVersion: ELEMENTS_PAYMENT_CONFIRMATION_PROTOCOL_VERSION,
|
|
13178
13185
|
publishableKey: this.publishableKey,
|
|
13186
|
+
...(this.account !== undefined ? { account: this.account } : {}),
|
|
13179
13187
|
apiUrl: this.apiUrl,
|
|
13180
13188
|
sdkVersion: config.version,
|
|
13181
13189
|
deadlineAt,
|
|
@@ -13251,6 +13259,7 @@ class PaypercutImpl {
|
|
|
13251
13259
|
this.paymentConfirmation = null;
|
|
13252
13260
|
this.configurationIdentity = JSON.stringify([
|
|
13253
13261
|
options.publishableKey,
|
|
13262
|
+
options.account ?? null,
|
|
13254
13263
|
getApiOrigin(options.apiUrl),
|
|
13255
13264
|
getCheckoutOrigin(options.hostedCheckoutUrl),
|
|
13256
13265
|
]);
|
|
@@ -13324,6 +13333,7 @@ class PaypercutImpl {
|
|
|
13324
13333
|
return Promise.reject(createSubmitError('elements_client_secret_invalid', 'confirmPayment requires only a Checkout Session clientSecret.', false));
|
|
13325
13334
|
}
|
|
13326
13335
|
this.paymentConfirmation ?? (this.paymentConfirmation = new PaymentConfirmationCoordinator(this.options.publishableKey, {
|
|
13336
|
+
...(this.options.account !== undefined ? { account: this.options.account } : {}),
|
|
13327
13337
|
...(this.options.apiUrl ? { apiUrl: this.options.apiUrl } : {}),
|
|
13328
13338
|
...(this.options.hostedCheckoutUrl
|
|
13329
13339
|
? { hostedCheckoutUrl: this.options.hostedCheckoutUrl }
|
|
@@ -13335,12 +13345,22 @@ class PaypercutImpl {
|
|
|
13335
13345
|
function isSetupFutureUsage(value) {
|
|
13336
13346
|
return value === undefined || value === 'on_session' || value === 'off_session';
|
|
13337
13347
|
}
|
|
13338
|
-
const Paypercut = function (options) {
|
|
13339
|
-
|
|
13348
|
+
const Paypercut = function (optionsOrKey, options) {
|
|
13349
|
+
if (typeof optionsOrKey === 'string') {
|
|
13350
|
+
if (options !== undefined &&
|
|
13351
|
+
(!options || typeof options !== 'object' || Array.isArray(options))) {
|
|
13352
|
+
throw new Error('[Paypercut Elements] Client options must be an object.');
|
|
13353
|
+
}
|
|
13354
|
+
return new PaypercutImpl(validateClientOptions({ ...options, publishableKey: optionsOrKey }));
|
|
13355
|
+
}
|
|
13356
|
+
if (options !== undefined) {
|
|
13357
|
+
throw new Error('[Paypercut Elements] Pass client options in one initializer object.');
|
|
13358
|
+
}
|
|
13359
|
+
return new PaypercutImpl(validateClientOptions(optionsOrKey));
|
|
13340
13360
|
};
|
|
13341
13361
|
Paypercut.version = config.version;
|
|
13342
13362
|
function validateClientOptions(options) {
|
|
13343
|
-
if (!options || typeof options !== 'object') {
|
|
13363
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
13344
13364
|
throw new Error('[Paypercut Elements] Client options are required.');
|
|
13345
13365
|
}
|
|
13346
13366
|
const publishableKey = options.publishableKey;
|