@rebilly/instruments 4.7.1 → 4.8.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/CHANGELOG.md +14 -0
- package/dist/index.js +12 -12
- package/dist/index.min.js +12 -12
- package/package.json +1 -1
- package/src/functions/mount/fetch-data.js +9 -7
- package/src/storefront/ready-to-pay.js +4 -4
- package/src/storefront/ready-to-pay.spec.js +1 -5
- package/src/views/amount-selector.js +1 -3
- package/src/views/method-selector/get-payment-methods.spec.js +1 -1
package/package.json
CHANGED
|
@@ -134,6 +134,13 @@ export async function fetchData({
|
|
|
134
134
|
try {
|
|
135
135
|
state.data = new DataInstance();
|
|
136
136
|
|
|
137
|
+
if (!riskMetadata) {
|
|
138
|
+
const { riskMetadata: data } = await collectData();
|
|
139
|
+
state.data.riskMetadata = data;
|
|
140
|
+
} else {
|
|
141
|
+
state.data.riskMetadata = riskMetadata;
|
|
142
|
+
}
|
|
143
|
+
|
|
137
144
|
if (state.options?.deposit) {
|
|
138
145
|
if (state.options.deposit.depositRequestId) {
|
|
139
146
|
state.data.deposit = await fetchDepositRequest({
|
|
@@ -156,10 +163,10 @@ export async function fetchData({
|
|
|
156
163
|
state.data.account = account;
|
|
157
164
|
state.data.website = website;
|
|
158
165
|
});
|
|
159
|
-
readyToPayPromise = fetchReadyToPay(
|
|
166
|
+
readyToPayPromise = fetchReadyToPay();
|
|
160
167
|
availableInstrumentsPromise = fetchInstruments({ state });
|
|
161
168
|
} else {
|
|
162
|
-
readyToPayPromise = fetchReadyToPay(
|
|
169
|
+
readyToPayPromise = fetchReadyToPay();
|
|
163
170
|
}
|
|
164
171
|
|
|
165
172
|
if (state.options?.transactionId) {
|
|
@@ -183,11 +190,6 @@ export async function fetchData({
|
|
|
183
190
|
state.data.invoice = invoice;
|
|
184
191
|
}
|
|
185
192
|
|
|
186
|
-
if (!riskMetadata) {
|
|
187
|
-
({ riskMetadata } = await collectData());
|
|
188
|
-
state.data.riskMetadata = riskMetadata;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
193
|
const previewPurchasePromise = state.options.items
|
|
192
194
|
? fetchSummary()
|
|
193
195
|
: null;
|
|
@@ -55,15 +55,15 @@ export function filterReadyToPay(readyToPay) {
|
|
|
55
55
|
.filter(({ metadata }) => metadata.storefrontEnabled);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export async function fetchReadyToPay(
|
|
58
|
+
export async function fetchReadyToPay() {
|
|
59
59
|
return Endpoint(async () => {
|
|
60
|
-
if (!riskMetadata) {
|
|
60
|
+
if (!state.data.riskMetadata) {
|
|
61
61
|
const { riskMetadata: data } = await collectData();
|
|
62
|
-
riskMetadata = data;
|
|
62
|
+
state.data.riskMetadata = data;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
const data = {
|
|
66
|
-
riskMetadata,
|
|
66
|
+
riskMetadata: state.data.riskMetadata,
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
data.websiteId = state.options?.websiteId || null;
|
|
@@ -42,10 +42,8 @@ describe('Storefront API Ready to Pay', () => {
|
|
|
42
42
|
|
|
43
43
|
vi.spyOn(instance.storefront.purchase, 'readyToPay');
|
|
44
44
|
|
|
45
|
-
const riskMetadata = null;
|
|
46
45
|
const response = await fetchReadyToPay({
|
|
47
46
|
state: instance,
|
|
48
|
-
riskMetadata,
|
|
49
47
|
});
|
|
50
48
|
|
|
51
49
|
expect(instance.storefront.purchase.readyToPay).toBeCalledTimes(1);
|
|
@@ -68,13 +66,11 @@ describe('Storefront API Ready to Pay', () => {
|
|
|
68
66
|
});
|
|
69
67
|
|
|
70
68
|
it('should throw errors with no options', async () => {
|
|
71
|
-
const riskMetadata = null;
|
|
72
|
-
|
|
73
69
|
const noConfigOrOptionsInstance = new StorefontTestingInstance({
|
|
74
70
|
options: null,
|
|
75
71
|
});
|
|
76
72
|
await expectConfigurationError(
|
|
77
|
-
fetchReadyToPay({
|
|
73
|
+
fetchReadyToPay({ state: noConfigOrOptionsInstance }),
|
|
78
74
|
);
|
|
79
75
|
});
|
|
80
76
|
});
|
|
@@ -36,9 +36,7 @@ export async function mountAmountSelector() {
|
|
|
36
36
|
currency,
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const readyToPayUpdated = await fetchReadyToPay(
|
|
40
|
-
riskMetadata: state.data.riskMetadata,
|
|
41
|
-
});
|
|
39
|
+
const readyToPayUpdated = await fetchReadyToPay();
|
|
42
40
|
|
|
43
41
|
state.data.readyToPay = readyToPayUpdated;
|
|
44
42
|
|