@paypercut/checkout-js 1.4.1 → 1.4.3
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 +28 -6
- 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 +28 -6
- 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.3";
|
|
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());
|
|
@@ -4811,7 +4815,9 @@ class CardElementImpl {
|
|
|
4811
4815
|
border: '0',
|
|
4812
4816
|
display: 'block',
|
|
4813
4817
|
overflow: 'hidden',
|
|
4814
|
-
|
|
4818
|
+
// Hosted Elements uses a normal document color scheme. A mismatch makes
|
|
4819
|
+
// browsers paint an opaque canvas even with transparent html/body styles.
|
|
4820
|
+
colorScheme: 'normal',
|
|
4815
4821
|
transition: 'height 350ms ease-in-out, opacity 400ms ease-in-out 100ms',
|
|
4816
4822
|
willChange: 'height, opacity',
|
|
4817
4823
|
});
|
|
@@ -12788,7 +12794,7 @@ const MAX_CONFIRM_ATTEMPTS = 3;
|
|
|
12788
12794
|
const CLIENT_SECRET_MARKER = '_secret_';
|
|
12789
12795
|
const CLIENT_SECRET_PREFIX_LENGTH = 3;
|
|
12790
12796
|
const MAX_CLIENT_SECRET_LENGTH = 4096;
|
|
12791
|
-
// Shared with
|
|
12797
|
+
// Shared with Paypercut's payment-resource client-secret issuer. Checkout IDs are
|
|
12792
12798
|
// embedded only so the SDK can address the authoritative resource; merchants
|
|
12793
12799
|
// must continue to treat the complete client secret as opaque.
|
|
12794
12800
|
const MAX_RESOURCE_ID_LENGTH = 200;
|
|
@@ -13006,6 +13012,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13006
13012
|
this.billingDetailsFor = billingDetailsFor;
|
|
13007
13013
|
this.inFlight = new Map();
|
|
13008
13014
|
this.activeAction = null;
|
|
13015
|
+
this.account = options.account;
|
|
13009
13016
|
this.apiUrl = getApiOrigin(options.apiUrl);
|
|
13010
13017
|
this.hostedOrigin = new URL(getCheckoutOrigin(options.hostedCheckoutUrl)).origin;
|
|
13011
13018
|
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 +13090,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13083
13090
|
method: 'GET',
|
|
13084
13091
|
headers: {
|
|
13085
13092
|
Accept: 'application/json',
|
|
13093
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13086
13094
|
},
|
|
13087
13095
|
}, 'elements_checkout_status_failed', { deadlineAt });
|
|
13088
13096
|
return parseCheckoutStatus(value, parsed.checkoutSessionId);
|
|
@@ -13096,6 +13104,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13096
13104
|
Accept: 'application/json',
|
|
13097
13105
|
'Content-Type': 'application/json',
|
|
13098
13106
|
'Idempotency-Key': idempotencyKey,
|
|
13107
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13099
13108
|
},
|
|
13100
13109
|
body: JSON.stringify({
|
|
13101
13110
|
key: this.publishableKey,
|
|
@@ -13176,6 +13185,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13176
13185
|
payload: {
|
|
13177
13186
|
protocolVersion: ELEMENTS_PAYMENT_CONFIRMATION_PROTOCOL_VERSION,
|
|
13178
13187
|
publishableKey: this.publishableKey,
|
|
13188
|
+
...(this.account !== undefined ? { account: this.account } : {}),
|
|
13179
13189
|
apiUrl: this.apiUrl,
|
|
13180
13190
|
sdkVersion: config.version,
|
|
13181
13191
|
deadlineAt,
|
|
@@ -13251,6 +13261,7 @@ class PaypercutImpl {
|
|
|
13251
13261
|
this.paymentConfirmation = null;
|
|
13252
13262
|
this.configurationIdentity = JSON.stringify([
|
|
13253
13263
|
options.publishableKey,
|
|
13264
|
+
options.account ?? null,
|
|
13254
13265
|
getApiOrigin(options.apiUrl),
|
|
13255
13266
|
getCheckoutOrigin(options.hostedCheckoutUrl),
|
|
13256
13267
|
]);
|
|
@@ -13324,6 +13335,7 @@ class PaypercutImpl {
|
|
|
13324
13335
|
return Promise.reject(createSubmitError('elements_client_secret_invalid', 'confirmPayment requires only a Checkout Session clientSecret.', false));
|
|
13325
13336
|
}
|
|
13326
13337
|
this.paymentConfirmation ?? (this.paymentConfirmation = new PaymentConfirmationCoordinator(this.options.publishableKey, {
|
|
13338
|
+
...(this.options.account !== undefined ? { account: this.options.account } : {}),
|
|
13327
13339
|
...(this.options.apiUrl ? { apiUrl: this.options.apiUrl } : {}),
|
|
13328
13340
|
...(this.options.hostedCheckoutUrl
|
|
13329
13341
|
? { hostedCheckoutUrl: this.options.hostedCheckoutUrl }
|
|
@@ -13335,12 +13347,22 @@ class PaypercutImpl {
|
|
|
13335
13347
|
function isSetupFutureUsage(value) {
|
|
13336
13348
|
return value === undefined || value === 'on_session' || value === 'off_session';
|
|
13337
13349
|
}
|
|
13338
|
-
const Paypercut = function (options) {
|
|
13339
|
-
|
|
13350
|
+
const Paypercut = function (optionsOrKey, options) {
|
|
13351
|
+
if (typeof optionsOrKey === 'string') {
|
|
13352
|
+
if (options !== undefined &&
|
|
13353
|
+
(!options || typeof options !== 'object' || Array.isArray(options))) {
|
|
13354
|
+
throw new Error('[Paypercut Elements] Client options must be an object.');
|
|
13355
|
+
}
|
|
13356
|
+
return new PaypercutImpl(validateClientOptions({ ...options, publishableKey: optionsOrKey }));
|
|
13357
|
+
}
|
|
13358
|
+
if (options !== undefined) {
|
|
13359
|
+
throw new Error('[Paypercut Elements] Pass client options in one initializer object.');
|
|
13360
|
+
}
|
|
13361
|
+
return new PaypercutImpl(validateClientOptions(optionsOrKey));
|
|
13340
13362
|
};
|
|
13341
13363
|
Paypercut.version = config.version;
|
|
13342
13364
|
function validateClientOptions(options) {
|
|
13343
|
-
if (!options || typeof options !== 'object') {
|
|
13365
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
13344
13366
|
throw new Error('[Paypercut Elements] Client options are required.');
|
|
13345
13367
|
}
|
|
13346
13368
|
const publishableKey = options.publishableKey;
|