Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
handle payment being done
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnIckler committed Oct 25, 2023
1 parent 45c1082 commit 5b97c1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Frontend/src/api/registration/get/get_payment_intent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface PaymentInfo {
// This is the MySQL payment id that can be give to the payment service
// to get the relevant data, not the Stripe ID!
id: string
status: string
}
// We get the user_id out of the JWT key, which is why we only send the
// competition_id
Expand Down
6 changes: 5 additions & 1 deletion Frontend/src/pages/register/components/StripeWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default function StripeWrapper() {
queryKey: ['payment-config', competitionInfo.id, paymentInfo?.id],
queryFn: () => getStripeConfig(competitionInfo.id, paymentInfo?.id),
onError: (err) => setMessage(err.error, 'error'),
enabled: !isPaymentIdLoading && !isError,
enabled:
!isPaymentIdLoading && !isError && paymentInfo?.status !== 'succeeded',
refetchOnWindowFocus: false,
refetchOnReconnect: false,
staleTime: Infinity,
Expand All @@ -64,6 +65,9 @@ export default function StripeWrapper() {
return (
<>
<h1>Payment</h1>
{paymentInfo?.status === 'succeeded' && (
<div>Your payment has been successfully processed.</div>
)}
{!isPaymentIdLoading && stripePromise && !isError && (
<Elements
stripe={stripePromise}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def payment_ticket
else
ticket = @registration.payment_ticket
end
render json: { id: ticket }
render json: { id: ticket, status: @registration.payment_status }
end

def validate_payment_ticket_request
Expand Down

0 comments on commit 5b97c1d

Please sign in to comment.