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/api.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import methods$5 from './products.mjs';
|
|
|
7
7
|
import methods$6 from './categories.mjs';
|
|
8
8
|
import methods$7 from './attributes.mjs';
|
|
9
9
|
import methods$8 from './subscriptions.mjs';
|
|
10
|
-
import { d as defaultMethods,
|
|
10
|
+
import { d as defaultMethods, y as trimEnd, z as utils, A as trimStart, B as trimBoth, t as toSnake, C as stringifyQuery, D as base64Encode, a as toCamel, E as setOptions } from './index.738bc14a.mjs';
|
|
11
11
|
import methods$9 from './content.mjs';
|
|
12
12
|
import methods$a from './settings.mjs';
|
|
13
13
|
import PaymentController from './payment.mjs';
|
|
@@ -135,7 +135,7 @@ const options = {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
const api = {
|
|
138
|
-
version: '4.
|
|
138
|
+
version: '4.2.0',
|
|
139
139
|
options,
|
|
140
140
|
request,
|
|
141
141
|
|
package/dist/attributes.mjs
CHANGED
package/dist/cache.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.
|
|
1
|
+
import { s as set, m as merge, a as toCamel, h as toCamelPath, j as getOptions } from './index.738bc14a.mjs';
|
|
2
2
|
import { g as get } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import './round.577a8441.mjs';
|
package/dist/card.mjs
CHANGED
package/dist/cart.mjs
CHANGED
package/dist/categories.mjs
CHANGED
package/dist/content.mjs
CHANGED
package/dist/cookie.mjs
CHANGED
|
@@ -1804,4 +1804,4 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1804
1804
|
vaultRequest
|
|
1805
1805
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1806
1806
|
|
|
1807
|
-
export {
|
|
1807
|
+
export { trimStart as A, trimBoth as B, stringifyQuery as C, base64Encode as D, setOptions as E, toLower as F, toCamel as a, isObject as b, cloneDeep as c, defaultMethods as d, camelCase as e, snakeCase as f, isEqual as g, toCamelPath as h, isServer as i, getOptions as j, isFunction as k, loadScript as l, merge as m, isEmpty as n, isLiveMode as o, pick$1 as p, map as q, reduce as r, set as s, toSnake as t, uniq as u, vaultRequest as v, getLocationParams as w, removeUrlParams as x, trimEnd as y, utils as z };
|
package/dist/index.mjs
CHANGED
package/dist/payment.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import methods from './cart.mjs';
|
|
2
2
|
import methods$1 from './settings.mjs';
|
|
3
|
-
import { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, t as toSnake, v as vaultRequest, p as pick, n as
|
|
3
|
+
import { b as isObject, k as isFunction, l as loadScript, c as cloneDeep, t as toSnake, v as vaultRequest, p as pick, n as isEmpty, o as isLiveMode, q as map, r as reduce, w as getLocationParams, x as removeUrlParams, a as toCamel } from './index.738bc14a.mjs';
|
|
4
4
|
import { g as get, t as toNumber } from './find.18f1ac6d.mjs';
|
|
5
5
|
import 'qs';
|
|
6
6
|
import 'deepmerge';
|
|
@@ -615,44 +615,6 @@ function getBillingDetails(cart) {
|
|
|
615
615
|
return details;
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
/**
|
|
619
|
-
* @param {CreateSourceData} source
|
|
620
|
-
* @param {object} data
|
|
621
|
-
*/
|
|
622
|
-
function setBancontactOwner(source, data) {
|
|
623
|
-
const fillValues = (fieldsMap, data) =>
|
|
624
|
-
reduce(
|
|
625
|
-
fieldsMap,
|
|
626
|
-
(acc, srcKey, destKey) => {
|
|
627
|
-
const value = data[srcKey];
|
|
628
|
-
if (value) {
|
|
629
|
-
acc[destKey] = value;
|
|
630
|
-
}
|
|
631
|
-
return acc;
|
|
632
|
-
},
|
|
633
|
-
{},
|
|
634
|
-
);
|
|
635
|
-
const { account = {}, billing, shipping } = data;
|
|
636
|
-
const billingData = {
|
|
637
|
-
...account.shipping,
|
|
638
|
-
...account.billing,
|
|
639
|
-
...shipping,
|
|
640
|
-
...billing,
|
|
641
|
-
};
|
|
642
|
-
const billingAddress = fillValues(addressFieldsMap$1, billingData);
|
|
643
|
-
|
|
644
|
-
source.owner = {
|
|
645
|
-
email: account.email,
|
|
646
|
-
name: billingData.name || account.name,
|
|
647
|
-
...(billingData.phone
|
|
648
|
-
? { phone: billingData.phone }
|
|
649
|
-
: account.phone
|
|
650
|
-
? { phone: account.phone }
|
|
651
|
-
: undefined),
|
|
652
|
-
...(!isEmpty(billingAddress) ? { address: billingAddress } : undefined),
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
|
|
656
618
|
/**
|
|
657
619
|
* @param {string} type
|
|
658
620
|
* @param {import('@stripe/stripe-js').StripeElements} elements
|
|
@@ -757,23 +719,23 @@ function getKlarnaConfirmationDetails(cart) {
|
|
|
757
719
|
}
|
|
758
720
|
|
|
759
721
|
/**
|
|
760
|
-
*
|
|
722
|
+
* Returns Bancontact Setup Intent confirmation details.
|
|
723
|
+
*
|
|
761
724
|
* @param {object} cart
|
|
725
|
+
* @returns {import('@stripe/stripe-js').ConfirmBancontactPaymentData}
|
|
762
726
|
*/
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
727
|
+
function getBancontactConfirmationDetails(cart) {
|
|
728
|
+
const billingDetails = getBillingDetails(cart);
|
|
729
|
+
const returnUrl = `${
|
|
730
|
+
window.location.origin + window.location.pathname
|
|
731
|
+
}?gateway=stripe`;
|
|
732
|
+
|
|
733
|
+
return {
|
|
734
|
+
payment_method: {
|
|
735
|
+
billing_details: billingDetails,
|
|
771
736
|
},
|
|
737
|
+
return_url: returnUrl,
|
|
772
738
|
};
|
|
773
|
-
|
|
774
|
-
setBancontactOwner(sourceObject, cart);
|
|
775
|
-
|
|
776
|
-
return stripe.createSource(sourceObject);
|
|
777
739
|
}
|
|
778
740
|
|
|
779
741
|
/**
|
|
@@ -1224,25 +1186,56 @@ class StripeBancontactPayment extends Payment {
|
|
|
1224
1186
|
}
|
|
1225
1187
|
|
|
1226
1188
|
async tokenize() {
|
|
1189
|
+
const cart = await this.getCart();
|
|
1190
|
+
const intent = await this.createIntent({
|
|
1191
|
+
gateway: 'stripe',
|
|
1192
|
+
action: 'setup',
|
|
1193
|
+
account_id: cart.account_id,
|
|
1194
|
+
intent: {
|
|
1195
|
+
payment_method_types: ['bancontact'],
|
|
1196
|
+
usage: 'off_session',
|
|
1197
|
+
},
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1227
1200
|
await this.loadScripts(this.scripts);
|
|
1228
1201
|
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1202
|
+
const { error } = await this.stripe.confirmBancontactSetup(
|
|
1203
|
+
intent.client_secret,
|
|
1204
|
+
getBancontactConfirmationDetails(cart),
|
|
1205
|
+
);
|
|
1206
|
+
|
|
1207
|
+
if (error) {
|
|
1208
|
+
throw new Error(error.message);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
async handleRedirect(queryParams) {
|
|
1213
|
+
const { redirect_status, setup_intent_client_secret } = queryParams;
|
|
1214
|
+
|
|
1215
|
+
if (redirect_status !== 'succeeded') {
|
|
1216
|
+
throw new UnableAuthenticatePaymentMethodError();
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
await this.loadScripts(this.scripts);
|
|
1220
|
+
|
|
1221
|
+
const { setupIntent, error } = await this.stripe.retrieveSetupIntent(
|
|
1222
|
+
setup_intent_client_secret,
|
|
1233
1223
|
);
|
|
1234
1224
|
|
|
1235
|
-
if (
|
|
1236
|
-
throw new Error(
|
|
1225
|
+
if (error) {
|
|
1226
|
+
throw new Error(error.message);
|
|
1237
1227
|
}
|
|
1238
1228
|
|
|
1239
1229
|
await this.updateCart({
|
|
1240
1230
|
billing: {
|
|
1241
1231
|
method: 'bancontact',
|
|
1232
|
+
bancontact: {
|
|
1233
|
+
token: setupIntent.id,
|
|
1234
|
+
},
|
|
1242
1235
|
},
|
|
1243
1236
|
});
|
|
1244
1237
|
|
|
1245
|
-
|
|
1238
|
+
this.onSuccess();
|
|
1246
1239
|
}
|
|
1247
1240
|
}
|
|
1248
1241
|
|
package/dist/products.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defaultMethods, r as reduce, t as toSnake, a as toCamel, f as snakeCase, u as uniq, g as isEqual } from './index.
|
|
1
|
+
import { d as defaultMethods, r as reduce, t as toSnake, a as toCamel, f as snakeCase, u as uniq, g as isEqual } from './index.738bc14a.mjs';
|
|
2
2
|
import cacheApi from './cache.mjs';
|
|
3
3
|
import methods$1 from './attributes.mjs';
|
|
4
4
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
package/dist/settings.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.
|
|
1
|
+
import { s as set, a as toCamel, m as merge, c as cloneDeep, b as isObject, e as camelCase } from './index.738bc14a.mjs';
|
|
2
2
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
|
3
3
|
import 'qs';
|
|
4
4
|
import './round.577a8441.mjs';
|
package/dist/subscriptions.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cleanProductOptions } from './products.mjs';
|
|
2
|
-
import { d as defaultMethods } from './index.
|
|
2
|
+
import { d as defaultMethods } from './index.738bc14a.mjs';
|
|
3
3
|
import cacheApi from './cache.mjs';
|
|
4
4
|
import './attributes.mjs';
|
|
5
5
|
import './find.18f1ac6d.mjs';
|
package/dist/swell.cjs
CHANGED
|
@@ -6900,44 +6900,6 @@ function getBillingDetails(cart) {
|
|
|
6900
6900
|
return details;
|
|
6901
6901
|
}
|
|
6902
6902
|
|
|
6903
|
-
/**
|
|
6904
|
-
* @param {CreateSourceData} source
|
|
6905
|
-
* @param {object} data
|
|
6906
|
-
*/
|
|
6907
|
-
function setBancontactOwner(source, data) {
|
|
6908
|
-
const fillValues = (fieldsMap, data) =>
|
|
6909
|
-
reduce(
|
|
6910
|
-
fieldsMap,
|
|
6911
|
-
(acc, srcKey, destKey) => {
|
|
6912
|
-
const value = data[srcKey];
|
|
6913
|
-
if (value) {
|
|
6914
|
-
acc[destKey] = value;
|
|
6915
|
-
}
|
|
6916
|
-
return acc;
|
|
6917
|
-
},
|
|
6918
|
-
{},
|
|
6919
|
-
);
|
|
6920
|
-
const { account = {}, billing, shipping } = data;
|
|
6921
|
-
const billingData = {
|
|
6922
|
-
...account.shipping,
|
|
6923
|
-
...account.billing,
|
|
6924
|
-
...shipping,
|
|
6925
|
-
...billing,
|
|
6926
|
-
};
|
|
6927
|
-
const billingAddress = fillValues(addressFieldsMap$1, billingData);
|
|
6928
|
-
|
|
6929
|
-
source.owner = {
|
|
6930
|
-
email: account.email,
|
|
6931
|
-
name: billingData.name || account.name,
|
|
6932
|
-
...(billingData.phone
|
|
6933
|
-
? { phone: billingData.phone }
|
|
6934
|
-
: account.phone
|
|
6935
|
-
? { phone: account.phone }
|
|
6936
|
-
: undefined),
|
|
6937
|
-
...(!isEmpty(billingAddress) ? { address: billingAddress } : undefined),
|
|
6938
|
-
};
|
|
6939
|
-
}
|
|
6940
|
-
|
|
6941
6903
|
/**
|
|
6942
6904
|
* @param {string} type
|
|
6943
6905
|
* @param {import('@stripe/stripe-js').StripeElements} elements
|
|
@@ -7042,23 +7004,23 @@ function getKlarnaConfirmationDetails(cart) {
|
|
|
7042
7004
|
}
|
|
7043
7005
|
|
|
7044
7006
|
/**
|
|
7045
|
-
*
|
|
7007
|
+
* Returns Bancontact Setup Intent confirmation details.
|
|
7008
|
+
*
|
|
7046
7009
|
* @param {object} cart
|
|
7010
|
+
* @returns {import('@stripe/stripe-js').ConfirmBancontactPaymentData}
|
|
7047
7011
|
*/
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
const
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7012
|
+
function getBancontactConfirmationDetails(cart) {
|
|
7013
|
+
const billingDetails = getBillingDetails(cart);
|
|
7014
|
+
const returnUrl = `${
|
|
7015
|
+
window.location.origin + window.location.pathname
|
|
7016
|
+
}?gateway=stripe`;
|
|
7017
|
+
|
|
7018
|
+
return {
|
|
7019
|
+
payment_method: {
|
|
7020
|
+
billing_details: billingDetails,
|
|
7056
7021
|
},
|
|
7022
|
+
return_url: returnUrl,
|
|
7057
7023
|
};
|
|
7058
|
-
|
|
7059
|
-
setBancontactOwner(sourceObject, cart);
|
|
7060
|
-
|
|
7061
|
-
return stripe.createSource(sourceObject);
|
|
7062
7024
|
}
|
|
7063
7025
|
|
|
7064
7026
|
/**
|
|
@@ -7509,25 +7471,56 @@ class StripeBancontactPayment extends Payment {
|
|
|
7509
7471
|
}
|
|
7510
7472
|
|
|
7511
7473
|
async tokenize() {
|
|
7474
|
+
const cart = await this.getCart();
|
|
7475
|
+
const intent = await this.createIntent({
|
|
7476
|
+
gateway: 'stripe',
|
|
7477
|
+
action: 'setup',
|
|
7478
|
+
account_id: cart.account_id,
|
|
7479
|
+
intent: {
|
|
7480
|
+
payment_method_types: ['bancontact'],
|
|
7481
|
+
usage: 'off_session',
|
|
7482
|
+
},
|
|
7483
|
+
});
|
|
7484
|
+
|
|
7512
7485
|
await this.loadScripts(this.scripts);
|
|
7513
7486
|
|
|
7514
|
-
const
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7487
|
+
const { error } = await this.stripe.confirmBancontactSetup(
|
|
7488
|
+
intent.client_secret,
|
|
7489
|
+
getBancontactConfirmationDetails(cart),
|
|
7490
|
+
);
|
|
7491
|
+
|
|
7492
|
+
if (error) {
|
|
7493
|
+
throw new Error(error.message);
|
|
7494
|
+
}
|
|
7495
|
+
}
|
|
7496
|
+
|
|
7497
|
+
async handleRedirect(queryParams) {
|
|
7498
|
+
const { redirect_status, setup_intent_client_secret } = queryParams;
|
|
7499
|
+
|
|
7500
|
+
if (redirect_status !== 'succeeded') {
|
|
7501
|
+
throw new UnableAuthenticatePaymentMethodError();
|
|
7502
|
+
}
|
|
7503
|
+
|
|
7504
|
+
await this.loadScripts(this.scripts);
|
|
7505
|
+
|
|
7506
|
+
const { setupIntent, error } = await this.stripe.retrieveSetupIntent(
|
|
7507
|
+
setup_intent_client_secret,
|
|
7518
7508
|
);
|
|
7519
7509
|
|
|
7520
|
-
if (
|
|
7521
|
-
throw new Error(
|
|
7510
|
+
if (error) {
|
|
7511
|
+
throw new Error(error.message);
|
|
7522
7512
|
}
|
|
7523
7513
|
|
|
7524
7514
|
await this.updateCart({
|
|
7525
7515
|
billing: {
|
|
7526
7516
|
method: 'bancontact',
|
|
7517
|
+
bancontact: {
|
|
7518
|
+
token: setupIntent.id,
|
|
7519
|
+
},
|
|
7527
7520
|
},
|
|
7528
7521
|
});
|
|
7529
7522
|
|
|
7530
|
-
|
|
7523
|
+
this.onSuccess();
|
|
7531
7524
|
}
|
|
7532
7525
|
}
|
|
7533
7526
|
|
|
@@ -10172,7 +10165,7 @@ const options = {
|
|
|
10172
10165
|
};
|
|
10173
10166
|
|
|
10174
10167
|
const api = {
|
|
10175
|
-
version: '4.
|
|
10168
|
+
version: '4.2.0',
|
|
10176
10169
|
options,
|
|
10177
10170
|
request,
|
|
10178
10171
|
|