swell-js 4.1.2 → 4.2.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/dist/api.mjs +2 -2
- package/dist/attributes.mjs +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/card.mjs +1 -1
- package/dist/cart.mjs +1 -1
- package/dist/categories.mjs +1 -1
- package/dist/content.mjs +1 -1
- package/dist/cookie.mjs +1 -1
- package/dist/{index.f58acfb6.mjs → index.738bc14a.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/payment.mjs +52 -59
- package/dist/products.mjs +1 -1
- package/dist/settings.mjs +1 -1
- package/dist/subscriptions.mjs +1 -1
- package/dist/swell.cjs +52 -59
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +52 -59
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
package/dist/swell.umd.min.js
CHANGED
|
@@ -12337,44 +12337,6 @@
|
|
|
12337
12337
|
return details;
|
|
12338
12338
|
}
|
|
12339
12339
|
|
|
12340
|
-
/**
|
|
12341
|
-
* @param {CreateSourceData} source
|
|
12342
|
-
* @param {object} data
|
|
12343
|
-
*/
|
|
12344
|
-
function setBancontactOwner(source, data) {
|
|
12345
|
-
const fillValues = (fieldsMap, data) =>
|
|
12346
|
-
reduce(
|
|
12347
|
-
fieldsMap,
|
|
12348
|
-
(acc, srcKey, destKey) => {
|
|
12349
|
-
const value = data[srcKey];
|
|
12350
|
-
if (value) {
|
|
12351
|
-
acc[destKey] = value;
|
|
12352
|
-
}
|
|
12353
|
-
return acc;
|
|
12354
|
-
},
|
|
12355
|
-
{},
|
|
12356
|
-
);
|
|
12357
|
-
const { account = {}, billing, shipping } = data;
|
|
12358
|
-
const billingData = {
|
|
12359
|
-
...account.shipping,
|
|
12360
|
-
...account.billing,
|
|
12361
|
-
...shipping,
|
|
12362
|
-
...billing,
|
|
12363
|
-
};
|
|
12364
|
-
const billingAddress = fillValues(addressFieldsMap$1, billingData);
|
|
12365
|
-
|
|
12366
|
-
source.owner = {
|
|
12367
|
-
email: account.email,
|
|
12368
|
-
name: billingData.name || account.name,
|
|
12369
|
-
...(billingData.phone
|
|
12370
|
-
? { phone: billingData.phone }
|
|
12371
|
-
: account.phone
|
|
12372
|
-
? { phone: account.phone }
|
|
12373
|
-
: undefined),
|
|
12374
|
-
...(!isEmpty(billingAddress) ? { address: billingAddress } : undefined),
|
|
12375
|
-
};
|
|
12376
|
-
}
|
|
12377
|
-
|
|
12378
12340
|
/**
|
|
12379
12341
|
* @param {string} type
|
|
12380
12342
|
* @param {import('@stripe/stripe-js').StripeElements} elements
|
|
@@ -12479,23 +12441,23 @@
|
|
|
12479
12441
|
}
|
|
12480
12442
|
|
|
12481
12443
|
/**
|
|
12482
|
-
*
|
|
12444
|
+
* Returns Bancontact Setup Intent confirmation details.
|
|
12445
|
+
*
|
|
12483
12446
|
* @param {object} cart
|
|
12447
|
+
* @returns {import('@stripe/stripe-js').ConfirmBancontactPaymentData}
|
|
12484
12448
|
*/
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
const
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12449
|
+
function getBancontactConfirmationDetails(cart) {
|
|
12450
|
+
const billingDetails = getBillingDetails(cart);
|
|
12451
|
+
const returnUrl = `${
|
|
12452
|
+
window.location.origin + window.location.pathname
|
|
12453
|
+
}?gateway=stripe`;
|
|
12454
|
+
|
|
12455
|
+
return {
|
|
12456
|
+
payment_method: {
|
|
12457
|
+
billing_details: billingDetails,
|
|
12493
12458
|
},
|
|
12459
|
+
return_url: returnUrl,
|
|
12494
12460
|
};
|
|
12495
|
-
|
|
12496
|
-
setBancontactOwner(sourceObject, cart);
|
|
12497
|
-
|
|
12498
|
-
return stripe.createSource(sourceObject);
|
|
12499
12461
|
}
|
|
12500
12462
|
|
|
12501
12463
|
/**
|
|
@@ -12946,25 +12908,56 @@
|
|
|
12946
12908
|
}
|
|
12947
12909
|
|
|
12948
12910
|
async tokenize() {
|
|
12911
|
+
const cart = await this.getCart();
|
|
12912
|
+
const intent = await this.createIntent({
|
|
12913
|
+
gateway: 'stripe',
|
|
12914
|
+
action: 'setup',
|
|
12915
|
+
account_id: cart.account_id,
|
|
12916
|
+
intent: {
|
|
12917
|
+
payment_method_types: ['bancontact'],
|
|
12918
|
+
usage: 'off_session',
|
|
12919
|
+
},
|
|
12920
|
+
});
|
|
12921
|
+
|
|
12949
12922
|
await this.loadScripts(this.scripts);
|
|
12950
12923
|
|
|
12951
|
-
const
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12924
|
+
const { error } = await this.stripe.confirmBancontactSetup(
|
|
12925
|
+
intent.client_secret,
|
|
12926
|
+
getBancontactConfirmationDetails(cart),
|
|
12927
|
+
);
|
|
12928
|
+
|
|
12929
|
+
if (error) {
|
|
12930
|
+
throw new Error(error.message);
|
|
12931
|
+
}
|
|
12932
|
+
}
|
|
12933
|
+
|
|
12934
|
+
async handleRedirect(queryParams) {
|
|
12935
|
+
const { redirect_status, setup_intent_client_secret } = queryParams;
|
|
12936
|
+
|
|
12937
|
+
if (redirect_status !== 'succeeded') {
|
|
12938
|
+
throw new UnableAuthenticatePaymentMethodError();
|
|
12939
|
+
}
|
|
12940
|
+
|
|
12941
|
+
await this.loadScripts(this.scripts);
|
|
12942
|
+
|
|
12943
|
+
const { setupIntent, error } = await this.stripe.retrieveSetupIntent(
|
|
12944
|
+
setup_intent_client_secret,
|
|
12955
12945
|
);
|
|
12956
12946
|
|
|
12957
|
-
if (
|
|
12958
|
-
throw new Error(
|
|
12947
|
+
if (error) {
|
|
12948
|
+
throw new Error(error.message);
|
|
12959
12949
|
}
|
|
12960
12950
|
|
|
12961
12951
|
await this.updateCart({
|
|
12962
12952
|
billing: {
|
|
12963
12953
|
method: 'bancontact',
|
|
12954
|
+
bancontact: {
|
|
12955
|
+
token: setupIntent.id,
|
|
12956
|
+
},
|
|
12964
12957
|
},
|
|
12965
12958
|
});
|
|
12966
12959
|
|
|
12967
|
-
|
|
12960
|
+
this.onSuccess();
|
|
12968
12961
|
}
|
|
12969
12962
|
}
|
|
12970
12963
|
|
|
@@ -15609,7 +15602,7 @@
|
|
|
15609
15602
|
};
|
|
15610
15603
|
|
|
15611
15604
|
const api = {
|
|
15612
|
-
version: '4.
|
|
15605
|
+
version: '4.2.0',
|
|
15613
15606
|
options,
|
|
15614
15607
|
request,
|
|
15615
15608
|
|