-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Location: frontend/components/payments/PaystackPaymentButton.tsx
Description
ManageHub uses Paystack for payment processing. Rather than redirecting the member to a separate page, Paystack supports an inline popup that keeps the user on the platform. This component wraps the Paystack inline JS SDK, calls the backend to get an authorization_url, and opens the Paystack popup for the member to complete their payment.
The Paystack inline script (https://js.paystack.co/v1/inline.js) exposes a window.PaystackPop.setup() method. The public key is stored in the NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY environment variable.
Acceptance Criteria
- The component is created at
frontend/components/payments/PaystackPaymentButton.tsx - Accepts props:
bookingId: stringamountKobo: number(used for display only — the actual charge amount is set server-side)onSuccess?: () => void— callback fired after Paystack confirms paymentonClose?: () => void— callback fired if the user closes the popup without paying
- On button click, calls
useInitiatePaymentto get thereferenceandauthorizationUrlfrom the backend - After receiving the reference, opens the Paystack popup using
window.PaystackPop.setup()with:key:NEXT_PUBLIC_PAYSTACK_PUBLIC_KEYemail: the logged-in user's email (from auth store)amount:amountKoboref: the reference from the backendonSuccess: calls theonSuccessprop and invalidates relevant queriesonCancel: calls theonCloseprop
- The Paystack inline script is loaded via a
<Script>tag (Next.jsnext/script) withstrategy="beforeInteractive"or handled with a load check - The button shows a loading state while the
useInitiatePaymentmutation is pending -
npx tsc --noEmitpasses with no errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers