From f72e04fd24bc913b89b6e3bf571d81c8f9ebd9fb Mon Sep 17 00:00:00 2001
From: andrewHEguardian <114918544+andrewHEguardian@users.noreply.github.com>
Date: Fri, 25 Oct 2024 10:17:27 +0100
Subject: [PATCH 1/3] don't show Something went wrong with normal validation
error
---
.../[countryGroupId]/oneTimeCheckout.tsx | 56 ++++++++++---------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
index 10d5abd792..d0ef80a708 100644
--- a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
+++ b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
@@ -459,29 +459,31 @@ function OneTimeCheckoutComponent({
}
}
- setThankYouOrder({
- firstName: '',
- paymentMethod: paymentMethod,
- });
- const thankYouUrlSearchParams = new URLSearchParams();
- thankYouUrlSearchParams.set('contribution', finalAmount.toString());
- const nextStepRoute = paymentResultThankyouRoute(
- paymentResult,
- geoId,
- thankYouUrlSearchParams,
- );
- setIsProcessingPayment(false);
- if (nextStepRoute) {
- window.location.href = nextStepRoute;
- } else {
- setErrorMessage('Sorry, something went wrong.');
- if (
- paymentResult &&
- 'paymentStatus' in paymentResult &&
- paymentResult.paymentStatus === 'failure'
- ) {
- setErrorContext(appropriateErrorMessage(paymentResult.error ?? ''));
+ if (paymentResult) {
+ setThankYouOrder({
+ firstName: '',
+ paymentMethod: paymentMethod,
+ });
+ const thankYouUrlSearchParams = new URLSearchParams();
+ thankYouUrlSearchParams.set('contribution', finalAmount.toString());
+ const nextStepRoute = paymentResultThankyouRoute(
+ paymentResult,
+ geoId,
+ thankYouUrlSearchParams,
+ );
+ if (nextStepRoute) {
+ window.location.href = nextStepRoute;
+ } else {
+ setErrorMessage('Sorry, something went wrong.');
+ if (
+ 'paymentStatus' in paymentResult &&
+ paymentResult.paymentStatus === 'failure'
+ ) {
+ setErrorContext(appropriateErrorMessage(paymentResult.error ?? ''));
+ }
}
+ } else {
+ setIsProcessingPayment(false);
}
}
};
@@ -821,11 +823,6 @@ function OneTimeCheckoutComponent({
type="submit"
/>
-
-
-
-
-
{errorMessage && (
)}
+
+
+
+
+
From 8924e288e38ebc2171598b8195d486d0f9483a48 Mon Sep 17 00:00:00 2001
From: andrewHEguardian <114918544+andrewHEguardian@users.noreply.github.com>
Date: Fri, 25 Oct 2024 10:24:44 +0100
Subject: [PATCH 2/3] unset payment method validation when changed
---
.../assets/pages/[countryGroupId]/oneTimeCheckout.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
index d0ef80a708..516faaeaee 100644
--- a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
+++ b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
@@ -767,7 +767,7 @@ function OneTimeCheckoutComponent({
}
onChange={() => {
setPaymentMethod(validPaymentMethod);
-
+ setPaymentMethodError(undefined);
// Track payment method selection with QM
sendEventPaymentMethodSelected(validPaymentMethod);
}}
From ebf9a0564b237e152cff9a8963f09524dee64b2b Mon Sep 17 00:00:00 2001
From: andrewHEguardian <114918544+andrewHEguardian@users.noreply.github.com>
Date: Fri, 25 Oct 2024 11:58:45 +0100
Subject: [PATCH 3/3] add check for recaptcha token if stripe card
---
.../assets/pages/[countryGroupId]/oneTimeCheckout.tsx | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
index 516faaeaee..05b613e1ac 100644
--- a/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
+++ b/support-frontend/assets/pages/[countryGroupId]/oneTimeCheckout.tsx
@@ -395,7 +395,12 @@ function OneTimeCheckoutComponent({
elements,
});
}
- if (paymentMethod === 'Stripe' && stripe && cardElement) {
+ if (
+ paymentMethod === 'Stripe' &&
+ stripe &&
+ cardElement &&
+ recaptchaToken
+ ) {
paymentMethodResult = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
@@ -448,7 +453,6 @@ function OneTimeCheckoutComponent({
billingPostcode,
),
publicKey: stripePublicKey,
- // ToDo: validate recaptchaToken for card payments
recaptchaToken: recaptchaToken ?? '',
paymentMethodId: paymentMethodResult.paymentMethod.id,
};