swell-js 5.8.2 → 5.9.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 +51 -39
- package/dist/attributes.mjs +2 -3
- package/dist/cache.mjs +139 -137
- package/dist/card.mjs +147 -145
- package/dist/cart.mjs +1 -2
- package/dist/categories.mjs +2 -3
- package/dist/content.mjs +1 -9
- package/dist/cookie.mjs +1 -1
- package/dist/{index.a8d5c125.mjs → index.777df7a8.mjs} +2 -14
- package/dist/index.mjs +1 -1
- package/dist/payment.mjs +10 -12
- package/dist/products.mjs +8 -12
- package/dist/settings.mjs +1 -1
- package/dist/subscriptions.mjs +2 -3
- package/dist/swell.cjs +319 -318
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +318 -317
- package/dist/swell.umd.min.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +13 -6
- 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/card.mjs
CHANGED
|
@@ -1,174 +1,176 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as toSnake, v as vaultRequest } from './index.777df7a8.mjs';
|
|
2
2
|
import 'qs';
|
|
3
3
|
import './find.18f1ac6d.mjs';
|
|
4
4
|
import './round.577a8441.mjs';
|
|
5
5
|
import 'deepmerge';
|
|
6
6
|
import 'fast-case';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const card = toSnake(data);
|
|
18
|
-
if (!card.nonce) {
|
|
19
|
-
if (!this.validateNumber(card.number)) {
|
|
20
|
-
error = 'Card number appears to be invalid';
|
|
21
|
-
code = 'invalid_card_number';
|
|
22
|
-
param = 'number';
|
|
8
|
+
function methods(options) {
|
|
9
|
+
return {
|
|
10
|
+
async createToken(data) {
|
|
11
|
+
let error = null;
|
|
12
|
+
let code = null;
|
|
13
|
+
let param = null;
|
|
14
|
+
if (!data) {
|
|
15
|
+
error = 'Card details are missing in `swell.card.createToken(card)`';
|
|
16
|
+
param = '';
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
card.
|
|
27
|
-
|
|
18
|
+
const card = toSnake(data);
|
|
19
|
+
if (!card.nonce) {
|
|
20
|
+
if (!this.validateNumber(card.number)) {
|
|
21
|
+
error = 'Card number appears to be invalid';
|
|
22
|
+
code = 'invalid_card_number';
|
|
23
|
+
param = 'number';
|
|
24
|
+
}
|
|
25
|
+
if (card.exp) {
|
|
26
|
+
const exp = this.expiry(card.exp);
|
|
27
|
+
card.exp_month = exp.month;
|
|
28
|
+
card.exp_year = exp.year;
|
|
29
|
+
}
|
|
30
|
+
if (!this.validateExpiry(card.exp_month, card.exp_year)) {
|
|
31
|
+
error = 'Card expiry appears to be invalid';
|
|
32
|
+
code = 'invalid_card_expiry';
|
|
33
|
+
param = 'exp_month';
|
|
34
|
+
}
|
|
35
|
+
if (!this.validateCVC(card.cvc)) {
|
|
36
|
+
error = 'Card CVC code appears to be invalid';
|
|
37
|
+
code = 'invalid_card_cvc';
|
|
38
|
+
param = 'exp_cvc';
|
|
39
|
+
}
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
|
|
42
|
+
if (error) {
|
|
43
|
+
const err = new Error(error);
|
|
44
|
+
err.code = code || 'invalid_card';
|
|
45
|
+
err.status = 402;
|
|
46
|
+
err.param = param;
|
|
47
|
+
throw err;
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
|
|
50
|
+
// Get a token from the vault
|
|
51
|
+
const result = await vaultRequest('post', '/tokens', card, options);
|
|
52
|
+
if (result.errors) {
|
|
53
|
+
const param = Object.keys(result.errors)[0];
|
|
54
|
+
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
55
|
+
err.code = 'vault_error';
|
|
56
|
+
err.status = 402;
|
|
57
|
+
err.param = param;
|
|
58
|
+
throw err;
|
|
38
59
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
err.param = param;
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Get a token from the vault
|
|
50
|
-
const result = await vaultRequest('post', '/tokens', card);
|
|
51
|
-
if (result.errors) {
|
|
52
|
-
const param = Object.keys(result.errors)[0];
|
|
53
|
-
const err = new Error(result.errors[param].message || 'Unknown error');
|
|
54
|
-
err.code = 'vault_error';
|
|
55
|
-
err.status = 402;
|
|
56
|
-
err.param = param;
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
expiry(value) {
|
|
63
|
-
if (value && value.month && value.year) {
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
68
|
-
const month = parts[0];
|
|
69
|
-
|
|
70
|
-
const currentYear = new Date().getUTCFullYear().toString();
|
|
71
|
-
let strYear = parts[1];
|
|
72
|
-
|
|
73
|
-
if (strYear.length < currentYear.length) {
|
|
74
|
-
let fullYear =
|
|
75
|
-
currentYear.slice(0, currentYear.length - strYear.length) + strYear;
|
|
76
|
-
|
|
77
|
-
// If the expiration year is less than the current year,
|
|
78
|
-
// then the expiration year is in the next century.
|
|
79
|
-
if (fullYear < currentYear) {
|
|
80
|
-
let year = Number(fullYear);
|
|
81
|
-
year += 10 ** strYear.length;
|
|
82
|
-
fullYear = year.toString();
|
|
60
|
+
return result;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
expiry(value) {
|
|
64
|
+
if (value && value.month && value.year) {
|
|
65
|
+
return value;
|
|
83
66
|
}
|
|
84
67
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
102
|
-
return t;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
type(num) {
|
|
106
|
-
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
luhnCheck(num) {
|
|
110
|
-
const numbers = String(num);
|
|
111
|
-
let odd = false;
|
|
112
|
-
let sum = 0;
|
|
113
|
-
|
|
114
|
-
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
115
|
-
let digit = Number.parseInt(numbers[i], 10);
|
|
116
|
-
|
|
117
|
-
if (odd) {
|
|
118
|
-
digit *= 2;
|
|
119
|
-
|
|
120
|
-
if (digit > 9) {
|
|
121
|
-
digit -= 9;
|
|
68
|
+
const parts = new String(value).split(/[\s/-]+/, 2);
|
|
69
|
+
const month = parts[0];
|
|
70
|
+
|
|
71
|
+
const currentYear = new Date().getUTCFullYear().toString();
|
|
72
|
+
let strYear = parts[1];
|
|
73
|
+
|
|
74
|
+
if (strYear.length < currentYear.length) {
|
|
75
|
+
let fullYear =
|
|
76
|
+
currentYear.slice(0, currentYear.length - strYear.length) + strYear;
|
|
77
|
+
|
|
78
|
+
// If the expiration year is less than the current year,
|
|
79
|
+
// then the expiration year is in the next century.
|
|
80
|
+
if (fullYear < currentYear) {
|
|
81
|
+
let year = Number(fullYear);
|
|
82
|
+
year += 10 ** strYear.length;
|
|
83
|
+
fullYear = year.toString();
|
|
122
84
|
}
|
|
85
|
+
|
|
86
|
+
strYear = fullYear;
|
|
123
87
|
}
|
|
124
88
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
89
|
+
return {
|
|
90
|
+
month: Number.parseInt(month, 10),
|
|
91
|
+
year: Number.parseInt(strYear, 10),
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
types() {
|
|
96
|
+
let t = {};
|
|
97
|
+
for (let e = 40; e <= 49; ++e) t[e] = 'Visa';
|
|
98
|
+
for (let e = 50; e <= 59; ++e) t[e] = 'MasterCard';
|
|
99
|
+
t[34] = t[37] = 'American Express';
|
|
100
|
+
t[60] = t[62] = t[64] = t[65] = 'Discover';
|
|
101
|
+
t[35] = 'JCB';
|
|
102
|
+
t[30] = t[36] = t[38] = t[39] = 'Diners Club';
|
|
103
|
+
return t;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
type(num) {
|
|
107
|
+
return this.types()[num.slice(0, 2)] || 'Unknown';
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
luhnCheck(num) {
|
|
111
|
+
const numbers = String(num);
|
|
112
|
+
let odd = false;
|
|
113
|
+
let sum = 0;
|
|
114
|
+
|
|
115
|
+
for (let i = numbers.length - 1; i >= 0; --i) {
|
|
116
|
+
let digit = Number.parseInt(numbers[i], 10);
|
|
117
|
+
|
|
118
|
+
if (odd) {
|
|
119
|
+
digit *= 2;
|
|
120
|
+
|
|
121
|
+
if (digit > 9) {
|
|
122
|
+
digit -= 9;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
sum += digit;
|
|
127
|
+
odd = !odd;
|
|
128
|
+
}
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
return sum % 10 === 0;
|
|
131
|
+
},
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
validateNumber(num) {
|
|
134
|
+
num = String(num).replace(/\s+|-/g, '');
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
return num.length >= 10 && num.length <= 16 && this.luhnCheck(num);
|
|
137
|
+
},
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
validateExpiry(month, year) {
|
|
140
|
+
month = String(month).trim();
|
|
141
|
+
year = String(year).trim();
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
if (!/^\d+$/.test(month) || !/^\d+$/.test(year)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
const numMonth = Number.parseInt(month, 10);
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
if (numMonth <= 0 || numMonth > 12) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const date = new Date(year, month);
|
|
154
|
+
date.setMonth(date.getMonth() - 1);
|
|
155
|
+
date.setMonth(date.getMonth() + 1, 1);
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
const diff = date.getTime() - Date.now();
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
// The card has expired
|
|
160
|
+
if (diff < 0) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
// The card's validity period must not exceed 50 years from the current time.
|
|
165
|
+
return Math.round(diff / 31_557_600_000) < 50;
|
|
166
|
+
},
|
|
166
167
|
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
validateCVC(val) {
|
|
169
|
+
val = String(val).trim();
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
171
|
+
return /^\d+$/.test(val) && val.length >= 3 && val.length <= 4;
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
173
175
|
|
|
174
|
-
export {
|
|
176
|
+
export { methods as default };
|
package/dist/cart.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import 'qs';
|
|
2
|
-
import { c as cloneDeep } from './index.
|
|
2
|
+
import { c as cloneDeep } from './index.777df7a8.mjs';
|
|
3
3
|
import 'deepmerge';
|
|
4
4
|
import 'fast-case';
|
|
5
5
|
import { cleanProductOptions } from './products.mjs';
|
|
6
6
|
import './find.18f1ac6d.mjs';
|
|
7
7
|
import './round.577a8441.mjs';
|
|
8
|
-
import './cache.mjs';
|
|
9
8
|
import './attributes.mjs';
|
|
10
9
|
|
|
11
10
|
function methods(api, options) {
|
package/dist/categories.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { d as defaultMethods } from './index.
|
|
2
|
-
import cacheApi from './cache.mjs';
|
|
1
|
+
import { d as defaultMethods } from './index.777df7a8.mjs';
|
|
3
2
|
import 'qs';
|
|
4
3
|
import './find.18f1ac6d.mjs';
|
|
5
4
|
import './round.577a8441.mjs';
|
|
@@ -11,7 +10,7 @@ function methods(api) {
|
|
|
11
10
|
|
|
12
11
|
return {
|
|
13
12
|
get: (id, ...args) => {
|
|
14
|
-
return
|
|
13
|
+
return api.cache.getFetch('categories', id, () => get(id, ...args));
|
|
15
14
|
},
|
|
16
15
|
|
|
17
16
|
list,
|
package/dist/content.mjs
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import cacheApi from './cache.mjs';
|
|
2
|
-
import './index.a8d5c125.mjs';
|
|
3
|
-
import 'qs';
|
|
4
|
-
import './find.18f1ac6d.mjs';
|
|
5
|
-
import './round.577a8441.mjs';
|
|
6
|
-
import 'deepmerge';
|
|
7
|
-
import 'fast-case';
|
|
8
|
-
|
|
9
1
|
function methods(api, opt) {
|
|
10
2
|
return {
|
|
11
3
|
get: (type, id, query) => {
|
|
12
|
-
return
|
|
4
|
+
return api.cache.getFetch(`content_${type}`, id, () =>
|
|
13
5
|
api.request('get', `/content/${type}`, id, {
|
|
14
6
|
$preview: opt.previewContent,
|
|
15
7
|
...(query || {}),
|
package/dist/cookie.mjs
CHANGED
|
@@ -1473,8 +1473,6 @@ function isEmpty(value) {
|
|
|
1473
1473
|
|
|
1474
1474
|
const LOADING_SCRIPTS = {};
|
|
1475
1475
|
|
|
1476
|
-
let options = {};
|
|
1477
|
-
|
|
1478
1476
|
function arrayMerge(target, source, options) {
|
|
1479
1477
|
const destination = target.slice();
|
|
1480
1478
|
source.forEach((item, index) => {
|
|
@@ -1512,14 +1510,6 @@ function merge(x, y, opt) {
|
|
|
1512
1510
|
return deepmerge(x, y, opt);
|
|
1513
1511
|
}
|
|
1514
1512
|
|
|
1515
|
-
function setOptions(optns) {
|
|
1516
|
-
options = optns;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
function getOptions() {
|
|
1520
|
-
return options;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
1513
|
function isObject(val) {
|
|
1524
1514
|
return val && typeof val === 'object' && !(val instanceof Array);
|
|
1525
1515
|
}
|
|
@@ -1601,7 +1591,7 @@ function defaultMethods(api, uri, methods) {
|
|
|
1601
1591
|
};
|
|
1602
1592
|
}
|
|
1603
1593
|
|
|
1604
|
-
async function vaultRequest(method, url, data) {
|
|
1594
|
+
async function vaultRequest(method, url, data, options) {
|
|
1605
1595
|
const { vaultUrl, timeout, key } = options;
|
|
1606
1596
|
const requestData = {
|
|
1607
1597
|
$jsonp: {
|
|
@@ -1785,7 +1775,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1785
1775
|
findIndex,
|
|
1786
1776
|
get,
|
|
1787
1777
|
getLocationParams,
|
|
1788
|
-
getOptions,
|
|
1789
1778
|
isEmpty,
|
|
1790
1779
|
isEqual,
|
|
1791
1780
|
isFunction,
|
|
@@ -1800,7 +1789,6 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1800
1789
|
removeUrlParams,
|
|
1801
1790
|
round,
|
|
1802
1791
|
set,
|
|
1803
|
-
setOptions,
|
|
1804
1792
|
snakeCase,
|
|
1805
1793
|
stringifyQuery,
|
|
1806
1794
|
toCamel,
|
|
@@ -1815,4 +1803,4 @@ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
1815
1803
|
vaultRequest
|
|
1816
1804
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1817
1805
|
|
|
1818
|
-
export {
|
|
1806
|
+
export { trimBoth as A, stringifyQuery as B, toLower as C, map as D, toCamelPath as a, toSnake as b, cloneDeep as c, defaultMethods as d, isObject as e, camelCase as f, snakeCase as g, isEqual as h, isServer as i, isFunction as j, isEmpty as k, loadScript as l, merge as m, isLiveMode as n, base64Encode as o, pick$1 as p, getLocationParams as q, reduce as r, set as s, toCamel as t, uniq as u, vaultRequest as v, removeUrlParams as w, trimEnd as x, utils as y, trimStart as z };
|
package/dist/index.mjs
CHANGED
package/dist/payment.mjs
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import methods from './cart.mjs';
|
|
2
2
|
import methods$1 from './settings.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { e as isObject, j as isFunction, l as loadScript, c as cloneDeep, v as vaultRequest, b as toSnake, p as pick, k as isEmpty, n as isLiveMode, o as base64Encode, q as getLocationParams, w as removeUrlParams, t as toCamel } from './index.777df7a8.mjs';
|
|
4
4
|
import { g as get } from './find.18f1ac6d.mjs';
|
|
5
5
|
import 'qs';
|
|
6
6
|
import 'deepmerge';
|
|
7
7
|
import 'fast-case';
|
|
8
|
-
import cardApi from './card.mjs';
|
|
9
8
|
import './products.mjs';
|
|
10
|
-
import './cache.mjs';
|
|
11
|
-
import './round.577a8441.mjs';
|
|
12
9
|
import './attributes.mjs';
|
|
10
|
+
import './round.577a8441.mjs';
|
|
13
11
|
|
|
14
12
|
const SCRIPT_HANDLERS = {
|
|
15
13
|
'stripe-js': loadStripe,
|
|
@@ -423,7 +421,7 @@ class Payment {
|
|
|
423
421
|
* @returns {Promise<object>}
|
|
424
422
|
*/
|
|
425
423
|
async createIntent(data) {
|
|
426
|
-
return vaultRequest('post', '/intent', data);
|
|
424
|
+
return vaultRequest('post', '/intent', data, this.options);
|
|
427
425
|
}
|
|
428
426
|
|
|
429
427
|
/**
|
|
@@ -433,7 +431,7 @@ class Payment {
|
|
|
433
431
|
* @returns {Promise<object>}
|
|
434
432
|
*/
|
|
435
433
|
async updateIntent(data) {
|
|
436
|
-
return vaultRequest('put', '/intent', data);
|
|
434
|
+
return vaultRequest('put', '/intent', data, this.options);
|
|
437
435
|
}
|
|
438
436
|
|
|
439
437
|
/**
|
|
@@ -443,7 +441,7 @@ class Payment {
|
|
|
443
441
|
* @returns {Promise<object>}
|
|
444
442
|
*/
|
|
445
443
|
async authorizeGateway(data) {
|
|
446
|
-
return vaultRequest('post', '/authorization', data);
|
|
444
|
+
return vaultRequest('post', '/authorization', data, this.options);
|
|
447
445
|
}
|
|
448
446
|
|
|
449
447
|
/**
|
|
@@ -2727,7 +2725,7 @@ class BraintreeGooglePayment extends Payment {
|
|
|
2727
2725
|
|
|
2728
2726
|
if (cart.subscription_delivery) {
|
|
2729
2727
|
try {
|
|
2730
|
-
const card = await
|
|
2728
|
+
const card = await this.api.card.createToken({
|
|
2731
2729
|
gateway: 'braintree',
|
|
2732
2730
|
account_id: cart.account_id,
|
|
2733
2731
|
nonce,
|
|
@@ -3404,7 +3402,7 @@ class BraintreeApplePayment extends Payment {
|
|
|
3404
3402
|
|
|
3405
3403
|
if (cart.subscription_delivery) {
|
|
3406
3404
|
try {
|
|
3407
|
-
const card = await
|
|
3405
|
+
const card = await this.api.card.createToken({
|
|
3408
3406
|
gateway: 'braintree',
|
|
3409
3407
|
account_id: cart.account_id,
|
|
3410
3408
|
nonce: payload.nonce,
|
|
@@ -4310,7 +4308,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
4310
4308
|
''
|
|
4311
4309
|
).replace(/[^0-9]+/g, '');
|
|
4312
4310
|
|
|
4313
|
-
const cardExpiry =
|
|
4311
|
+
const cardExpiry = this.api.card.expiry(
|
|
4314
4312
|
this.params.exp ||
|
|
4315
4313
|
document.getElementById(
|
|
4316
4314
|
this.params.cardExpiry?.elementId || 'cardExpiry-element',
|
|
@@ -4334,7 +4332,7 @@ class ConvesioCardPayment extends Payment {
|
|
|
4334
4332
|
''
|
|
4335
4333
|
).trim();
|
|
4336
4334
|
|
|
4337
|
-
const cardBrand =
|
|
4335
|
+
const cardBrand = this.api.card.type(cardNumber).toLowerCase();
|
|
4338
4336
|
|
|
4339
4337
|
const payment = await createConvesioCardPaymentToken(this.method, {
|
|
4340
4338
|
paymentMethod: {
|
|
@@ -6039,7 +6037,7 @@ class PaymentController {
|
|
|
6039
6037
|
}
|
|
6040
6038
|
|
|
6041
6039
|
async _vaultRequest(method, url, data) {
|
|
6042
|
-
const response = await vaultRequest(method, url, data);
|
|
6040
|
+
const response = await vaultRequest(method, url, data, this.options);
|
|
6043
6041
|
|
|
6044
6042
|
if (this.options.useCamelCase) {
|
|
6045
6043
|
return toCamel(response);
|
package/dist/products.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { d as defaultMethods, r as reduce,
|
|
2
|
-
import cacheApi from './cache.mjs';
|
|
1
|
+
import { d as defaultMethods, r as reduce, b as toSnake, t as toCamel, g as snakeCase, u as uniq, h as isEqual } from './index.777df7a8.mjs';
|
|
3
2
|
import methods$1 from './attributes.mjs';
|
|
4
3
|
import { g as get, f as find } from './find.18f1ac6d.mjs';
|
|
5
4
|
import 'qs';
|
|
@@ -7,19 +6,17 @@ import './round.577a8441.mjs';
|
|
|
7
6
|
import 'deepmerge';
|
|
8
7
|
import 'fast-case';
|
|
9
8
|
|
|
10
|
-
let OPTIONS;
|
|
11
|
-
|
|
12
9
|
function methods(api, opt) {
|
|
13
|
-
OPTIONS = opt;
|
|
14
10
|
const { get, list } = defaultMethods(api, '/products', ['list', 'get']);
|
|
15
11
|
return {
|
|
16
12
|
get: (id, ...args) => {
|
|
17
|
-
return
|
|
13
|
+
return api.cache.getFetch('products', id, () => get(id, ...args));
|
|
18
14
|
},
|
|
19
15
|
|
|
20
16
|
list,
|
|
21
17
|
|
|
22
|
-
variation:
|
|
18
|
+
variation: (input, options, purchaseOption) =>
|
|
19
|
+
calculateVariation(input, options, purchaseOption, opt),
|
|
23
20
|
|
|
24
21
|
categories: getCategories,
|
|
25
22
|
|
|
@@ -116,8 +113,8 @@ function findVariantWithOptions(product, options) {
|
|
|
116
113
|
return findVariantWithOptionValueIds(product, optionValueIds);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
function calculateVariation(input, options, purchaseOption) {
|
|
120
|
-
const product =
|
|
116
|
+
function calculateVariation(input, options, purchaseOption, opt) {
|
|
117
|
+
const product = opt.useCamelCase ? toSnake(input) : input;
|
|
121
118
|
const purchaseOp = findPurchaseOption(product, purchaseOption);
|
|
122
119
|
const variation = {
|
|
123
120
|
...product,
|
|
@@ -180,7 +177,7 @@ function calculateVariation(input, options, purchaseOption) {
|
|
|
180
177
|
if (variation.orig_price === undefined) {
|
|
181
178
|
delete variation.orig_price;
|
|
182
179
|
}
|
|
183
|
-
return
|
|
180
|
+
return opt.useCamelCase ? toCamel(variation) : variation;
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
function findPurchaseOption(product, purchaseOption) {
|
|
@@ -235,8 +232,7 @@ function findPurchaseOption(product, purchaseOption) {
|
|
|
235
232
|
}
|
|
236
233
|
|
|
237
234
|
async function getFilterableAttributeFilters(api, products, options) {
|
|
238
|
-
const { results: filterableAttributes } = await methods$1(
|
|
239
|
-
api).list({
|
|
235
|
+
const { results: filterableAttributes } = await methods$1(api).list({
|
|
240
236
|
filterable: true,
|
|
241
237
|
});
|
|
242
238
|
|
package/dist/settings.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as set,
|
|
1
|
+
import { s as set, t as toCamel, m as merge, c as cloneDeep, e as isObject, f as camelCase } from './index.777df7a8.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,6 +1,5 @@
|
|
|
1
1
|
import { cleanProductOptions } from './products.mjs';
|
|
2
|
-
import { d as defaultMethods } from './index.
|
|
3
|
-
import cacheApi from './cache.mjs';
|
|
2
|
+
import { d as defaultMethods } from './index.777df7a8.mjs';
|
|
4
3
|
import './attributes.mjs';
|
|
5
4
|
import './find.18f1ac6d.mjs';
|
|
6
5
|
import 'qs';
|
|
@@ -12,7 +11,7 @@ function methods(api) {
|
|
|
12
11
|
const { get, list } = defaultMethods(api, '/subscriptions', ['list', 'get']);
|
|
13
12
|
return {
|
|
14
13
|
get: (id, ...args) => {
|
|
15
|
-
return
|
|
14
|
+
return api.cache.getFetch('subscriptions', id, () => get(id, ...args));
|
|
16
15
|
},
|
|
17
16
|
|
|
18
17
|
list,
|