@rebilly/instruments 1.0.2-beta.8 → 2.1.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/.babelrc +13 -4
- package/.eslintrc.js +3 -0
- package/.prettierrc.js +11 -0
- package/README.md +15 -314
- package/dist/events/base-event.js +6 -9
- package/dist/events/events.spec.js +4 -4
- package/dist/events/index.js +2 -1
- package/dist/functions/destroy.js +12 -14
- package/dist/functions/destroy.spec.js +3 -3
- package/dist/functions/mount/fetch-data.js +183 -0
- package/dist/functions/mount/fetch-data.spec.js +189 -0
- package/dist/functions/mount/index.js +158 -251
- package/dist/functions/mount/mount.spec.js +24 -121
- package/dist/functions/mount/setup-element.js +40 -0
- package/dist/functions/mount/setup-framepay.js +46 -0
- package/dist/functions/mount/setup-i18n.js +33 -0
- package/dist/functions/mount/setup-options.js +96 -0
- package/dist/functions/mount/setup-options.spec.js +66 -0
- package/dist/functions/mount/setup-storefront.js +34 -0
- package/dist/functions/mount/setup-styles.js +43 -0
- package/dist/functions/on.js +13 -4
- package/dist/functions/on.spec.js +19 -5
- package/dist/functions/purchase.js +139 -22
- package/dist/functions/purchase.spec.js +23 -19
- package/dist/functions/setup.js +85 -0
- package/dist/functions/setup.spec.js +87 -0
- package/dist/functions/show.js +31 -14
- package/dist/functions/show.spec.js +47 -18
- package/dist/functions/update.js +53 -27
- package/dist/functions/update.spec.js +40 -21
- package/dist/i18n/en.json +4 -1
- package/dist/i18n/es.json +4 -1
- package/dist/index.js +67 -56
- package/dist/index.spec.js +7 -27
- package/dist/loader/index.js +4 -3
- package/dist/storefront/index.js +33 -0
- package/dist/storefront/invoices.js +27 -0
- package/dist/storefront/models/base-model.js +18 -0
- package/dist/storefront/models/invoice-model.js +14 -0
- package/dist/storefront/models/plan-model.js +4 -35
- package/dist/storefront/models/product-model.js +4 -23
- package/dist/storefront/models/summary-model.js +12 -25
- package/dist/storefront/models/transaction-model.js +31 -0
- package/dist/storefront/payment-instruments.js +47 -0
- package/dist/storefront/payment-instruments.spec.js +55 -0
- package/dist/storefront/plans.js +15 -24
- package/dist/storefront/plans.spec.js +17 -44
- package/dist/storefront/products.js +16 -20
- package/dist/storefront/products.spec.js +25 -49
- package/dist/storefront/purchase.js +28 -16
- package/dist/storefront/purchase.spec.js +4 -22
- package/dist/storefront/ready-to-pay.js +26 -22
- package/dist/storefront/ready-to-pay.spec.js +25 -54
- package/dist/storefront/storefront.spec.js +1 -1
- package/dist/storefront/summary.js +27 -24
- package/dist/storefront/summary.spec.js +44 -86
- package/dist/storefront/transactions.js +27 -0
- package/dist/style/base/theme.js +3 -3
- package/dist/style/components/methods.js +43 -42
- package/dist/style/utils/color-values.js +1 -3
- package/dist/style/views/confirmation.js +0 -4
- package/dist/style/views/method-selector.js +1 -1
- package/dist/style/views/modal.js +3 -1
- package/dist/style/views/summary.js +5 -1
- package/dist/utils/format-currency.js +4 -2
- package/dist/utils/has-valid-css-selector.js +1 -1
- package/dist/utils/process-property-as-dom-element.js +0 -2
- package/dist/views/__snapshots__/summary.spec.js.snap +103 -113
- package/dist/views/common/iframe/base-iframe.js +10 -2
- package/dist/views/common/iframe/modal-iframe.js +44 -3
- package/dist/views/confirmation.js +44 -20
- package/dist/views/method-selector/express-methods/apple-pay.js +92 -0
- package/dist/views/method-selector/express-methods/google-pay.js +31 -0
- package/dist/views/method-selector/express-methods/paypal.js +19 -0
- package/dist/views/method-selector/generate-digital-wallet.js +68 -0
- package/dist/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/dist/views/method-selector/get-payment-methods.js +28 -8
- package/dist/views/method-selector/get-payment-methods.spec.js +25 -26
- package/dist/views/method-selector/index.js +55 -86
- package/dist/views/method-selector/method-selector.spec.js +80 -69
- package/dist/views/method-selector/mount-express-methods.js +38 -62
- package/dist/views/method-selector/mount-methods.js +18 -18
- package/dist/views/modal.js +21 -15
- package/dist/views/result.js +13 -16
- package/dist/views/summary.js +170 -114
- package/dist/views/summary.spec.js +72 -76
- package/package.json +5 -4
- package/src/events/base-event.js +15 -17
- package/src/events/events.spec.js +6 -4
- package/src/events/index.js +6 -3
- package/src/functions/destroy.js +12 -13
- package/src/functions/destroy.spec.js +30 -31
- package/src/functions/mount/fetch-data.js +148 -0
- package/src/functions/mount/fetch-data.spec.js +238 -0
- package/src/functions/mount/index.js +129 -244
- package/src/functions/mount/mount.spec.js +35 -139
- package/src/functions/mount/setup-element.js +26 -0
- package/src/functions/mount/setup-framepay.js +41 -0
- package/src/functions/mount/setup-i18n.js +19 -0
- package/src/functions/mount/setup-options.js +100 -0
- package/src/functions/mount/setup-options.spec.js +60 -0
- package/src/functions/mount/setup-storefront.js +24 -0
- package/src/functions/mount/setup-styles.js +30 -0
- package/src/functions/on.js +13 -8
- package/src/functions/on.spec.js +30 -17
- package/src/functions/purchase.js +101 -19
- package/src/functions/purchase.spec.js +18 -18
- package/src/functions/setup.js +48 -0
- package/src/functions/setup.spec.js +98 -0
- package/src/functions/show.js +20 -10
- package/src/functions/show.spec.js +43 -22
- package/src/functions/update.js +50 -27
- package/src/functions/update.spec.js +57 -22
- package/src/i18n/en.json +4 -1
- package/src/i18n/es.json +4 -1
- package/src/i18n/i18n.spec.js +6 -4
- package/src/i18n/index.js +14 -11
- package/src/index.js +41 -52
- package/src/index.spec.js +8 -37
- package/src/loader/index.js +51 -47
- package/src/loader/loader.spec.js +26 -19
- package/src/storefront/index.js +37 -7
- package/src/storefront/invoices.js +11 -0
- package/src/storefront/models/base-model.js +10 -0
- package/src/storefront/models/invoice-model.js +3 -0
- package/src/storefront/models/plan-model.js +3 -35
- package/src/storefront/models/product-model.js +3 -23
- package/src/storefront/models/ready-to-pay-model.js +3 -3
- package/src/storefront/models/summary-model.js +15 -29
- package/src/storefront/models/transaction-model.js +19 -0
- package/src/storefront/payment-instruments.js +30 -0
- package/src/storefront/payment-instruments.spec.js +69 -0
- package/src/storefront/plans.js +16 -23
- package/src/storefront/plans.spec.js +25 -54
- package/src/storefront/products.js +18 -22
- package/src/storefront/products.spec.js +23 -54
- package/src/storefront/purchase.js +14 -14
- package/src/storefront/purchase.spec.js +17 -29
- package/src/storefront/ready-to-pay.js +26 -23
- package/src/storefront/ready-to-pay.spec.js +41 -71
- package/src/storefront/storefront.spec.js +1 -1
- package/src/storefront/summary.js +26 -22
- package/src/storefront/summary.spec.js +60 -109
- package/src/storefront/transactions.js +11 -0
- package/src/style/base/theme.js +10 -8
- package/src/style/base/theme.spec.js +4 -2
- package/src/style/browserslist.js +1 -3
- package/src/style/components/button.js +3 -1
- package/src/style/components/forms/checkbox.js +3 -1
- package/src/style/components/index.js +1 -1
- package/src/style/components/loader.js +3 -1
- package/src/style/components/methods.js +43 -42
- package/src/style/helpers/index.js +1 -1
- package/src/style/index.js +2 -1
- package/src/style/utils/color-values.js +4 -4
- package/src/style/vendor/framepay.js +1 -1
- package/src/style/vendor/postmate.js +1 -1
- package/src/style/views/confirmation.js +0 -4
- package/src/style/views/index.js +1 -1
- package/src/style/views/method-selector.js +1 -1
- package/src/style/views/modal.js +4 -2
- package/src/style/views/summary.js +5 -1
- package/src/utils/add-dom-element.js +12 -13
- package/src/utils/format-currency.js +6 -2
- package/src/utils/has-valid-css-selector.js +2 -2
- package/src/utils/is-dom-element.js +1 -1
- package/src/utils/process-property-as-dom-element.js +27 -24
- package/src/utils/sleep.js +1 -1
- package/src/views/__snapshots__/summary.spec.js.snap +103 -113
- package/src/views/common/iframe/base-iframe.js +12 -4
- package/src/views/common/iframe/event-listeners.js +6 -6
- package/src/views/common/iframe/index.js +1 -1
- package/src/views/common/iframe/method-iframe.js +3 -6
- package/src/views/common/iframe/modal-iframe.js +42 -6
- package/src/views/common/iframe/view-iframe.js +3 -5
- package/src/views/common/render-utilities.js +3 -3
- package/src/views/confirmation.js +34 -25
- package/src/views/method-selector/express-methods/apple-pay.js +78 -0
- package/src/views/method-selector/express-methods/google-pay.js +24 -0
- package/src/views/method-selector/express-methods/paypal.js +7 -0
- package/src/views/method-selector/generate-digital-wallet.js +51 -0
- package/src/views/method-selector/generate-digital-wallet.spec.js +135 -0
- package/src/views/method-selector/get-method-data.js +7 -4
- package/src/views/method-selector/get-payment-methods.js +38 -29
- package/src/views/method-selector/get-payment-methods.spec.js +26 -33
- package/src/views/method-selector/index.js +70 -99
- package/src/views/method-selector/method-selector.spec.js +88 -78
- package/src/views/method-selector/mount-express-methods.js +36 -60
- package/src/views/method-selector/mount-methods.js +32 -21
- package/src/views/modal.js +37 -23
- package/src/views/result.js +12 -15
- package/src/views/summary.js +169 -101
- package/src/views/summary.spec.js +99 -74
- package/tests/async-utilities.js +22 -0
- package/tests/mocks/rebilly-instruments-mock.js +89 -77
- package/tests/mocks/storefront-api-mock.js +8 -0
- package/tests/mocks/storefront-mock.js +17 -0
- package/dist/events/purchase-completed.js +0 -24
- package/dist/functions/initialize.js +0 -82
- package/dist/functions/initialize.spec.js +0 -34
- package/dist/functions/mount/fetch-summary-data.js +0 -31
- package/dist/functions/mount/fetch-summary-data.spec.js +0 -45
- package/dist/views/method-selector/process-digital-wallet-options.js +0 -35
- package/dist/views/method-selector/process-digital-wallet-options.spec.js +0 -80
- package/src/events/purchase-completed.js +0 -11
- package/src/functions/initialize.js +0 -74
- package/src/functions/initialize.spec.js +0 -38
- package/src/functions/mount/fetch-summary-data.js +0 -26
- package/src/functions/mount/fetch-summary-data.spec.js +0 -46
- package/src/views/method-selector/process-digital-wallet-options.js +0 -16
- package/src/views/method-selector/process-digital-wallet-options.spec.js +0 -94
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import SummaryModel from './models/summary-model';
|
|
2
|
+
import { Endpoint } from './index';
|
|
2
3
|
|
|
3
|
-
export async function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!this.storefront) {
|
|
7
|
-
throw new Error('Could not access rebilly-js-sdk instance');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (!this.configs || !this.options) {
|
|
11
|
-
throw new Error('Could not use Rebilly Instruments configurations or mount options to fetch Rebilly data');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const websiteId = this.configs?.websiteId || null;
|
|
16
|
-
const items = this.options?.intent?.items || [];
|
|
4
|
+
export async function fetchSummary({ data = null, state = null } = {}) {
|
|
5
|
+
return Endpoint({state}, async () => {
|
|
6
|
+
const websiteId = state.options?.websiteId || null;
|
|
17
7
|
|
|
18
8
|
const payload = {
|
|
19
9
|
data: {
|
|
20
|
-
websiteId
|
|
21
|
-
|
|
10
|
+
websiteId
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if (state.options?.items) {
|
|
15
|
+
payload.data.items = state.options.items;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (state.data?.amountAndCurrency) {
|
|
19
|
+
payload.data = {
|
|
20
|
+
...payload.data,
|
|
21
|
+
...state.data.amountAndCurrency
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
24
25
|
if (data?.billingAddress) {
|
|
25
26
|
payload.data.billingAddress = data.billingAddress;
|
|
26
27
|
}
|
|
27
|
-
if(data?.deliveryAddress) {
|
|
28
|
+
if (data?.deliveryAddress) {
|
|
28
29
|
payload.data.deliveryAddress = data.deliveryAddress;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const {fields: summaryFields} = await
|
|
32
|
+
const { fields: summaryFields } = await state.storefront.purchase.preview(
|
|
33
|
+
payload
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// In case of preview purchase gets call again for updating the values
|
|
37
|
+
state.data.previewPurchase = summaryFields;
|
|
32
38
|
|
|
33
39
|
return new SummaryModel(summaryFields);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorefontTestingInstance } from 'tests/mocks/storefront-mock';
|
|
2
2
|
import { ok, post } from 'msw-when-then';
|
|
3
3
|
import { when } from 'tests/msw/server';
|
|
4
4
|
import { storefrontURL } from 'tests/mocks/storefront-api-mock';
|
|
5
|
-
import {
|
|
5
|
+
import { fetchSummary } from './summary';
|
|
6
6
|
import SummaryModel from '@/storefront/models/summary-model';
|
|
7
|
+
import { expectConfigurationError } from 'tests/async-utilities';
|
|
7
8
|
|
|
8
9
|
describe('Storefront API Summary', () => {
|
|
9
|
-
|
|
10
|
-
constructor({
|
|
11
|
-
configs = {},
|
|
12
|
-
options = {},
|
|
13
|
-
storefront = null,
|
|
14
|
-
} = {}) {
|
|
15
|
-
this.configs = configs;
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.storefront = storefront === null ? MockStorefront() : storefront;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
fetchSummary(...args) {
|
|
21
|
-
return FetchSummary.apply(this, args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
it ('can fetch preview', async () => {
|
|
26
|
-
const configs = {
|
|
27
|
-
websiteId: 'test-website-id'
|
|
28
|
-
};
|
|
10
|
+
it('can fetch preview', async () => {
|
|
29
11
|
const options = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
12
|
+
websiteId: 'test-website-id',
|
|
13
|
+
items: [
|
|
14
|
+
{
|
|
15
|
+
planId: 'test-plan-id',
|
|
16
|
+
quantity: 1
|
|
17
|
+
}
|
|
18
|
+
]
|
|
38
19
|
};
|
|
39
20
|
const testSummary = {
|
|
40
21
|
currency: 'USD',
|
|
@@ -42,142 +23,112 @@ describe('Storefront API Summary', () => {
|
|
|
42
23
|
{
|
|
43
24
|
description: 'test-plan-id-1',
|
|
44
25
|
planId: 'test-plan-id-1',
|
|
45
|
-
quantity: 1
|
|
26
|
+
quantity: 1
|
|
46
27
|
}
|
|
47
28
|
]
|
|
48
29
|
};
|
|
49
30
|
|
|
50
31
|
when(post(`${storefrontURL}/preview-purchase`)).thenReturn(ok(testSummary));
|
|
51
32
|
|
|
52
|
-
const instance =
|
|
53
|
-
|
|
54
|
-
options,
|
|
33
|
+
const instance = StorefontTestingInstance({
|
|
34
|
+
options
|
|
55
35
|
});
|
|
56
36
|
|
|
57
37
|
jest.spyOn(instance.storefront.purchase, 'preview');
|
|
58
38
|
|
|
59
|
-
const response = await
|
|
60
|
-
|
|
39
|
+
const response = await fetchSummary({ state: instance });
|
|
40
|
+
|
|
61
41
|
expect(instance.storefront.purchase.preview).toBeCalledTimes(1);
|
|
62
42
|
expect(instance.storefront.purchase.preview).toBeCalledWith({
|
|
63
43
|
data: {
|
|
64
|
-
items: options.
|
|
65
|
-
websiteId:
|
|
44
|
+
items: options.items,
|
|
45
|
+
websiteId: options.websiteId
|
|
66
46
|
}
|
|
67
47
|
});
|
|
68
48
|
expect(response).toBeInstanceOf(SummaryModel);
|
|
69
49
|
expect(response).toEqual(new SummaryModel(testSummary));
|
|
70
|
-
|
|
71
50
|
});
|
|
72
51
|
|
|
73
|
-
it
|
|
74
|
-
const configs = {
|
|
75
|
-
websiteId: 'test-website-id'
|
|
76
|
-
};
|
|
52
|
+
it('Adds billing address to preview payload', async () => {
|
|
77
53
|
const options = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
54
|
+
websiteId: 'test-website-id',
|
|
55
|
+
items: [
|
|
56
|
+
{
|
|
57
|
+
planId: 'test-plan-id',
|
|
58
|
+
quantity: 1
|
|
59
|
+
}
|
|
60
|
+
]
|
|
86
61
|
};
|
|
87
62
|
const billingAddress = {
|
|
88
63
|
firstName: 'Test',
|
|
89
64
|
lastName: 'Customer'
|
|
90
65
|
};
|
|
91
|
-
const instance =
|
|
92
|
-
|
|
93
|
-
options,
|
|
66
|
+
const instance = StorefontTestingInstance({
|
|
67
|
+
options
|
|
94
68
|
});
|
|
95
69
|
|
|
96
70
|
jest.spyOn(instance.storefront.purchase, 'preview');
|
|
97
71
|
|
|
98
|
-
await
|
|
72
|
+
await fetchSummary({
|
|
99
73
|
data: {
|
|
100
|
-
billingAddress
|
|
101
|
-
}
|
|
74
|
+
billingAddress
|
|
75
|
+
},
|
|
76
|
+
state: instance
|
|
102
77
|
});
|
|
103
|
-
|
|
78
|
+
|
|
104
79
|
expect(instance.storefront.purchase.preview).toBeCalledTimes(1);
|
|
105
80
|
expect(instance.storefront.purchase.preview).toBeCalledWith({
|
|
106
81
|
data: {
|
|
107
|
-
items: options.
|
|
108
|
-
websiteId:
|
|
109
|
-
billingAddress
|
|
82
|
+
items: options.items,
|
|
83
|
+
websiteId: options.websiteId,
|
|
84
|
+
billingAddress
|
|
110
85
|
}
|
|
111
86
|
});
|
|
112
87
|
});
|
|
113
88
|
|
|
114
|
-
it
|
|
115
|
-
const configs = {
|
|
116
|
-
websiteId: 'test-website-id'
|
|
117
|
-
};
|
|
89
|
+
it('Adds delivery address to preview payload', async () => {
|
|
118
90
|
const options = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
91
|
+
websiteId: 'test-website-id',
|
|
92
|
+
items: [
|
|
93
|
+
{
|
|
94
|
+
planId: 'test-plan-id',
|
|
95
|
+
quantity: 1
|
|
96
|
+
}
|
|
97
|
+
]
|
|
127
98
|
};
|
|
128
99
|
const deliveryAddress = {
|
|
129
100
|
firstName: 'Test',
|
|
130
101
|
lastName: 'Customer'
|
|
131
102
|
};
|
|
132
|
-
const instance =
|
|
133
|
-
|
|
134
|
-
options,
|
|
103
|
+
const instance = StorefontTestingInstance({
|
|
104
|
+
options
|
|
135
105
|
});
|
|
136
106
|
|
|
137
107
|
jest.spyOn(instance.storefront.purchase, 'preview');
|
|
138
108
|
|
|
139
|
-
await
|
|
109
|
+
await fetchSummary({
|
|
140
110
|
data: {
|
|
141
|
-
deliveryAddress
|
|
142
|
-
}
|
|
111
|
+
deliveryAddress
|
|
112
|
+
},
|
|
113
|
+
state: instance
|
|
143
114
|
});
|
|
144
|
-
|
|
115
|
+
|
|
145
116
|
expect(instance.storefront.purchase.preview).toBeCalledTimes(1);
|
|
146
117
|
expect(instance.storefront.purchase.preview).toBeCalledWith({
|
|
147
118
|
data: {
|
|
148
|
-
items: options.
|
|
149
|
-
websiteId:
|
|
150
|
-
deliveryAddress
|
|
119
|
+
items: options.items,
|
|
120
|
+
websiteId: options.websiteId,
|
|
121
|
+
deliveryAddress
|
|
151
122
|
}
|
|
152
123
|
});
|
|
153
|
-
|
|
154
124
|
});
|
|
155
125
|
|
|
156
|
-
it
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
configs: null,
|
|
160
|
-
options: null,
|
|
161
|
-
});
|
|
162
|
-
const noConfigInstance = new TestSummaryInstance({
|
|
163
|
-
configs: null,
|
|
164
|
-
options: {},
|
|
165
|
-
});
|
|
166
|
-
const noOptionsInstance = new TestSummaryInstance({
|
|
167
|
-
configs: {},
|
|
168
|
-
options: null,
|
|
126
|
+
it('should throw errors with no options', async () => {
|
|
127
|
+
const noConfigOrOptionsInstance = StorefontTestingInstance({
|
|
128
|
+
options: null
|
|
169
129
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}).rejects.toEqual(NoConfigOrOptionsError);
|
|
174
|
-
|
|
175
|
-
expect(async () => {
|
|
176
|
-
await noConfigInstance.fetchSummary();
|
|
177
|
-
}).rejects.toEqual(NoConfigOrOptionsError);
|
|
178
|
-
|
|
179
|
-
expect(async () => {
|
|
180
|
-
await noOptionsInstance.fetchSummary();
|
|
181
|
-
}).rejects.toEqual(NoConfigOrOptionsError);
|
|
130
|
+
await expectConfigurationError(
|
|
131
|
+
fetchSummary({ state: noConfigOrOptionsInstance })
|
|
132
|
+
);
|
|
182
133
|
});
|
|
183
134
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import TransactionModel from './models/transaction-model';
|
|
2
|
+
import { Endpoint } from './index';
|
|
3
|
+
|
|
4
|
+
export async function fetchTransaction({ data = null, state = null }) {
|
|
5
|
+
return Endpoint({state}, async () => {
|
|
6
|
+
state.storefront.setSessionToken(state.options.customerJwt);
|
|
7
|
+
const {fields} = await state.storefront.transactions.get(data);
|
|
8
|
+
|
|
9
|
+
return new TransactionModel(fields);
|
|
10
|
+
});
|
|
11
|
+
}
|
package/src/style/base/theme.js
CHANGED
|
@@ -31,29 +31,31 @@ export class Theme {
|
|
|
31
31
|
padding: '8px 16px',
|
|
32
32
|
verticalPadding: '8px',
|
|
33
33
|
horizontalPadding: '16px',
|
|
34
|
-
minHeight: '44px'
|
|
34
|
+
minHeight: '44px'
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
borderRadius: '4px'
|
|
37
|
+
borderRadius: '4px'
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
get getComputed() {
|
|
40
|
+
|
|
41
|
+
get getComputed() {
|
|
42
|
+
return this.computed();
|
|
43
|
+
}
|
|
42
44
|
|
|
43
45
|
computed() {
|
|
44
46
|
return {
|
|
45
47
|
color: {
|
|
46
48
|
primaryValues: colorValues(this.theme.color.primary),
|
|
47
49
|
mutedText: alphaColor(this.theme.color.text, 0.6),
|
|
48
|
-
mutedBorder: alphaColor(this.theme.color.text, 0.25)
|
|
50
|
+
mutedBorder: alphaColor(this.theme.color.text, 0.25)
|
|
49
51
|
}
|
|
50
|
-
}
|
|
52
|
+
};
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
build() {
|
|
54
56
|
return {
|
|
55
|
-
...merge(this.theme, this.overrides),
|
|
57
|
+
...merge({...this.theme}, this.overrides),
|
|
56
58
|
getComputed: this.getComputed
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
|
-
}
|
|
61
|
+
}
|
|
@@ -14,7 +14,7 @@ describe('RebillyInstruments theme', () => {
|
|
|
14
14
|
primary: 'purple',
|
|
15
15
|
text: 'gray'
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
const theme = new Theme(overrides).build();
|
|
19
19
|
|
|
20
20
|
expect(theme.color.primary).toEqual('purple');
|
|
@@ -24,7 +24,9 @@ describe('RebillyInstruments theme', () => {
|
|
|
24
24
|
it('computes new styles from theme properties', () => {
|
|
25
25
|
const theme = new Theme().build();
|
|
26
26
|
|
|
27
|
-
expect(theme.getComputed.color.primaryValues instanceof Values).toEqual(
|
|
27
|
+
expect(theme.getComputed.color.primaryValues instanceof Values).toEqual(
|
|
28
|
+
true
|
|
29
|
+
);
|
|
28
30
|
expect(theme.getComputed.color.mutedText).toEqual('rgba(13, 43, 62, 0.6)');
|
|
29
31
|
});
|
|
30
32
|
});
|
|
@@ -40,7 +40,9 @@ export const button = (theme) => `
|
|
|
40
40
|
background: ${theme.color.background};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.rebilly-instruments-button:focus { box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
|
|
43
|
+
.rebilly-instruments-button:focus { box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
|
|
44
|
+
.tint(60)
|
|
45
|
+
.hexString()}; }
|
|
44
46
|
|
|
45
47
|
.rebilly-instruments-button:disabled { opacity: 0.6; }
|
|
46
48
|
|
|
@@ -64,7 +64,9 @@ export const checkbox = (theme) => `
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
.rebilly-instruments-form-field-checkbox input[type="checkbox"]:focus ~ span {
|
|
67
|
-
box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
|
|
67
|
+
box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
|
|
68
|
+
.tint(80)
|
|
69
|
+
.hexString()},
|
|
68
70
|
inset 0 0 0 1px ${theme.color.primary};
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -24,7 +24,9 @@ export const loader = (theme) => `
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.rebilly-instruments-loader-spinner {
|
|
27
|
-
border: 4px solid ${theme.getComputed.color.primaryValues
|
|
27
|
+
border: 4px solid ${theme.getComputed.color.primaryValues
|
|
28
|
+
.tint(80)
|
|
29
|
+
.hexString()};
|
|
28
30
|
border-top: 4px solid ${theme.color.primary};
|
|
29
31
|
border-radius: 50%;
|
|
30
32
|
width: 40px;
|
|
@@ -6,73 +6,60 @@ export const expressMethods = (theme) => `
|
|
|
6
6
|
* Express methods
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.rebilly-instruments-express-methods *:nth-child(2) {
|
|
14
|
-
margin-top: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.rebilly-instruments-express-methods.is-compact * + * {
|
|
18
|
-
margin-top: 0;
|
|
9
|
+
@keyframes rebillyExpressShine {
|
|
10
|
+
to {
|
|
11
|
+
background-position-x: -200%;
|
|
12
|
+
}
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
.rebilly-instruments-express-methods.is-compact {
|
|
22
|
-
display: flex;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
padding: calc(${theme.space.xs} + ${theme.space.s}) ${theme.space.s} ${theme.space.s};
|
|
25
16
|
border: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
17
|
+
padding: calc(${theme.space.xs} + ${theme.space.s}) ${theme.space.s} ${theme.space.s};
|
|
26
18
|
border-radius: ${theme.borderRadius};
|
|
27
19
|
position: relative;
|
|
28
|
-
flex-wrap: wrap;
|
|
29
20
|
}
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.rebilly-instruments-express-methods.is-compact > * {
|
|
38
|
-
flex: 1 1;
|
|
39
|
-
margin: ${theme.space.xs} ${theme.space.xs};
|
|
40
|
-
max-width: 260px;
|
|
22
|
+
.rebilly-instruments-express-methods .rebilly-instruments-iframe {
|
|
23
|
+
display: block;
|
|
24
|
+
margin-bottom: 0;
|
|
41
25
|
height: 44px;
|
|
42
|
-
background: linear-gradient(110deg, ${theme.getComputed.color.mutedBorder} 0%, ${theme.color.background} 25%, ${theme.getComputed.color.mutedBorder} 50%);
|
|
43
|
-
border-radius: 6px;
|
|
44
|
-
background-size: 200% 100%;
|
|
45
|
-
animation: 1.5s rebillyExpressShine linear infinite;
|
|
46
|
-
position: relative;
|
|
47
26
|
}
|
|
48
27
|
|
|
49
|
-
.rebilly-instruments-express-methods > * {
|
|
50
|
-
margin: ${theme.space.xs} 0;
|
|
51
|
-
height: 44px;
|
|
52
|
-
background: linear-gradient(110deg, ${theme.getComputed.color.mutedBorder} 0%, ${theme.color.background} 25%, ${theme.getComputed.color.mutedBorder} 50%);
|
|
28
|
+
.rebilly-instruments-express-methods .rebilly-instruments-express-methods-container > * {
|
|
53
29
|
border-radius: 6px;
|
|
30
|
+
margin-bottom: ${theme.space.xs};
|
|
31
|
+
background: linear-gradient(110deg, ${theme.getComputed.color.mutedBorder} 0%, ${theme.color.background} 25%, ${theme.getComputed.color.mutedBorder} 50%);
|
|
54
32
|
background-size: 200% 100%;
|
|
55
33
|
animation: 1.5s rebillyExpressShine linear infinite;
|
|
56
34
|
}
|
|
35
|
+
.rebilly-instruments-express-methods .rebilly-instruments-express-methods-container > *:last-child {
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
57
38
|
|
|
58
|
-
.rebilly-instruments-express-methods
|
|
59
|
-
|
|
39
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container {
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
60
42
|
}
|
|
61
43
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container > * {
|
|
45
|
+
flex: 1 1 0px;
|
|
46
|
+
max-width: 260px;
|
|
47
|
+
margin: 0 ${theme.space.xs};
|
|
48
|
+
}
|
|
49
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container > *:first-child {
|
|
50
|
+
margin-left: 0;
|
|
51
|
+
}
|
|
52
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container > *:last-child {
|
|
53
|
+
margin-right: 0;
|
|
67
54
|
}
|
|
68
55
|
|
|
69
56
|
.rebilly-instruments-express-methods .rebilly-instruments-express-methods-label {
|
|
70
57
|
display: none;
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-label {
|
|
74
60
|
position: absolute;
|
|
75
|
-
top: -12px;
|
|
61
|
+
top: -12px; left: 50%;
|
|
62
|
+
transform: translateX(-50%);
|
|
76
63
|
color: ${theme.color.text};
|
|
77
64
|
padding: 0 ${theme.space.s};
|
|
78
65
|
line-height: ${theme.typography.lineHeight};
|
|
@@ -81,6 +68,20 @@ export const expressMethods = (theme) => `
|
|
|
81
68
|
font-weight: 500;
|
|
82
69
|
min-height: auto;
|
|
83
70
|
margin: 0;
|
|
71
|
+
border: 1px soplid red;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@media (max-width: 600px) {
|
|
75
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container {
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
}
|
|
78
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container > * {
|
|
79
|
+
max-width: 100%;
|
|
80
|
+
margin: 0 0 ${theme.space.xs};
|
|
81
|
+
}
|
|
82
|
+
.rebilly-instruments-express-methods.is-compact .rebilly-instruments-express-methods-container > *:last-child {
|
|
83
|
+
margin: 0;
|
|
84
|
+
}
|
|
84
85
|
}
|
|
85
86
|
`;
|
|
86
87
|
|
|
@@ -48,4 +48,4 @@ export const helpers = (theme) => `
|
|
|
48
48
|
.rebilly-instruments-helper-ml-xl { margin-left: ${theme.space.xl}!important }
|
|
49
49
|
.rebilly-instruments-helper-ml-xxl { margin-left: ${theme.space.xxl}!important }
|
|
50
50
|
.rebilly-instruments-helper-ml-0 { margin-left: 0!important }
|
|
51
|
-
|
|
51
|
+
`;
|
package/src/style/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import Values from 'values.js';
|
|
|
3
3
|
export const colorValues = (color) => new Values(color);
|
|
4
4
|
|
|
5
5
|
export function alphaColor(color, alphaValue = 1) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
const _alphaColor = new Values(color);
|
|
7
|
+
_alphaColor.alpha = alphaValue;
|
|
8
|
+
return _alphaColor.rgbString();
|
|
9
|
+
}
|
|
@@ -15,10 +15,6 @@ export const confirmation = (theme) => `
|
|
|
15
15
|
margin-left: -${theme.space.xs};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
.rebilly-instruments-confirmation .rebilly-instruments-h2 {
|
|
19
|
-
margin: 0 0 ${theme.space.s};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
.rebilly-instruments-confirmation-address-title {
|
|
23
19
|
display: flex;
|
|
24
20
|
justify-content: flex-start;
|
package/src/style/views/index.js
CHANGED
package/src/style/views/modal.js
CHANGED
|
@@ -31,6 +31,7 @@ export const modal = (theme) => `
|
|
|
31
31
|
transition: all .24s ease-in-out;
|
|
32
32
|
position: relative;
|
|
33
33
|
max-width: 800px;
|
|
34
|
+
background: ${theme.color.background};
|
|
34
35
|
margin: 50px auto 20px;
|
|
35
36
|
box-shadow: 0 19px 38px rgba(0,0,0,0.20), 0 15px 12px rgba(0,0,0,0.12);
|
|
36
37
|
border-radius: ${theme.borderRadius};
|
|
@@ -59,7 +60,8 @@ export const modal = (theme) => `
|
|
|
59
60
|
|
|
60
61
|
.rebilly-instruments-modal-content .rebilly-instruments-iframe {
|
|
61
62
|
transition: all .15s;
|
|
62
|
-
height:
|
|
63
|
+
height: auto;
|
|
64
|
+
min-height: 360px;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
.rebilly-instruments-modal-container.is-redirect .rebilly-instruments-modal-content {
|
|
@@ -79,4 +81,4 @@ export const modal = (theme) => `
|
|
|
79
81
|
.rebilly-instruments-modal-close:hover{
|
|
80
82
|
color: #000;
|
|
81
83
|
}
|
|
82
|
-
`;
|
|
84
|
+
`;
|
|
@@ -86,10 +86,14 @@ export const summary = (theme) => `
|
|
|
86
86
|
font-weight: 500;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
.rebilly-instruments-summary-breakdown table {
|
|
90
|
+
border-bottom: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
91
|
+
padding-bottom: ${theme.space.xs};
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
.rebilly-instruments-summary-breakdown-total {
|
|
90
95
|
padding-top: ${theme.space.xs};
|
|
91
96
|
display: flex;
|
|
92
|
-
border-top: 1px solid ${theme.getComputed.color.mutedBorder};
|
|
93
97
|
align-items: center;
|
|
94
98
|
}
|
|
95
99
|
|