@rebilly/instruments 3.28.2 → 3.28.4
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 +9 -9
- package/dist/index.min.js +9 -9
- package/package.json +1 -1
- package/src/storefront/purchase.js +42 -8
package/package.json
CHANGED
|
@@ -3,18 +3,52 @@ import { Endpoint } from './index';
|
|
|
3
3
|
|
|
4
4
|
export async function postPurchase({ data }) {
|
|
5
5
|
return Endpoint(async () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
// https://storefront-api-docs.rebilly.com/tag/Purchases/operation/StorefrontPostPurchase
|
|
7
|
+
const purchaseSchemaKeys = [
|
|
8
|
+
'websiteId',
|
|
9
|
+
'paymentInstruction',
|
|
10
|
+
'items',
|
|
11
|
+
'billingAddress',
|
|
12
|
+
'deliveryAddress',
|
|
13
|
+
'shippingRateId',
|
|
14
|
+
'couponIds',
|
|
15
|
+
'password',
|
|
16
|
+
'redirectUrl',
|
|
17
|
+
];
|
|
18
|
+
Object.keys(data).forEach((key) => {
|
|
19
|
+
if (!purchaseSchemaKeys.includes(key)) {
|
|
20
|
+
delete data[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return state.storefront.purchase.purchase({data});
|
|
10
24
|
});
|
|
11
25
|
}
|
|
12
26
|
|
|
13
27
|
export async function postPayment({ data }) {
|
|
14
28
|
return Endpoint(async () => {
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
const {token, transactionId, invoiceId, websiteId, paymentInstrumentId} = data;
|
|
30
|
+
// https://storefront-api-docs.rebilly.com/tag/Purchases/operation/StorefrontPostPayment
|
|
31
|
+
const purchaseSchemaKeys = ['riskMetadata', 'redirectUrl'];
|
|
32
|
+
if (token) {
|
|
33
|
+
purchaseSchemaKeys.push('token');
|
|
34
|
+
}
|
|
35
|
+
if (paymentInstrumentId) {
|
|
36
|
+
purchaseSchemaKeys.push('paymentInstrumentId');
|
|
37
|
+
}
|
|
38
|
+
if (transactionId) {
|
|
39
|
+
purchaseSchemaKeys.push('transactionId');
|
|
17
40
|
}
|
|
18
|
-
|
|
41
|
+
if (invoiceId) {
|
|
42
|
+
purchaseSchemaKeys.push('invoiceId');
|
|
43
|
+
}
|
|
44
|
+
if (websiteId) {
|
|
45
|
+
purchaseSchemaKeys.push('amount', 'currency', 'websiteId');
|
|
46
|
+
}
|
|
47
|
+
Object.keys(data).forEach((key) => {
|
|
48
|
+
if (!purchaseSchemaKeys.includes(key)) {
|
|
49
|
+
delete data[key];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return state.storefront.purchase.payment({data});
|
|
19
53
|
});
|
|
20
|
-
}
|
|
54
|
+
}
|