fontdue-js 1.12.1 → 1.12.3
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
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 1.12.2
|
|
2
|
+
|
|
3
|
+
- Fixes an issue completing checkout with a 100% coupon
|
|
4
|
+
|
|
5
|
+
## 1.12.1
|
|
6
|
+
|
|
7
|
+
- Fixes issues in the StoreModal router
|
|
8
|
+
|
|
9
|
+
## 1.12.0
|
|
10
|
+
|
|
11
|
+
- Added `indexExcludeTags` option to `storeModal` config
|
|
12
|
+
|
|
13
|
+
## 1.11.0
|
|
14
|
+
|
|
15
|
+
- Updated Stripe integration and checkout UX to support payment methods via
|
|
16
|
+
Stripe's Payment Element
|
|
17
|
+
|
|
1
18
|
## 1.10.2
|
|
2
19
|
|
|
3
20
|
- Fixed error importing module
|
|
@@ -35,7 +35,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
35
35
|
const submitCompleteMutation = _StoreModalReviewCompleteOrderMutation !== void 0 ? _StoreModalReviewCompleteOrderMutation : (_StoreModalReviewCompleteOrderMutation = require("../../__generated__/StoreModalReviewCompleteOrderMutation.graphql"), _StoreModalReviewCompleteOrderMutation.hash && _StoreModalReviewCompleteOrderMutation.hash !== "de20197df49deb030c473adbd9560e03" && console.error("The definition of 'StoreModalReviewCompleteOrderMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalReviewCompleteOrderMutation);
|
|
36
36
|
const updateOrderMutation = _StoreModalReviewUpdateOrderMutation !== void 0 ? _StoreModalReviewUpdateOrderMutation : (_StoreModalReviewUpdateOrderMutation = require("../../__generated__/StoreModalReviewUpdateOrderMutation.graphql"), _StoreModalReviewUpdateOrderMutation.hash && _StoreModalReviewUpdateOrderMutation.hash !== "5ee297fdd5931c542d2f683651e54643" && console.error("The definition of 'StoreModalReviewUpdateOrderMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalReviewUpdateOrderMutation);
|
|
37
37
|
const StoreModalReview = _ref => {
|
|
38
|
-
var _order$stripePaymentI, _order$
|
|
38
|
+
var _order$stripePaymentI, _order$orderItems, _viewer$settings;
|
|
39
39
|
let {
|
|
40
40
|
viewer: viewerKey,
|
|
41
41
|
order: orderKey
|
|
@@ -63,15 +63,28 @@ const StoreModalReview = _ref => {
|
|
|
63
63
|
stripe = (0, _reactStripeJs.useStripe)();
|
|
64
64
|
elements = (0, _reactStripeJs.useElements)();
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
(0, _react.useEffect)(() => {
|
|
67
|
+
// first do an `update` mutation without any inputs, which will make sure
|
|
68
|
+
// the total has been calculated from the latest coupon data. if the total
|
|
69
|
+
// doesn't change, submit the payment
|
|
70
|
+
(0, _relayRuntime.commitMutation)(environment, {
|
|
71
|
+
mutation: updateOrderMutation,
|
|
72
|
+
variables: {
|
|
73
|
+
input: {}
|
|
74
|
+
},
|
|
75
|
+
onCompleted: (response, errors) => {
|
|
76
|
+
if (errors && errors.length > 0) {
|
|
77
|
+
setCompleting(false);
|
|
78
|
+
setError(errors[0].message);
|
|
79
|
+
scrollToTop === null || scrollToTop === void 0 ? void 0 : scrollToTop();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
70
83
|
});
|
|
71
|
-
}
|
|
72
|
-
const billingIdentity = order.billingIdentity;
|
|
73
|
-
const lastShownTotal = (0, _react.useRef)((_order$total = order.total) === null || _order$total === void 0 ? void 0 : _order$total.amount);
|
|
84
|
+
}, []);
|
|
74
85
|
const handleSubmit = () => {
|
|
86
|
+
var _stripe, _billingIdentity$stre, _billingIdentity$stre2;
|
|
87
|
+
if (!order) return;
|
|
75
88
|
if (!billingIdentity) {
|
|
76
89
|
console.error('No billing identity, required for payment');
|
|
77
90
|
return;
|
|
@@ -93,63 +106,35 @@ const StoreModalReview = _ref => {
|
|
|
93
106
|
});
|
|
94
107
|
return;
|
|
95
108
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
const newTotal = (_response$updateOrder = response.updateOrder) === null || _response$updateOrder === void 0 ? void 0 : (_response$updateOrder2 = _response$updateOrder.order) === null || _response$updateOrder2 === void 0 ? void 0 : (_response$updateOrder3 = _response$updateOrder2.total) === null || _response$updateOrder3 === void 0 ? void 0 : _response$updateOrder3.amount;
|
|
114
|
-
if (newTotal !== lastShownTotal.current) {
|
|
115
|
-
var _response$updateOrder4, _response$updateOrder5, _response$updateOrder6;
|
|
116
|
-
setCompleting(false);
|
|
117
|
-
setError('Order total has updated. Please review and confirm again.');
|
|
118
|
-
scrollToTop === null || scrollToTop === void 0 ? void 0 : scrollToTop();
|
|
119
|
-
lastShownTotal.current = (_response$updateOrder4 = response.updateOrder) === null || _response$updateOrder4 === void 0 ? void 0 : (_response$updateOrder5 = _response$updateOrder4.order) === null || _response$updateOrder5 === void 0 ? void 0 : (_response$updateOrder6 = _response$updateOrder5.total) === null || _response$updateOrder6 === void 0 ? void 0 : _response$updateOrder6.amount;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (!stripe || !elements) return;
|
|
123
|
-
(_stripe = stripe) === null || _stripe === void 0 ? void 0 : _stripe.confirmPayment({
|
|
124
|
-
elements,
|
|
125
|
-
confirmParams: {
|
|
126
|
-
return_url: order.completeUrl,
|
|
127
|
-
payment_method_data: {
|
|
128
|
-
billing_details: {
|
|
129
|
-
email: billingIdentity.email,
|
|
130
|
-
name: billingIdentity.name,
|
|
131
|
-
address: {
|
|
132
|
-
line1: (_billingIdentity$stre = billingIdentity.street) === null || _billingIdentity$stre === void 0 ? void 0 : _billingIdentity$stre.split(/\n/)[0],
|
|
133
|
-
line2: ((_billingIdentity$stre2 = billingIdentity.street) === null || _billingIdentity$stre2 === void 0 ? void 0 : _billingIdentity$stre2.split(/\n/)[1]) ?? '',
|
|
134
|
-
city: billingIdentity.locality ?? '',
|
|
135
|
-
state: billingIdentity.administrativeArea ?? '',
|
|
136
|
-
country: billingIdentity.country,
|
|
137
|
-
postal_code: billingIdentity.zip ?? undefined
|
|
138
|
-
}
|
|
139
|
-
}
|
|
109
|
+
if (!stripe || !elements) return;
|
|
110
|
+
(_stripe = stripe) === null || _stripe === void 0 ? void 0 : _stripe.confirmPayment({
|
|
111
|
+
elements,
|
|
112
|
+
confirmParams: {
|
|
113
|
+
return_url: order.completeUrl,
|
|
114
|
+
payment_method_data: {
|
|
115
|
+
billing_details: {
|
|
116
|
+
email: billingIdentity.email,
|
|
117
|
+
name: billingIdentity.name,
|
|
118
|
+
address: {
|
|
119
|
+
line1: (_billingIdentity$stre = billingIdentity.street) === null || _billingIdentity$stre === void 0 ? void 0 : _billingIdentity$stre.split(/\n/)[0],
|
|
120
|
+
line2: ((_billingIdentity$stre2 = billingIdentity.street) === null || _billingIdentity$stre2 === void 0 ? void 0 : _billingIdentity$stre2.split(/\n/)[1]) ?? '',
|
|
121
|
+
city: billingIdentity.locality ?? '',
|
|
122
|
+
state: billingIdentity.administrativeArea ?? '',
|
|
123
|
+
country: billingIdentity.country,
|
|
124
|
+
postal_code: billingIdentity.zip ?? undefined
|
|
140
125
|
}
|
|
141
126
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
console.log(error);
|
|
150
|
-
setCompleting(false);
|
|
151
|
-
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}).then(result => {
|
|
130
|
+
if ('error' in result) {
|
|
131
|
+
setCompleting(false);
|
|
132
|
+
setError(result.error.message ?? 'Payment failed. Please try another payment method.');
|
|
133
|
+
scrollToTop === null || scrollToTop === void 0 ? void 0 : scrollToTop();
|
|
152
134
|
}
|
|
135
|
+
}).catch(error => {
|
|
136
|
+
console.log(error);
|
|
137
|
+
setCompleting(false);
|
|
153
138
|
});
|
|
154
139
|
};
|
|
155
140
|
const handleClickSection = step => {
|
|
@@ -159,6 +144,13 @@ const StoreModalReview = _ref => {
|
|
|
159
144
|
route: 'checkout'
|
|
160
145
|
});
|
|
161
146
|
};
|
|
147
|
+
if (!order) return null;
|
|
148
|
+
if (order.completedWithCoupon) {
|
|
149
|
+
return /*#__PURE__*/_react.default.createElement(_StoreModalDownload.default, {
|
|
150
|
+
order: order
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const billingIdentity = order.billingIdentity;
|
|
162
154
|
return /*#__PURE__*/_react.default.createElement(_StoreModalPageContainer.default, null, {
|
|
163
155
|
title: 'Review & pay',
|
|
164
156
|
body: /*#__PURE__*/_react.default.createElement(_StoreModalReviewLayout.default, {
|