swell-js 5.8.2 → 5.9.1
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 +53 -42
- package/dist/attributes.mjs +4 -6
- package/dist/cache.mjs +141 -140
- package/dist/card.mjs +149 -148
- package/dist/cart.mjs +3 -5
- package/dist/categories.mjs +4 -6
- package/dist/content.mjs +1 -9
- package/dist/cookie.mjs +3 -4
- package/dist/currency.mjs +2 -3
- package/dist/{find.18f1ac6d.mjs → find.ba551a2e.mjs} +125 -5
- package/dist/{index.a8d5c125.mjs → index.3949a230.mjs} +4 -21
- package/dist/index.mjs +3 -4
- package/dist/locale.mjs +1 -2
- package/dist/payment.mjs +11 -14
- package/dist/products.mjs +10 -15
- package/dist/{round.577a8441.mjs → round.c68b8be5.mjs} +1 -1
- package/dist/settings.mjs +3 -4
- package/dist/subscriptions.mjs +4 -6
- package/dist/swell.cjs +439 -323
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +13676 -18860
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +3 -4
- package/package.json +15 -8
- package/types/account/camel.ts +10 -7
- package/types/account/index.ts +3 -3
- package/types/account/snake.ts +5 -5
- package/types/attribute/camel.ts +7 -4
- package/types/attribute/index.ts +3 -3
- package/types/attribute/snake.ts +2 -2
- package/types/billing/camel.ts +4 -4
- package/types/billing/index.ts +2 -2
- package/types/billing/snake.ts +1 -1
- package/types/card/camel.ts +5 -5
- package/types/card/index.ts +3 -3
- package/types/card/snake.ts +3 -3
- package/types/cart/camel.ts +17 -14
- package/types/cart/index.ts +3 -3
- package/types/cart/snake.ts +12 -12
- package/types/category/camel.ts +4 -4
- package/types/category/index.ts +3 -3
- package/types/category/snake.ts +2 -2
- package/types/content/camel.ts +5 -5
- package/types/content/index.ts +3 -3
- package/types/content/snake.ts +3 -3
- package/types/coupon/camel.ts +4 -4
- package/types/coupon/index.ts +2 -2
- package/types/coupon/snake.ts +2 -2
- package/types/currency/camel.ts +2 -2
- package/types/currency/index.ts +3 -3
- package/types/discount/camel.ts +3 -3
- package/types/discount/index.ts +2 -2
- package/types/giftcard/camel.ts +10 -7
- package/types/giftcard/index.ts +2 -2
- package/types/giftcard/snake.ts +5 -5
- package/types/index.d.cts +207 -0
- package/types/index.d.ts +83 -56
- package/types/invoice/camel.ts +10 -10
- package/types/invoice/index.ts +3 -3
- package/types/invoice/snake.ts +8 -8
- package/types/order/camel.ts +18 -15
- package/types/order/index.ts +3 -3
- package/types/order/snake.ts +18 -13
- package/types/payment/camel.ts +13 -10
- package/types/payment/index.ts +3 -3
- package/types/payment/snake.ts +8 -8
- package/types/product/camel.ts +5 -5
- package/types/product/index.ts +4 -4
- package/types/product/snake.ts +3 -3
- package/types/promotion/camel.ts +6 -6
- package/types/promotion/index.ts +2 -2
- package/types/promotion/snake.ts +4 -4
- package/types/purchase_link/camel.ts +10 -7
- package/types/purchase_link/index.ts +2 -2
- package/types/purchase_link/snake.ts +5 -5
- package/types/refund/camel.ts +6 -6
- package/types/refund/index.ts +2 -2
- package/types/refund/snake.ts +4 -4
- package/types/shipment_rating/camel.ts +3 -3
- package/types/shipment_rating/index.ts +2 -2
- package/types/subscription/camel.ts +16 -13
- package/types/subscription/index.ts +3 -3
- package/types/subscription/snake.ts +16 -11
- package/types/user/camel.ts +2 -2
- package/types/user/index.ts +3 -3
- package/types/user/snake.ts +1 -1
package/dist/swell.cjs
CHANGED
|
@@ -1,9 +1,128 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const qs = require('qs');
|
|
4
3
|
const deepmerge = require('deepmerge');
|
|
5
4
|
const fastCase = require('fast-case');
|
|
6
5
|
|
|
6
|
+
/*!
|
|
7
|
+
* The UTF-8/RFC 3986 encoder in this file is adapted from qs 6.16.0 (lib/utils.js).
|
|
8
|
+
* That code was originally written by Brian White (mscdex) for the io.js core
|
|
9
|
+
* querystring library and adapted by qs for stricter adherence to RFC 3986.
|
|
10
|
+
*
|
|
11
|
+
* @license BSD-3-Clause
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2014, Nathan LaFreniere and other contributors
|
|
14
|
+
* (https://github.com/ljharb/qs/graphs/contributors)
|
|
15
|
+
* All rights reserved.
|
|
16
|
+
*
|
|
17
|
+
* Redistribution and use in source and binary forms, with or without
|
|
18
|
+
* modification, are permitted provided that the following conditions are met:
|
|
19
|
+
*
|
|
20
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
21
|
+
* list of conditions and the following disclaimer.
|
|
22
|
+
*
|
|
23
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
24
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
25
|
+
* and/or other materials provided with the distribution.
|
|
26
|
+
*
|
|
27
|
+
* 3. Neither the name of the copyright holder nor the names of its
|
|
28
|
+
* contributors may be used to endorse or promote products derived from
|
|
29
|
+
* this software without specific prior written permission.
|
|
30
|
+
*
|
|
31
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
32
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
33
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
34
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
35
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
36
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
37
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
38
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
39
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
40
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const hex = Array.from({ length: 256 }, (_, c) =>
|
|
44
|
+
`%${c.toString(16).padStart(2, '0')}`.toUpperCase(),
|
|
45
|
+
);
|
|
46
|
+
const toISO = Date.prototype.toISOString;
|
|
47
|
+
|
|
48
|
+
function encode(value) {
|
|
49
|
+
if (value.length === 0) return value;
|
|
50
|
+
const string =
|
|
51
|
+
typeof value === 'symbol'
|
|
52
|
+
? Symbol.prototype.toString.call(value)
|
|
53
|
+
: String(value);
|
|
54
|
+
let out = '';
|
|
55
|
+
for (let j = 0; j < string.length; j += 1024) {
|
|
56
|
+
let segment = string.slice(j, j + 1024);
|
|
57
|
+
if (j + 1024 < string.length) {
|
|
58
|
+
const last = segment.charCodeAt(segment.length - 1);
|
|
59
|
+
if (last >= 0xd800 && last <= 0xdbff) {
|
|
60
|
+
segment = segment.slice(0, -1);
|
|
61
|
+
j -= 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
65
|
+
let c = segment.charCodeAt(i);
|
|
66
|
+
if (
|
|
67
|
+
c === 0x2d ||
|
|
68
|
+
c === 0x2e ||
|
|
69
|
+
c === 0x5f ||
|
|
70
|
+
c === 0x7e ||
|
|
71
|
+
(c >= 0x30 && c <= 0x39) ||
|
|
72
|
+
(c >= 0x41 && c <= 0x5a) ||
|
|
73
|
+
(c >= 0x61 && c <= 0x7a)
|
|
74
|
+
) {
|
|
75
|
+
out += segment.charAt(i);
|
|
76
|
+
} else if (c < 0x80) {
|
|
77
|
+
out += hex[c];
|
|
78
|
+
} else if (c < 0x800) {
|
|
79
|
+
out += hex[0xc0 | (c >> 6)] + hex[0x80 | (c & 0x3f)];
|
|
80
|
+
} else if (c < 0xd800 || c >= 0xe000) {
|
|
81
|
+
out +=
|
|
82
|
+
hex[0xe0 | (c >> 12)] +
|
|
83
|
+
hex[0x80 | ((c >> 6) & 0x3f)] +
|
|
84
|
+
hex[0x80 | (c & 0x3f)];
|
|
85
|
+
} else {
|
|
86
|
+
i += 1;
|
|
87
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
88
|
+
out +=
|
|
89
|
+
hex[0xf0 | (c >> 18)] +
|
|
90
|
+
hex[0x80 | ((c >> 12) & 0x3f)] +
|
|
91
|
+
hex[0x80 | ((c >> 6) & 0x3f)] +
|
|
92
|
+
hex[0x80 | (c & 0x3f)];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function stringifyQuery(obj) {
|
|
100
|
+
if (typeof obj !== 'object' || obj === null) return '';
|
|
101
|
+
const parts = [];
|
|
102
|
+
const ancestors = new Set();
|
|
103
|
+
function walk(value, prefix) {
|
|
104
|
+
if (value === undefined) return;
|
|
105
|
+
if (value instanceof Date) value = toISO.call(value);
|
|
106
|
+
if (value === null) value = '';
|
|
107
|
+
const isObject = typeof value === 'object';
|
|
108
|
+
const isBuffer =
|
|
109
|
+
isObject &&
|
|
110
|
+
value.constructor &&
|
|
111
|
+
value.constructor.isBuffer &&
|
|
112
|
+
value.constructor.isBuffer(value);
|
|
113
|
+
if ((!isObject && typeof value !== 'function') || isBuffer) {
|
|
114
|
+
parts.push(`${encode(prefix)}=${encode(value)}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (ancestors.has(value)) throw new RangeError('Cyclic object value');
|
|
118
|
+
ancestors.add(value);
|
|
119
|
+
for (const key of Object.keys(value)) walk(value[key], `${prefix}[${key}]`);
|
|
120
|
+
ancestors.delete(value);
|
|
121
|
+
}
|
|
122
|
+
for (const key of Object.keys(obj)) walk(obj[key], key);
|
|
123
|
+
return parts.join('&');
|
|
124
|
+
}
|
|
125
|
+
|
|
7
126
|
/** Detect free variable `global` from Node.js. */
|
|
8
127
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
9
128
|
|
|
@@ -4493,8 +4612,6 @@ function isEmpty(value) {
|
|
|
4493
4612
|
|
|
4494
4613
|
const LOADING_SCRIPTS = {};
|
|
4495
4614
|
|
|
4496
|
-
let options = {};
|
|
4497
|
-
|
|
4498
4615
|
function arrayMerge(target, source, options) {
|
|
4499
4616
|
const destination = target.slice();
|
|
4500
4617
|
source.forEach((item, index) => {
|
|
@@ -4532,14 +4649,6 @@ function merge(x, y, opt) {
|
|
|
4532
4649
|
return deepmerge(x, y, opt);
|
|
4533
4650
|
}
|
|
4534
4651
|
|
|
4535
|
-
function setOptions(optns) {
|
|
4536
|
-
options = optns;
|
|
4537
|
-
}
|
|
4538
|
-
|
|
4539
|
-
function getOptions() {
|
|
4540
|
-
return options;
|
|
4541
|
-
}
|
|
4542
|
-
|
|
4543
4652
|
function isObject(val) {
|
|
4544
4653
|
return val && typeof val === 'object' && !(val instanceof Array);
|
|
4545
4654
|
}
|
|
@@ -4583,10 +4692,6 @@ function trimEnd(str) {
|
|
|
4583
4692
|
return typeof str === 'string' ? str.replace(/[/]+$/, '') : '';
|
|
4584
4693
|
}
|
|
4585
4694
|
|
|
4586
|
-
function stringifyQuery(str) {
|
|
4587
|
-
return qs.stringify(str);
|
|
4588
|
-
}
|
|
4589
|
-
|
|
4590
4695
|
function map(arr, cb) {
|
|
4591
4696
|
return arr instanceof Array ? arr.map(cb) : [];
|
|
4592
4697
|
}
|
|
@@ -4621,7 +4726,7 @@ function defaultMethods(api, uri, methods) {
|
|
|
4621
4726
|
};
|
|
4622
4727
|
}
|
|
4623
4728
|
|
|
4624
|
-
async function vaultRequest(method, url, data) {
|
|
4729
|
+
async function vaultRequest(method, url, data, options) {
|
|
4625
4730
|
const { vaultUrl, timeout, key } = options;
|
|
4626
4731
|
const requestData = {
|
|
4627
4732
|
$jsonp: {
|
|
@@ -4805,7 +4910,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4805
4910
|
findIndex,
|
|
4806
4911
|
get,
|
|
4807
4912
|
getLocationParams,
|
|
4808
|
-
getOptions,
|
|
4809
4913
|
isEmpty,
|
|
4810
4914
|
isEqual,
|
|
4811
4915
|
isFunction,
|
|
@@ -4820,7 +4924,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4820
4924
|
removeUrlParams,
|
|
4821
4925
|
round: round$1,
|
|
4822
4926
|
set,
|
|
4823
|
-
setOptions,
|
|
4824
4927
|
snakeCase,
|
|
4825
4928
|
stringifyQuery,
|
|
4826
4929
|
toCamel,
|
|
@@ -4835,171 +4938,173 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4835
4938
|
vaultRequest
|
|
4836
4939
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
4837
4940
|
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
if (!
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4941
|
+
function methods$e(options) {
|
|
4942
|
+
return {
|
|
4943
|
+
async createToken(data) {
|
|
4944
|
+
let error = null;
|
|
4945
|
+
let code = null;
|
|
4946
|
+
let param = null;
|
|
4947
|
+
if (!data) {
|
|
4948
|
+
error = 'Card details are missing in `swell.card.createToken(card)`';
|
|
4949
|
+
param = '';
|
|
4950
|
+
}
|
|
4951
|
+
const card = toSnake(data);
|
|
4952
|
+
if (!card.nonce) {
|
|
4953
|
+
if (!this.validateNumber(card.number)) {
|
|
4954
|
+
error = 'Card number appears to be invalid';
|
|
4955
|
+
code = 'invalid_card_number';
|
|
4956
|
+
param = 'number';
|
|
4957
|
+
}
|
|
4958
|
+
if (card.exp) {
|
|
4959
|
+
const exp = this.expiry(card.exp);
|
|
4960
|
+
card.exp_month = exp.month;
|
|
4961
|
+
card.exp_year = exp.year;
|
|
4962
|
+
}
|
|
4963
|
+
if (!this.validateExpiry(card.exp_month, card.exp_year)) {
|
|
4964
|
+
error = 'Card expiry appears to be invalid';
|
|
4965
|
+
code = 'invalid_card_expiry';
|
|
4966
|
+
param = 'exp_month';
|
|
4967
|
+
}
|
|
4968
|
+
if (!this.validateCVC(card.cvc)) {
|
|
4969
|
+
error = 'Card CVC code appears to be invalid';
|
|
4970
|
+
code = 'invalid_card_cvc';
|
|
4971
|
+
param = 'exp_cvc';
|
|
4972
|
+
}
|
|
4853
4973
|
}
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4974
|
+
|
|
4975
|
+
if (error) {
|
|
4976
|
+
const err = new Error(error);
|
|
4977
|
+
err.code = code || 'invalid_card';
|
|
4978
|
+
err.status = 402;
|
|
4979
|
+
err.param = param;
|
|
4980
|
+
throw err;
|
|
4858
4981
|
}
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4982
|
+
|
|
4983
|
+
// Get a token from the vault
|
|
4984
|
+
const result = await vaultRequest('post', '/tokens', card, options);
|
|
4985
|
+
if (result.errors) {
|
|
4986
|
+
const param = Object.keys(result.errors)[0];
|
|
4987
|
+
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
4988
|
+
err.code = 'vault_error';
|
|
4989
|
+
err.status = 402;
|
|
4990
|
+
err.param = param;
|
|
4991
|
+
throw err;
|
|
4863
4992
|
}
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4993
|
+
return result;
|
|
4994
|
+
},
|
|
4995
|
+
|
|
4996
|
+
expiry(value) {
|
|
4997
|
+
if (value && value.month && value.year) {
|
|
4998
|
+
return value;
|
|
4868
4999
|
}
|
|
4869
|
-
}
|
|
4870
5000
|
|
|
4871
|
-
|
|
4872
|
-
const
|
|
4873
|
-
err.code = code || 'invalid_card';
|
|
4874
|
-
err.status = 402;
|
|
4875
|
-
err.param = param;
|
|
4876
|
-
throw err;
|
|
4877
|
-
}
|
|
5001
|
+
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
5002
|
+
const month = parts[0];
|
|
4878
5003
|
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
if (result.errors) {
|
|
4882
|
-
const param = Object.keys(result.errors)[0];
|
|
4883
|
-
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
4884
|
-
err.code = 'vault_error';
|
|
4885
|
-
err.status = 402;
|
|
4886
|
-
err.param = param;
|
|
4887
|
-
throw err;
|
|
4888
|
-
}
|
|
4889
|
-
return result;
|
|
4890
|
-
},
|
|
5004
|
+
const currentYear = new Date().getUTCFullYear().toString();
|
|
5005
|
+
let strYear = parts[1];
|
|
4891
5006
|
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
5007
|
+
if (strYear.length < currentYear.length) {
|
|
5008
|
+
let fullYear =
|
|
5009
|
+
currentYear.slice(0, currentYear.length - strYear.length) + strYear;
|
|
5010
|
+
|
|
5011
|
+
// If the expiration year is less than the current year,
|
|
5012
|
+
// then the expiration year is in the next century.
|
|
5013
|
+
if (fullYear < currentYear) {
|
|
5014
|
+
let year = Number(fullYear);
|
|
5015
|
+
year += 10 ** strYear.length;
|
|
5016
|
+
fullYear = year.toString();
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
strYear = fullYear;
|
|
5020
|
+
}
|
|
4896
5021
|
|
|
4897
|
-
|
|
4898
|
-
|
|
5022
|
+
return {
|
|
5023
|
+
month: Number.parseInt(month, 10),
|
|
5024
|
+
year: Number.parseInt(strYear, 10),
|
|
5025
|
+
};
|
|
5026
|
+
},
|
|
5027
|
+
|
|
5028
|
+
types() {
|
|
5029
|
+
let t = {};
|
|
5030
|
+
for (let e = 40; e <= 49; ++e) t[e] = 'Visa';
|
|
5031
|
+
for (let e = 50; e <= 59; ++e) t[e] = 'MasterCard';
|
|
5032
|
+
t[34] = t[37] = 'American Express';
|
|
5033
|
+
t[60] = t[62] = t[64] = t[65] = 'Discover';
|
|
5034
|
+
t[35] = 'JCB';
|
|
5035
|
+
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
5036
|
+
return t;
|
|
5037
|
+
},
|
|
4899
5038
|
|
|
4900
|
-
|
|
4901
|
-
|
|
5039
|
+
type(num) {
|
|
5040
|
+
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
5041
|
+
},
|
|
4902
5042
|
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
5043
|
+
luhnCheck(num) {
|
|
5044
|
+
const numbers = String(num);
|
|
5045
|
+
let odd = false;
|
|
5046
|
+
let sum = 0;
|
|
4906
5047
|
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
if (fullYear < currentYear) {
|
|
4910
|
-
let year = Number(fullYear);
|
|
4911
|
-
year += 10 ** strYear.length;
|
|
4912
|
-
fullYear = year.toString();
|
|
4913
|
-
}
|
|
5048
|
+
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
5049
|
+
let digit = Number.parseInt(numbers[i], 10);
|
|
4914
5050
|
|
|
4915
|
-
|
|
4916
|
-
|
|
5051
|
+
if (odd) {
|
|
5052
|
+
digit *= 2;
|
|
4917
5053
|
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
};
|
|
4922
|
-
},
|
|
4923
|
-
|
|
4924
|
-
types() {
|
|
4925
|
-
let t = {};
|
|
4926
|
-
for (let e = 40; e <= 49; ++e) t[e] = 'Visa';
|
|
4927
|
-
for (let e = 50; e <= 59; ++e) t[e] = 'MasterCard';
|
|
4928
|
-
t[34] = t[37] = 'American Express';
|
|
4929
|
-
t[60] = t[62] = t[64] = t[65] = 'Discover';
|
|
4930
|
-
t[35] = 'JCB';
|
|
4931
|
-
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
4932
|
-
return t;
|
|
4933
|
-
},
|
|
4934
|
-
|
|
4935
|
-
type(num) {
|
|
4936
|
-
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
4937
|
-
},
|
|
4938
|
-
|
|
4939
|
-
luhnCheck(num) {
|
|
4940
|
-
const numbers = String(num);
|
|
4941
|
-
let odd = false;
|
|
4942
|
-
let sum = 0;
|
|
4943
|
-
|
|
4944
|
-
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
4945
|
-
let digit = Number.parseInt(numbers[i], 10);
|
|
4946
|
-
|
|
4947
|
-
if (odd) {
|
|
4948
|
-
digit *= 2;
|
|
4949
|
-
|
|
4950
|
-
if (digit > 9) {
|
|
4951
|
-
digit -= 9;
|
|
5054
|
+
if (digit > 9) {
|
|
5055
|
+
digit -= 9;
|
|
5056
|
+
}
|
|
4952
5057
|
}
|
|
4953
|
-
}
|
|
4954
5058
|
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
5059
|
+
sum += digit;
|
|
5060
|
+
odd = !odd;
|
|
5061
|
+
}
|
|
4958
5062
|
|
|
4959
|
-
|
|
4960
|
-
|
|
5063
|
+
return sum % 10 === 0;
|
|
5064
|
+
},
|
|
4961
5065
|
|
|
4962
|
-
|
|
4963
|
-
|
|
5066
|
+
validateNumber(num) {
|
|
5067
|
+
num = String(num).replace(/\s+|-/g, '');
|
|
4964
5068
|
|
|
4965
|
-
|
|
4966
|
-
|
|
5069
|
+
return num.length >= 10 && num.length <= 16 && this.luhnCheck(num);
|
|
5070
|
+
},
|
|
4967
5071
|
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
5072
|
+
validateExpiry(month, year) {
|
|
5073
|
+
month = String(month).trim();
|
|
5074
|
+
year = String(year).trim();
|
|
4971
5075
|
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5076
|
+
if (!/^\d+$/.test(month) || !/^\d+$/.test(year)) {
|
|
5077
|
+
return false;
|
|
5078
|
+
}
|
|
4975
5079
|
|
|
4976
|
-
|
|
5080
|
+
const numMonth = Number.parseInt(month, 10);
|
|
4977
5081
|
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
5082
|
+
if (numMonth <= 0 || numMonth > 12) {
|
|
5083
|
+
return false;
|
|
5084
|
+
}
|
|
4981
5085
|
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
5086
|
+
const date = new Date(year, month);
|
|
5087
|
+
date.setMonth(date.getMonth() - 1);
|
|
5088
|
+
date.setMonth(date.getMonth() + 1, 1);
|
|
4985
5089
|
|
|
4986
|
-
|
|
5090
|
+
const diff = date.getTime() - Date.now();
|
|
4987
5091
|
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
5092
|
+
// The card has expired
|
|
5093
|
+
if (diff < 0) {
|
|
5094
|
+
return false;
|
|
5095
|
+
}
|
|
4992
5096
|
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5097
|
+
// The card's validity period must not exceed 50 years from the current time.
|
|
5098
|
+
return Math.round(diff / 31_557_600_000) < 50;
|
|
5099
|
+
},
|
|
4996
5100
|
|
|
4997
|
-
|
|
4998
|
-
|
|
5101
|
+
validateCVC(val) {
|
|
5102
|
+
val = String(val).trim();
|
|
4999
5103
|
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
};
|
|
5104
|
+
return /^\d+$/.test(val) && val.length >= 3 && val.length <= 4;
|
|
5105
|
+
},
|
|
5106
|
+
};
|
|
5107
|
+
}
|
|
5003
5108
|
|
|
5004
5109
|
const COOKIE_MAX_AGE = 604800; // 1 week
|
|
5005
5110
|
|
|
@@ -5050,191 +5155,191 @@ function setCookie(name, value, options = {}) {
|
|
|
5050
5155
|
|
|
5051
5156
|
const RECORD_TIMEOUT = 5000;
|
|
5052
5157
|
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
[
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5158
|
+
function methods$d(opt) {
|
|
5159
|
+
let VALUES = {
|
|
5160
|
+
/*
|
|
5161
|
+
[model]: {
|
|
5162
|
+
[id]: {
|
|
5163
|
+
data,
|
|
5164
|
+
record,
|
|
5165
|
+
recordTimer,
|
|
5166
|
+
presets,
|
|
5167
|
+
}
|
|
5061
5168
|
}
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
};
|
|
5169
|
+
*/
|
|
5170
|
+
};
|
|
5065
5171
|
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5172
|
+
return {
|
|
5173
|
+
options: {
|
|
5174
|
+
enabled: true,
|
|
5175
|
+
debug: false,
|
|
5176
|
+
},
|
|
5071
5177
|
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5178
|
+
debug(...args) {
|
|
5179
|
+
if (this.options.debug) {
|
|
5180
|
+
console.log(...args);
|
|
5181
|
+
}
|
|
5182
|
+
},
|
|
5077
5183
|
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5184
|
+
values({ model, id }, setValues = undefined) {
|
|
5185
|
+
this.debug('cache.values', ...arguments);
|
|
5186
|
+
if (setValues !== undefined) {
|
|
5187
|
+
for (let key in setValues) {
|
|
5188
|
+
set(VALUES, `${model}.${id}.${key}`, setValues[key]);
|
|
5189
|
+
}
|
|
5190
|
+
return;
|
|
5083
5191
|
}
|
|
5084
|
-
return;
|
|
5085
|
-
}
|
|
5086
|
-
return get(VALUES, `${model}.${id}`, {});
|
|
5087
|
-
},
|
|
5192
|
+
return get(VALUES, `${model}.${id}`, {});
|
|
5193
|
+
},
|
|
5088
5194
|
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5195
|
+
preset(details) {
|
|
5196
|
+
this.debug('cache.preset', ...arguments);
|
|
5197
|
+
const { presets = [] } = this.values(details);
|
|
5198
|
+
presets.push(details);
|
|
5199
|
+
this.values(details, { presets });
|
|
5200
|
+
},
|
|
5095
5201
|
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5202
|
+
set(details) {
|
|
5203
|
+
this.debug('cache.set', ...arguments);
|
|
5204
|
+
let { model, id, path, value } = details;
|
|
5205
|
+
let { data = {}, record } = this.values(details);
|
|
5100
5206
|
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
if (record === undefined) {
|
|
5106
|
-
return this.preset(details);
|
|
5107
|
-
}
|
|
5207
|
+
if (id === null) {
|
|
5208
|
+
return;
|
|
5209
|
+
}
|
|
5108
5210
|
|
|
5109
|
-
|
|
5211
|
+
if (record === undefined) {
|
|
5212
|
+
return this.preset(details);
|
|
5213
|
+
}
|
|
5110
5214
|
|
|
5111
|
-
|
|
5112
|
-
if (useCamelCase && value && typeof value === 'object') {
|
|
5113
|
-
value = toCamel(value);
|
|
5114
|
-
}
|
|
5215
|
+
data = merge(record || {}, data);
|
|
5115
5216
|
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5217
|
+
const { useCamelCase } = opt;
|
|
5218
|
+
if (useCamelCase && value && typeof value === 'object') {
|
|
5219
|
+
value = toCamel(value);
|
|
5220
|
+
}
|
|
5221
|
+
|
|
5222
|
+
if (path || value instanceof Array) {
|
|
5223
|
+
let upData = { ...(data || {}) };
|
|
5224
|
+
let upPath = useCamelCase ? toCamelPath(path) : path;
|
|
5225
|
+
set(upData, upPath || '', value);
|
|
5226
|
+
data = upData;
|
|
5227
|
+
} else if (value && typeof value === 'object') {
|
|
5228
|
+
data = data || {};
|
|
5229
|
+
data = merge(data, value);
|
|
5230
|
+
} else {
|
|
5231
|
+
data = value;
|
|
5232
|
+
}
|
|
5127
5233
|
|
|
5128
|
-
|
|
5234
|
+
this.values(details, { data });
|
|
5129
5235
|
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5236
|
+
try {
|
|
5237
|
+
// Make sure values have clean refs
|
|
5238
|
+
const cache = VALUES[model][id];
|
|
5239
|
+
if (cache !== undefined) {
|
|
5240
|
+
if (cache.data !== undefined) {
|
|
5241
|
+
cache.data = JSON.parse(JSON.stringify(cache.data));
|
|
5242
|
+
}
|
|
5243
|
+
if (cache.record !== undefined) {
|
|
5244
|
+
cache.record = JSON.parse(JSON.stringify(cache.record));
|
|
5245
|
+
}
|
|
5139
5246
|
}
|
|
5247
|
+
} catch (err) {
|
|
5248
|
+
// noop
|
|
5140
5249
|
}
|
|
5141
|
-
}
|
|
5142
|
-
// noop
|
|
5143
|
-
}
|
|
5144
|
-
},
|
|
5250
|
+
},
|
|
5145
5251
|
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5252
|
+
get(model, id) {
|
|
5253
|
+
this.debug('cache.get', ...arguments);
|
|
5254
|
+
const { data, recordTimer } = this.values({ model, id });
|
|
5255
|
+
this.debug('cache.get:data+recordTimer', ...arguments);
|
|
5256
|
+
if (recordTimer) {
|
|
5257
|
+
return data;
|
|
5258
|
+
}
|
|
5259
|
+
},
|
|
5154
5260
|
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5261
|
+
setRecord(record, details) {
|
|
5262
|
+
this.debug('cache.setRecord', ...arguments);
|
|
5263
|
+
let { recordTimer, presets } = this.values(details);
|
|
5158
5264
|
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5265
|
+
if (recordTimer) {
|
|
5266
|
+
clearTimeout(recordTimer);
|
|
5267
|
+
}
|
|
5162
5268
|
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5269
|
+
recordTimer = setTimeout(() => {
|
|
5270
|
+
this.values(details, { record: undefined, recordTimer: undefined });
|
|
5271
|
+
}, RECORD_TIMEOUT);
|
|
5166
5272
|
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5273
|
+
// Record has to be null at minimum, not undefined
|
|
5274
|
+
this.values(details, {
|
|
5275
|
+
record: record !== undefined ? record : null,
|
|
5276
|
+
recordTimer,
|
|
5277
|
+
});
|
|
5172
5278
|
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5279
|
+
if (presets) {
|
|
5280
|
+
for (let preset of presets) {
|
|
5281
|
+
this.set(preset);
|
|
5282
|
+
}
|
|
5283
|
+
this.values(details, { presets: undefined });
|
|
5176
5284
|
}
|
|
5177
|
-
this.values(details, { presets: undefined });
|
|
5178
|
-
}
|
|
5179
5285
|
|
|
5180
|
-
|
|
5286
|
+
const result = this.get(details.model, details.id);
|
|
5181
5287
|
|
|
5182
|
-
|
|
5183
|
-
|
|
5288
|
+
return result !== undefined ? result : record;
|
|
5289
|
+
},
|
|
5184
5290
|
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5291
|
+
async getFetch(model, id, fetch) {
|
|
5292
|
+
if (this.options.enabled) {
|
|
5293
|
+
this.debug('cache.getFetch', ...arguments);
|
|
5294
|
+
const value = this.get(model, id);
|
|
5189
5295
|
|
|
5190
|
-
|
|
5191
|
-
|
|
5296
|
+
if (value !== undefined) {
|
|
5297
|
+
return value;
|
|
5298
|
+
}
|
|
5192
5299
|
}
|
|
5193
|
-
}
|
|
5194
5300
|
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5301
|
+
const record = await fetch();
|
|
5302
|
+
return this.setRecord(record, { model, id });
|
|
5303
|
+
},
|
|
5198
5304
|
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5305
|
+
clear(model = undefined, id = undefined) {
|
|
5306
|
+
this.debug('cache.clear', ...arguments);
|
|
5307
|
+
if (model) {
|
|
5308
|
+
if (id) {
|
|
5309
|
+
set(VALUES, `${model}.${id}`, undefined);
|
|
5310
|
+
} else {
|
|
5311
|
+
set(VALUES, model, undefined);
|
|
5312
|
+
}
|
|
5204
5313
|
} else {
|
|
5205
|
-
|
|
5314
|
+
VALUES = {};
|
|
5206
5315
|
}
|
|
5207
|
-
}
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
},
|
|
5211
|
-
};
|
|
5316
|
+
},
|
|
5317
|
+
};
|
|
5318
|
+
}
|
|
5212
5319
|
|
|
5213
5320
|
function methods$c(api) {
|
|
5214
5321
|
const { get, list } = defaultMethods(api, '/attributes', ['list', 'get']);
|
|
5215
5322
|
|
|
5216
5323
|
return {
|
|
5217
5324
|
get: (id, ...args) => {
|
|
5218
|
-
return
|
|
5325
|
+
return api.cache.getFetch('attributes', id, () => get(id, ...args));
|
|
5219
5326
|
},
|
|
5220
5327
|
|
|
5221
5328
|
list,
|
|
5222
5329
|
};
|
|
5223
5330
|
}
|
|
5224
5331
|
|
|
5225
|
-
let OPTIONS;
|
|
5226
|
-
|
|
5227
5332
|
function methods$b(api, opt) {
|
|
5228
|
-
OPTIONS = opt;
|
|
5229
5333
|
const { get, list } = defaultMethods(api, '/products', ['list', 'get']);
|
|
5230
5334
|
return {
|
|
5231
5335
|
get: (id, ...args) => {
|
|
5232
|
-
return
|
|
5336
|
+
return api.cache.getFetch('products', id, () => get(id, ...args));
|
|
5233
5337
|
},
|
|
5234
5338
|
|
|
5235
5339
|
list,
|
|
5236
5340
|
|
|
5237
|
-
variation:
|
|
5341
|
+
variation: (input, options, purchaseOption) =>
|
|
5342
|
+
calculateVariation(input, options, purchaseOption, opt),
|
|
5238
5343
|
|
|
5239
5344
|
categories: getCategories,
|
|
5240
5345
|
|
|
@@ -5314,8 +5419,8 @@ function findVariantWithOptionValueIds(product, ids) {
|
|
|
5314
5419
|
return null;
|
|
5315
5420
|
}
|
|
5316
5421
|
|
|
5317
|
-
function calculateVariation(input, options, purchaseOption) {
|
|
5318
|
-
const product =
|
|
5422
|
+
function calculateVariation(input, options, purchaseOption, opt) {
|
|
5423
|
+
const product = opt.useCamelCase ? toSnake(input) : input;
|
|
5319
5424
|
const purchaseOp = findPurchaseOption(product, purchaseOption);
|
|
5320
5425
|
const variation = {
|
|
5321
5426
|
...product,
|
|
@@ -5378,7 +5483,7 @@ function calculateVariation(input, options, purchaseOption) {
|
|
|
5378
5483
|
if (variation.orig_price === undefined) {
|
|
5379
5484
|
delete variation.orig_price;
|
|
5380
5485
|
}
|
|
5381
|
-
return
|
|
5486
|
+
return opt.useCamelCase ? toCamel(variation) : variation;
|
|
5382
5487
|
}
|
|
5383
5488
|
|
|
5384
5489
|
function findPurchaseOption(product, purchaseOption) {
|
|
@@ -5433,8 +5538,7 @@ function findPurchaseOption(product, purchaseOption) {
|
|
|
5433
5538
|
}
|
|
5434
5539
|
|
|
5435
5540
|
async function getFilterableAttributeFilters(api, products, options) {
|
|
5436
|
-
const { results: filterableAttributes } = await methods$c(
|
|
5437
|
-
api).list({
|
|
5541
|
+
const { results: filterableAttributes } = await methods$c(api).list({
|
|
5438
5542
|
filterable: true,
|
|
5439
5543
|
});
|
|
5440
5544
|
|
|
@@ -6041,19 +6145,29 @@ class AppPaymentComponent extends AppComponent {
|
|
|
6041
6145
|
}
|
|
6042
6146
|
|
|
6043
6147
|
#getIntent(data) {
|
|
6044
|
-
return vaultRequest(
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6148
|
+
return vaultRequest(
|
|
6149
|
+
'GET',
|
|
6150
|
+
'/intent',
|
|
6151
|
+
{
|
|
6152
|
+
gateway: this.#gateway,
|
|
6153
|
+
account_id: this.#accountId,
|
|
6154
|
+
intent: data,
|
|
6155
|
+
},
|
|
6156
|
+
this.options,
|
|
6157
|
+
);
|
|
6049
6158
|
}
|
|
6050
6159
|
|
|
6051
6160
|
#createIntent(data) {
|
|
6052
|
-
return vaultRequest(
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6161
|
+
return vaultRequest(
|
|
6162
|
+
'POST',
|
|
6163
|
+
'/intent',
|
|
6164
|
+
{
|
|
6165
|
+
gateway: this.#gateway,
|
|
6166
|
+
account_id: this.#accountId,
|
|
6167
|
+
intent: data,
|
|
6168
|
+
},
|
|
6169
|
+
this.options,
|
|
6170
|
+
);
|
|
6057
6171
|
}
|
|
6058
6172
|
}
|
|
6059
6173
|
|
|
@@ -6208,7 +6322,7 @@ function methods$8(api) {
|
|
|
6208
6322
|
|
|
6209
6323
|
return {
|
|
6210
6324
|
get: (id, ...args) => {
|
|
6211
|
-
return
|
|
6325
|
+
return api.cache.getFetch('categories', id, () => get(id, ...args));
|
|
6212
6326
|
},
|
|
6213
6327
|
|
|
6214
6328
|
list,
|
|
@@ -6219,7 +6333,7 @@ function methods$7(api) {
|
|
|
6219
6333
|
const { get, list } = defaultMethods(api, '/subscriptions', ['list', 'get']);
|
|
6220
6334
|
return {
|
|
6221
6335
|
get: (id, ...args) => {
|
|
6222
|
-
return
|
|
6336
|
+
return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
|
|
6223
6337
|
},
|
|
6224
6338
|
|
|
6225
6339
|
list,
|
|
@@ -6284,7 +6398,7 @@ function methods$6(api) {
|
|
|
6284
6398
|
const { get, list } = defaultMethods(api, '/invoices', ['list', 'get']);
|
|
6285
6399
|
return {
|
|
6286
6400
|
get: (id, ...args) => {
|
|
6287
|
-
return
|
|
6401
|
+
return api.cache.getFetch('invoices', id, () => get(id, ...args));
|
|
6288
6402
|
},
|
|
6289
6403
|
|
|
6290
6404
|
list,
|
|
@@ -6294,7 +6408,7 @@ function methods$6(api) {
|
|
|
6294
6408
|
function methods$5(api, opt) {
|
|
6295
6409
|
return {
|
|
6296
6410
|
get: (type, id, query) => {
|
|
6297
|
-
return
|
|
6411
|
+
return api.cache.getFetch(`content_${type}`, id, () =>
|
|
6298
6412
|
api.request('get', `/content/${type}`, id, {
|
|
6299
6413
|
$preview: opt.previewContent,
|
|
6300
6414
|
...(query || {}),
|
|
@@ -7041,7 +7155,7 @@ class Payment {
|
|
|
7041
7155
|
* @returns {Promise<object>}
|
|
7042
7156
|
*/
|
|
7043
7157
|
async createIntent(data) {
|
|
7044
|
-
return vaultRequest('post', '/intent', data);
|
|
7158
|
+
return vaultRequest('post', '/intent', data, this.options);
|
|
7045
7159
|
}
|
|
7046
7160
|
|
|
7047
7161
|
/**
|
|
@@ -7051,7 +7165,7 @@ class Payment {
|
|
|
7051
7165
|
* @returns {Promise<object>}
|
|
7052
7166
|
*/
|
|
7053
7167
|
async updateIntent(data) {
|
|
7054
|
-
return vaultRequest('put', '/intent', data);
|
|
7168
|
+
return vaultRequest('put', '/intent', data, this.options);
|
|
7055
7169
|
}
|
|
7056
7170
|
|
|
7057
7171
|
/**
|
|
@@ -7061,7 +7175,7 @@ class Payment {
|
|
|
7061
7175
|
* @returns {Promise<object>}
|
|
7062
7176
|
*/
|
|
7063
7177
|
async authorizeGateway(data) {
|
|
7064
|
-
return vaultRequest('post', '/authorization', data);
|
|
7178
|
+
return vaultRequest('post', '/authorization', data, this.options);
|
|
7065
7179
|
}
|
|
7066
7180
|
|
|
7067
7181
|
/**
|
|
@@ -9345,7 +9459,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
9345
9459
|
|
|
9346
9460
|
if (cart.subscription_delivery) {
|
|
9347
9461
|
try {
|
|
9348
|
-
const card = await
|
|
9462
|
+
const card = await this.api.card.createToken({
|
|
9349
9463
|
gateway: 'braintree',
|
|
9350
9464
|
account_id: cart.account_id,
|
|
9351
9465
|
nonce,
|
|
@@ -10022,7 +10136,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
10022
10136
|
|
|
10023
10137
|
if (cart.subscription_delivery) {
|
|
10024
10138
|
try {
|
|
10025
|
-
const card = await
|
|
10139
|
+
const card = await this.api.card.createToken({
|
|
10026
10140
|
gateway: 'braintree',
|
|
10027
10141
|
account_id: cart.account_id,
|
|
10028
10142
|
nonce: payload.nonce,
|
|
@@ -10928,7 +11042,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
10928
11042
|
''
|
|
10929
11043
|
).replace(/[^0-9]+/g, '');
|
|
10930
11044
|
|
|
10931
|
-
const cardExpiry =
|
|
11045
|
+
const cardExpiry = this.api.card.expiry(
|
|
10932
11046
|
this.params.exp ||
|
|
10933
11047
|
document.getElementById(
|
|
10934
11048
|
this.params.cardExpiry?.elementId || 'cardExpiry-element',
|
|
@@ -10952,7 +11066,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
10952
11066
|
''
|
|
10953
11067
|
).trim();
|
|
10954
11068
|
|
|
10955
|
-
const cardBrand =
|
|
11069
|
+
const cardBrand = this.api.card.type(cardNumber).toLowerCase();
|
|
10956
11070
|
|
|
10957
11071
|
const payment = await createConvesioCardPaymentToken(this.method, {
|
|
10958
11072
|
paymentMethod: {
|
|
@@ -12657,7 +12771,7 @@ class PaymentController {
|
|
|
12657
12771
|
}
|
|
12658
12772
|
|
|
12659
12773
|
async _vaultRequest(method, url, data) {
|
|
12660
|
-
const response = await vaultRequest(method, url, data);
|
|
12774
|
+
const response = await vaultRequest(method, url, data, this.options);
|
|
12661
12775
|
|
|
12662
12776
|
if (this.options.useCamelCase) {
|
|
12663
12777
|
return toCamel(response);
|
|
@@ -13211,7 +13325,7 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
13211
13325
|
const api = {};
|
|
13212
13326
|
|
|
13213
13327
|
Object.assign(api, {
|
|
13214
|
-
version: '5.
|
|
13328
|
+
version: '5.9.1',
|
|
13215
13329
|
options,
|
|
13216
13330
|
request,
|
|
13217
13331
|
|
|
@@ -13241,8 +13355,6 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
13241
13355
|
options.getCart = opt.getCart;
|
|
13242
13356
|
options.updateCart = opt.updateCart;
|
|
13243
13357
|
options.headers = opt.headers || {};
|
|
13244
|
-
|
|
13245
|
-
setOptions(options);
|
|
13246
13358
|
},
|
|
13247
13359
|
|
|
13248
13360
|
// Backward compatibility
|
|
@@ -13266,9 +13378,9 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
13266
13378
|
return api.request('delete', url, data);
|
|
13267
13379
|
},
|
|
13268
13380
|
|
|
13269
|
-
cache:
|
|
13381
|
+
cache: methods$d(options),
|
|
13270
13382
|
|
|
13271
|
-
card:
|
|
13383
|
+
card: methods$e(options),
|
|
13272
13384
|
|
|
13273
13385
|
cart: methods$a(api, options),
|
|
13274
13386
|
|
|
@@ -13302,9 +13414,13 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
13302
13414
|
|
|
13303
13415
|
utils,
|
|
13304
13416
|
|
|
13305
|
-
getCookie
|
|
13417
|
+
getCookie(name) {
|
|
13418
|
+
return (options.getCookie || getCookie)(name);
|
|
13419
|
+
},
|
|
13306
13420
|
|
|
13307
|
-
setCookie,
|
|
13421
|
+
setCookie(name, value, cookieOptions) {
|
|
13422
|
+
return (options.setCookie || setCookie)(name, value, cookieOptions);
|
|
13423
|
+
},
|
|
13308
13424
|
});
|
|
13309
13425
|
|
|
13310
13426
|
async function request(
|