fontdue-js 1.12.2 → 1.12.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
CHANGED
|
@@ -31,7 +31,7 @@ const FontdueProvider = _ref => {
|
|
|
31
31
|
stripeIntegration
|
|
32
32
|
}));
|
|
33
33
|
const configValue = (0, _ConfigContext.makeConfig)(config);
|
|
34
|
-
const store = (0, _redux.createStore)(_reducer.default, {
|
|
34
|
+
const store = (0, _react.useRef)((0, _redux.createStore)(_reducer.default, {
|
|
35
35
|
selectedSkuIds: {},
|
|
36
36
|
// { [skuId]: Boolean }
|
|
37
37
|
licenseOptions: [],
|
|
@@ -49,11 +49,11 @@ const FontdueProvider = _ref => {
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
storeModalHistory: []
|
|
52
|
-
});
|
|
52
|
+
}));
|
|
53
53
|
return /*#__PURE__*/_react.default.createElement(_reactRelay.RelayEnvironmentProvider, {
|
|
54
54
|
environment: environment.current
|
|
55
55
|
}, /*#__PURE__*/_react.default.createElement(_reactRedux.Provider, {
|
|
56
|
-
store: store
|
|
56
|
+
store: store.current
|
|
57
57
|
}, /*#__PURE__*/_react.default.createElement(_Stylesheet.StylesheetContainer, null), /*#__PURE__*/_react.default.createElement(_ThemeConfig.default, null), /*#__PURE__*/_react.default.createElement(_ConfigContext.default.Provider, {
|
|
58
58
|
value: configValue
|
|
59
59
|
}, /*#__PURE__*/_react.default.createElement(_ComponentsContext.default.Provider, {
|
|
@@ -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,8 +63,27 @@ const StoreModalReview = _ref => {
|
|
|
63
63
|
stripe = (0, _reactStripeJs.useStripe)();
|
|
64
64
|
elements = (0, _reactStripeJs.useElements)();
|
|
65
65
|
}
|
|
66
|
-
|
|
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
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, []);
|
|
67
85
|
const handleSubmit = () => {
|
|
86
|
+
var _stripe, _billingIdentity$stre, _billingIdentity$stre2;
|
|
68
87
|
if (!order) return;
|
|
69
88
|
if (!billingIdentity) {
|
|
70
89
|
console.error('No billing identity, required for payment');
|
|
@@ -87,63 +106,35 @@ const StoreModalReview = _ref => {
|
|
|
87
106
|
});
|
|
88
107
|
return;
|
|
89
108
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
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;
|
|
108
|
-
if (newTotal !== lastShownTotal.current) {
|
|
109
|
-
var _response$updateOrder4, _response$updateOrder5, _response$updateOrder6;
|
|
110
|
-
setCompleting(false);
|
|
111
|
-
setError('Order total has updated. Please review and confirm again.');
|
|
112
|
-
scrollToTop === null || scrollToTop === void 0 ? void 0 : scrollToTop();
|
|
113
|
-
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;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (!stripe || !elements) return;
|
|
117
|
-
(_stripe = stripe) === null || _stripe === void 0 ? void 0 : _stripe.confirmPayment({
|
|
118
|
-
elements,
|
|
119
|
-
confirmParams: {
|
|
120
|
-
return_url: order.completeUrl,
|
|
121
|
-
payment_method_data: {
|
|
122
|
-
billing_details: {
|
|
123
|
-
email: billingIdentity.email,
|
|
124
|
-
name: billingIdentity.name,
|
|
125
|
-
address: {
|
|
126
|
-
line1: (_billingIdentity$stre = billingIdentity.street) === null || _billingIdentity$stre === void 0 ? void 0 : _billingIdentity$stre.split(/\n/)[0],
|
|
127
|
-
line2: ((_billingIdentity$stre2 = billingIdentity.street) === null || _billingIdentity$stre2 === void 0 ? void 0 : _billingIdentity$stre2.split(/\n/)[1]) ?? '',
|
|
128
|
-
city: billingIdentity.locality ?? '',
|
|
129
|
-
state: billingIdentity.administrativeArea ?? '',
|
|
130
|
-
country: billingIdentity.country,
|
|
131
|
-
postal_code: billingIdentity.zip ?? undefined
|
|
132
|
-
}
|
|
133
|
-
}
|
|
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
|
|
134
125
|
}
|
|
135
126
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
console.log(error);
|
|
144
|
-
setCompleting(false);
|
|
145
|
-
});
|
|
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();
|
|
146
134
|
}
|
|
135
|
+
}).catch(error => {
|
|
136
|
+
console.log(error);
|
|
137
|
+
setCompleting(false);
|
|
147
138
|
});
|
|
148
139
|
};
|
|
149
140
|
const handleClickSection = step => {
|