@rebilly/instruments 3.16.4-beta.0 → 3.18.1-beta.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/index.js +3 -3
- package/dist/index.min.js +3 -3
- package/package.json +2 -2
- package/src/functions/mount/fetch-data.js +4 -5
- package/src/storefront/index.js +4 -2
- package/src/storefront/invoices.js +2 -1
- package/src/storefront/invoices.spec.js +32 -0
- package/src/storefront/ready-to-pay.js +2 -1
- package/src/views/method-selector/get-payment-methods.js +14 -2
- package/src/views/method-selector/get-payment-methods.spec.js +1 -1
- package/src/views/modal.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebilly/instruments",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.1-beta.0",
|
|
4
4
|
"author": "Rebilly",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"component-emitter": "^1.3.0",
|
|
38
38
|
"core-js": "3.23.3",
|
|
39
39
|
"jest": "^27.0.6",
|
|
40
|
-
"msw": "0.
|
|
40
|
+
"msw": "0.45.0",
|
|
41
41
|
"msw-when-then": "^1.5.1",
|
|
42
42
|
"rollup": "^2.35.1",
|
|
43
43
|
"rollup-plugin-ignore": "^1.0.10",
|
|
@@ -147,11 +147,10 @@ export async function fetchData({
|
|
|
147
147
|
|
|
148
148
|
let productsPromise;
|
|
149
149
|
if (state.options?.invoiceId || state.data?.transaction?.hasInvoice) {
|
|
150
|
-
const { invoice, products } = await fetchInvoiceAndProducts(
|
|
151
|
-
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
150
|
+
const { invoice, products } = await fetchInvoiceAndProducts({
|
|
151
|
+
data: {
|
|
152
|
+
id: state.options?.invoiceId || state.data?.transaction?.invoiceId
|
|
153
|
+
},
|
|
155
154
|
state,
|
|
156
155
|
});
|
|
157
156
|
productsPromise = Promise.resolve(products);
|
package/src/storefront/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import RebillyApi, {RebillyStorefrontAPI, RebillyExperimentalAPI} from 'rebilly-js-sdk';
|
|
2
2
|
import { showError } from '../views/errors';
|
|
3
3
|
|
|
4
|
+
const TIMEOUT = 60000;
|
|
5
|
+
|
|
4
6
|
export function validateStateForStorefront({state}) {
|
|
5
7
|
if (!state.storefront) {
|
|
6
8
|
throw new Error('Could not access rebilly-js-sdk instance');
|
|
@@ -31,7 +33,7 @@ export class StorefrontInstance {
|
|
|
31
33
|
jwt = null,
|
|
32
34
|
organizationId = null,
|
|
33
35
|
mode = 'live',
|
|
34
|
-
timeout =
|
|
36
|
+
timeout = TIMEOUT,
|
|
35
37
|
liveUrl = null,
|
|
36
38
|
sandboxUrl = null
|
|
37
39
|
} = {}) {
|
|
@@ -44,7 +46,7 @@ export class StorefrontInstance {
|
|
|
44
46
|
organizationId,
|
|
45
47
|
sandbox: mode === 'sandbox',
|
|
46
48
|
timeout: Number.isNaN(parseInt(timeout, 10))
|
|
47
|
-
?
|
|
49
|
+
? TIMEOUT
|
|
48
50
|
: parseInt(timeout, 10),
|
|
49
51
|
urls
|
|
50
52
|
};
|
|
@@ -10,7 +10,8 @@ export async function fetchInvoiceAndProducts({ data = null, state = null }) {
|
|
|
10
10
|
expand: 'items.*.product'
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
const products = fields.items.
|
|
13
|
+
const products = fields.items.filter(item => item._embedded)
|
|
14
|
+
.map(items => new ProductModel(items._embedded.product));
|
|
14
15
|
|
|
15
16
|
return {
|
|
16
17
|
products,
|
|
@@ -53,4 +53,36 @@ describe('Storefront Invoices', () => {
|
|
|
53
53
|
}
|
|
54
54
|
`);
|
|
55
55
|
});
|
|
56
|
+
|
|
57
|
+
it('can fetch an invoice when it does not have any products', async () => {
|
|
58
|
+
const id = '1234';
|
|
59
|
+
const testInvoice = {
|
|
60
|
+
id: 'test-invoice-id-1',
|
|
61
|
+
items: [
|
|
62
|
+
{
|
|
63
|
+
id: 'test',
|
|
64
|
+
price: 0.99,
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
when(get(`${storefrontURL}/invoices/${id}`)).thenReturn(ok(testInvoice));
|
|
70
|
+
|
|
71
|
+
const instance = new StorefontTestingInstance({
|
|
72
|
+
data: {
|
|
73
|
+
invoice: {
|
|
74
|
+
id
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const { invoice, products } = await fetchInvoiceAndProducts({
|
|
80
|
+
data: { id },
|
|
81
|
+
state: instance
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(invoice).toBeInstanceOf(InvoiceModel);
|
|
85
|
+
expect(products).toBeInstanceOf(Array);
|
|
86
|
+
expect(products.length).toBe(0);
|
|
87
|
+
});
|
|
56
88
|
});
|
|
@@ -42,9 +42,10 @@ export async function fetchReadyToPay({
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const { fields: readyToPayFields } = await state.storefront.purchase.readyToPay({ data });
|
|
45
|
+
const readyToPay = Object.values(readyToPayFields);
|
|
45
46
|
const paymentMethodsMetadata = [...paymentMethodsFile];
|
|
46
47
|
|
|
47
|
-
return
|
|
48
|
+
return readyToPay
|
|
48
49
|
// Remove result for "old" paypal method
|
|
49
50
|
.filter((fields) => !(fields.method === 'paypal' && !fields.feature))
|
|
50
51
|
// Remove Plaid payment method
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
// TODO: Express methods should be filtered from RTP some how
|
|
2
|
+
export const SUPPORTED_EXPRESS_METHODS = [
|
|
3
|
+
'Google Pay',
|
|
4
|
+
'Apple Pay',
|
|
5
|
+
'paypal',
|
|
6
|
+
];
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
// TODO: Supported methods should be aimed to be not needed
|
|
9
|
+
// eventually moving to a BLOCKED_METHODS
|
|
10
|
+
export const SUPPORTED_METHODS = [
|
|
11
|
+
'payment-card',
|
|
12
|
+
'ach',
|
|
13
|
+
'cryptocurrency',
|
|
14
|
+
'bitcoin'
|
|
15
|
+
];
|
|
4
16
|
|
|
5
17
|
const isExpressMethod = ({ method, feature }) => (
|
|
6
18
|
SUPPORTED_EXPRESS_METHODS.includes(method) ||
|
package/src/views/modal.js
CHANGED
|
@@ -67,7 +67,12 @@ export async function mountModal({
|
|
|
67
67
|
modalOverlay.classList.remove('is-visible');
|
|
68
68
|
setTimeout(() => {
|
|
69
69
|
document.body.style.overflow = 'auto';
|
|
70
|
-
|
|
70
|
+
|
|
71
|
+
const list = modalOverlay.children;
|
|
72
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
73
|
+
list[i].remove();
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
modalOverlay.remove();
|
|
72
77
|
close(...args);
|
|
73
78
|
iframe.destroy();
|