Skip to content

Commit ba0c367

Browse files
committed
Show the checkout modal even if no payment is needed
1 parent ac437c7 commit ba0c367

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/javascript/Store/OrderPaymentModal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ function OrderPaymentModal({ visible, onCancel, onError, onComplete, order }: Or
150150
const client = useApolloClient();
151151
const onErrorRef = useRef(onError);
152152

153+
const paymentIntentClientSecretNeeded = useMemo(() => order != null && order.total_price.fractional > 0, [order]);
154+
153155
useEffect(() => {
154156
onErrorRef.current = onError;
155157
}, [onError]);
@@ -171,14 +173,14 @@ function OrderPaymentModal({ visible, onCancel, onError, onComplete, order }: Or
171173
useEffect(() => {
172174
setPaymentIntentClientSecret(undefined);
173175

174-
if (order != null && order.total_price.fractional > 0) {
176+
if (paymentIntentClientSecretNeeded) {
175177
refreshPaymentIntentClientSecret();
176178
}
177-
}, [order, order?.total_price, order?.order_entries, refreshPaymentIntentClientSecret]);
179+
}, [paymentIntentClientSecretNeeded, refreshPaymentIntentClientSecret]);
178180

179181
return (
180182
<Modal visible={visible && order != null} dialogClassName="modal-lg">
181-
{visible && paymentIntentClientSecret && order != null && (
183+
{visible && order != null && (paymentIntentClientSecret || !paymentIntentClientSecretNeeded) && (
182184
<LazyStripeElementsContainer options={{ clientSecret: paymentIntentClientSecret }}>
183185
<OrderPaymentModalContents onCancel={onCancel} onComplete={onComplete} onError={onError} order={order} />
184186
</LazyStripeElementsContainer>

0 commit comments

Comments
 (0)