@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/README.md
CHANGED
|
@@ -102,6 +102,41 @@ Mounting an Element never creates a Payment Method and never creates or confirms
|
|
|
102
102
|
a payment. The merchant server remains authoritative for the final amount,
|
|
103
103
|
currency, order state, authorization, capture, and fulfillment.
|
|
104
104
|
|
|
105
|
+
### Connected account context
|
|
106
|
+
|
|
107
|
+
Platforms can initialize an Elements client with their platform publishable key
|
|
108
|
+
and the connected account selected for the payment:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { Paypercut } from '@paypercut/checkout-js';
|
|
112
|
+
|
|
113
|
+
const paypercut = Paypercut('pk_live_PLATFORM', {
|
|
114
|
+
account: 'acc_merchant_A',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// The existing object initializer supports the same option:
|
|
118
|
+
// Paypercut({ publishableKey: 'pk_live_PLATFORM', account: 'acc_merchant_A' });
|
|
119
|
+
|
|
120
|
+
const elements = paypercut.elements({
|
|
121
|
+
mode: 'payment',
|
|
122
|
+
amount: 2500,
|
|
123
|
+
currency: 'EUR',
|
|
124
|
+
});
|
|
125
|
+
const card = elements.create('card');
|
|
126
|
+
card.mount('#card-element');
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`account` is optional and fixed for the client lifetime. Every Elements group
|
|
130
|
+
created by that client inherits it, including Card, split card fields, and
|
|
131
|
+
Express Checkout Elements. `createPaymentMethod()`, `confirmPayment()`, and
|
|
132
|
+
`handleNextAction()` use that same context. Omit `account` to use the
|
|
133
|
+
credential's default account. To select another merchant, destroy the previous
|
|
134
|
+
groups and initialize a new client; `elements.update()` cannot change accounts.
|
|
135
|
+
|
|
136
|
+
Your server must use the same account context when using the Payment Method or
|
|
137
|
+
creating the payment resource whose client secret is returned to this client.
|
|
138
|
+
Do not reuse objects from another account.
|
|
139
|
+
|
|
105
140
|
### Developer Assistance
|
|
106
141
|
|
|
107
142
|
The Developer Assistant is an optional configuration preview tool for developers
|
|
@@ -1708,7 +1743,7 @@ Tip: Prefer subscribing with the SdkEvent enum for stronger typing.
|
|
|
1708
1743
|
<body>
|
|
1709
1744
|
<div id="checkout"></div>
|
|
1710
1745
|
|
|
1711
|
-
<script src="https://cdn.jsdelivr.net/npm/@paypercut/checkout-js@1.4.
|
|
1746
|
+
<script src="https://cdn.jsdelivr.net/npm/@paypercut/checkout-js@1.4.3/dist/paypercut-checkout.iife.min.js"></script>
|
|
1712
1747
|
<script>
|
|
1713
1748
|
const checkout = PaypercutCheckout({
|
|
1714
1749
|
id: '01KB23M9EC960C50G3AH14FTTT',
|
package/dist/index.cjs
CHANGED
|
@@ -105,7 +105,7 @@ class Emitter {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const SDK_VERSION = "1.4.
|
|
108
|
+
const SDK_VERSION = "1.4.3";
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Build-time configuration
|
|
@@ -897,6 +897,7 @@ class ExpressCheckoutImpl {
|
|
|
897
897
|
merchantMcc: data.merchant?.mcc ?? '',
|
|
898
898
|
merchantCountry: data.merchant?.country ?? '',
|
|
899
899
|
merchantUrl: data.merchant?.business_url ?? '',
|
|
900
|
+
threeDSecure: data.three_d_secure ?? null,
|
|
900
901
|
};
|
|
901
902
|
}
|
|
902
903
|
catch (err) {
|
|
@@ -1569,6 +1570,7 @@ class ExpressCheckoutImpl {
|
|
|
1569
1570
|
country: this.expressConfig?.merchantCountry ?? '',
|
|
1570
1571
|
url: this.expressConfig?.merchantUrl ?? '',
|
|
1571
1572
|
},
|
|
1573
|
+
threeDSecure: this.expressConfig?.threeDSecure ?? null,
|
|
1572
1574
|
});
|
|
1573
1575
|
};
|
|
1574
1576
|
session.oncancel = () => {
|
|
@@ -1884,6 +1886,7 @@ class ExpressCheckoutImpl {
|
|
|
1884
1886
|
country: this.expressConfig?.merchantCountry ?? '',
|
|
1885
1887
|
url: this.expressConfig?.merchantUrl ?? '',
|
|
1886
1888
|
},
|
|
1889
|
+
threeDSecure: this.expressConfig?.threeDSecure ?? null,
|
|
1887
1890
|
});
|
|
1888
1891
|
});
|
|
1889
1892
|
// 3DS was triggered — sheet already closed, payment method creation handled in message handler
|
|
@@ -3269,6 +3272,7 @@ function buildCardElementFrameUrl(input) {
|
|
|
3269
3272
|
function setSharedParams(params, input, includeKeyMode = true) {
|
|
3270
3273
|
params.set('controllerId', input.controllerId);
|
|
3271
3274
|
params.set('apiKey', input.clientOptions.publishableKey);
|
|
3275
|
+
set(params, 'account', input.clientOptions.account);
|
|
3272
3276
|
if (includeKeyMode)
|
|
3273
3277
|
params.set('keyMode', inferKeyMode(input.clientOptions.publishableKey));
|
|
3274
3278
|
params.set('locale', input.elementsOptions.locale || navigatorLocale());
|
|
@@ -4816,7 +4820,9 @@ class CardElementImpl {
|
|
|
4816
4820
|
border: '0',
|
|
4817
4821
|
display: 'block',
|
|
4818
4822
|
overflow: 'hidden',
|
|
4819
|
-
|
|
4823
|
+
// Hosted Elements uses a normal document color scheme. A mismatch makes
|
|
4824
|
+
// browsers paint an opaque canvas even with transparent html/body styles.
|
|
4825
|
+
colorScheme: 'normal',
|
|
4820
4826
|
transition: 'height 350ms ease-in-out, opacity 400ms ease-in-out 100ms',
|
|
4821
4827
|
willChange: 'height, opacity',
|
|
4822
4828
|
});
|
|
@@ -12793,7 +12799,7 @@ const MAX_CONFIRM_ATTEMPTS = 3;
|
|
|
12793
12799
|
const CLIENT_SECRET_MARKER = '_secret_';
|
|
12794
12800
|
const CLIENT_SECRET_PREFIX_LENGTH = 3;
|
|
12795
12801
|
const MAX_CLIENT_SECRET_LENGTH = 4096;
|
|
12796
|
-
// Shared with
|
|
12802
|
+
// Shared with Paypercut's payment-resource client-secret issuer. Checkout IDs are
|
|
12797
12803
|
// embedded only so the SDK can address the authoritative resource; merchants
|
|
12798
12804
|
// must continue to treat the complete client secret as opaque.
|
|
12799
12805
|
const MAX_RESOURCE_ID_LENGTH = 200;
|
|
@@ -13011,6 +13017,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13011
13017
|
this.billingDetailsFor = billingDetailsFor;
|
|
13012
13018
|
this.inFlight = new Map();
|
|
13013
13019
|
this.activeAction = null;
|
|
13020
|
+
this.account = options.account;
|
|
13014
13021
|
this.apiUrl = getApiOrigin(options.apiUrl);
|
|
13015
13022
|
this.hostedOrigin = new URL(getCheckoutOrigin(options.hostedCheckoutUrl)).origin;
|
|
13016
13023
|
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));
|
|
@@ -13088,6 +13095,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13088
13095
|
method: 'GET',
|
|
13089
13096
|
headers: {
|
|
13090
13097
|
Accept: 'application/json',
|
|
13098
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13091
13099
|
},
|
|
13092
13100
|
}, 'elements_checkout_status_failed', { deadlineAt });
|
|
13093
13101
|
return parseCheckoutStatus(value, parsed.checkoutSessionId);
|
|
@@ -13101,6 +13109,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13101
13109
|
Accept: 'application/json',
|
|
13102
13110
|
'Content-Type': 'application/json',
|
|
13103
13111
|
'Idempotency-Key': idempotencyKey,
|
|
13112
|
+
...(this.account !== undefined ? { 'Paypercut-Account': this.account } : {}),
|
|
13104
13113
|
},
|
|
13105
13114
|
body: JSON.stringify({
|
|
13106
13115
|
key: this.publishableKey,
|
|
@@ -13181,6 +13190,7 @@ class PaymentConfirmationCoordinator {
|
|
|
13181
13190
|
payload: {
|
|
13182
13191
|
protocolVersion: ELEMENTS_PAYMENT_CONFIRMATION_PROTOCOL_VERSION,
|
|
13183
13192
|
publishableKey: this.publishableKey,
|
|
13193
|
+
...(this.account !== undefined ? { account: this.account } : {}),
|
|
13184
13194
|
apiUrl: this.apiUrl,
|
|
13185
13195
|
sdkVersion: config.version,
|
|
13186
13196
|
deadlineAt,
|
|
@@ -13256,6 +13266,7 @@ class PaypercutImpl {
|
|
|
13256
13266
|
this.paymentConfirmation = null;
|
|
13257
13267
|
this.configurationIdentity = JSON.stringify([
|
|
13258
13268
|
options.publishableKey,
|
|
13269
|
+
options.account ?? null,
|
|
13259
13270
|
getApiOrigin(options.apiUrl),
|
|
13260
13271
|
getCheckoutOrigin(options.hostedCheckoutUrl),
|
|
13261
13272
|
]);
|
|
@@ -13329,6 +13340,7 @@ class PaypercutImpl {
|
|
|
13329
13340
|
return Promise.reject(createSubmitError('elements_client_secret_invalid', 'confirmPayment requires only a Checkout Session clientSecret.', false));
|
|
13330
13341
|
}
|
|
13331
13342
|
this.paymentConfirmation ?? (this.paymentConfirmation = new PaymentConfirmationCoordinator(this.options.publishableKey, {
|
|
13343
|
+
...(this.options.account !== undefined ? { account: this.options.account } : {}),
|
|
13332
13344
|
...(this.options.apiUrl ? { apiUrl: this.options.apiUrl } : {}),
|
|
13333
13345
|
...(this.options.hostedCheckoutUrl
|
|
13334
13346
|
? { hostedCheckoutUrl: this.options.hostedCheckoutUrl }
|
|
@@ -13340,12 +13352,22 @@ class PaypercutImpl {
|
|
|
13340
13352
|
function isSetupFutureUsage(value) {
|
|
13341
13353
|
return value === undefined || value === 'on_session' || value === 'off_session';
|
|
13342
13354
|
}
|
|
13343
|
-
const Paypercut = function (options) {
|
|
13344
|
-
|
|
13355
|
+
const Paypercut = function (optionsOrKey, options) {
|
|
13356
|
+
if (typeof optionsOrKey === 'string') {
|
|
13357
|
+
if (options !== undefined &&
|
|
13358
|
+
(!options || typeof options !== 'object' || Array.isArray(options))) {
|
|
13359
|
+
throw new Error('[Paypercut Elements] Client options must be an object.');
|
|
13360
|
+
}
|
|
13361
|
+
return new PaypercutImpl(validateClientOptions({ ...options, publishableKey: optionsOrKey }));
|
|
13362
|
+
}
|
|
13363
|
+
if (options !== undefined) {
|
|
13364
|
+
throw new Error('[Paypercut Elements] Pass client options in one initializer object.');
|
|
13365
|
+
}
|
|
13366
|
+
return new PaypercutImpl(validateClientOptions(optionsOrKey));
|
|
13345
13367
|
};
|
|
13346
13368
|
Paypercut.version = config.version;
|
|
13347
13369
|
function validateClientOptions(options) {
|
|
13348
|
-
if (!options || typeof options !== 'object') {
|
|
13370
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
13349
13371
|
throw new Error('[Paypercut Elements] Client options are required.');
|
|
13350
13372
|
}
|
|
13351
13373
|
const publishableKey = options.publishableKey;
|