diff --git a/jam-ui/src/components/page/JKPaymentMethod.js b/jam-ui/src/components/page/JKPaymentMethod.js index 784a64bdb..f25880c3e 100644 --- a/jam-ui/src/components/page/JKPaymentMethod.js +++ b/jam-ui/src/components/page/JKPaymentMethod.js @@ -196,21 +196,70 @@ const JKPaymentMethod = () => { }); }; - const onSubmit = async (data) => { + // const onSubmit = async (data) => { + // //first update billing address + // setSubmitting(true); + // const resp = await updateBillingInfo(data) + // if (!resp.ok) { + // setSubmitting(false); + // const errorData = await resp.json(); + // console.error('Error updating billing info:', errorData); + // toast.error(errorData.message || t('payment_method.alerts.billing_update_error')); + // return; + // } + // if (paymentMethod === 'paypal') { + // handoverToPaypal(); + // return; + // } else { + + // if (!elementsRef.current) { + // console.error('Recurly elementsRef.current is not ready'); + // setSubmitting(false); + // return; + // } + // if (!formRef.current) { + // console.error('formRef.current is not ready'); + // setSubmitting(false); + // return; + // } + + // // if (!isCardValid) { + // // console.error('Card is not valid'); + // // toast.error(t('payment_method.validations.card.invalid')); + // // setSubmitting(false); + // // return; + // // } + + // window.recurly.token(elementsRef.current, formRef.current, (err, token) => { + // if (err) { + // console.error('Recurly token error:', err); + // toast.error(err.message || t('payment_method.alerts.card_processing_error')); + // setSubmitting(false); + // } else { + // console.log('Recurly token:', token.id); + // // send token.id to backend + // handleUpdatePayment(token); + // } + // }); + // } + + // }; + + const onSubmit = async (data) => { //first update billing address setSubmitting(true); - const resp = await updateBillingInfo(data) - if (!resp.ok) { - setSubmitting(false); - const errorData = await resp.json(); - console.error('Error updating billing info:', errorData); - toast.error(errorData.message || t('payment_method.alerts.billing_update_error')); - return; - } + // const resp = await updateBillingInfo(data) + // if (!resp.ok) { + // setSubmitting(false); + // const errorData = await resp.json(); + // console.error('Error updating billing info:', errorData); + // toast.error(errorData.message || t('payment_method.alerts.billing_update_error')); + // return; + // } if (paymentMethod === 'paypal') { handoverToPaypal(); return; - } else { + } else { // Credit Card payment method if (!elementsRef.current) { console.error('Recurly elementsRef.current is not ready'); @@ -223,17 +272,10 @@ const JKPaymentMethod = () => { return; } - // if (!isCardValid) { - // console.error('Card is not valid'); - // toast.error(t('payment_method.validations.card.invalid')); - // setSubmitting(false); - // return; - // } - window.recurly.token(elementsRef.current, formRef.current, (err, token) => { if (err) { console.error('Recurly token error:', err); - toast.error(err.message || t('payment_method.alerts.card_processing_error')); + toast.error(t('payment_method.alerts.card_processing_error')); setSubmitting(false); } else { console.log('Recurly token:', token.id); @@ -265,7 +307,7 @@ const JKPaymentMethod = () => { {t('payment_method.help_text_no_card')} )} - {t('payment_method.help_text')} + {t('payment_method.help_text')}