Payments
Collect school enrollment fees with Paystack — initialize, verify, and handle webhooks.
How it works
- Fetch config — get your fee structure and Paystack public key from the Nexa dashboard
- Initialize — create a Paystack session, receive a checkout URL
- Redirect — send the student to Paystack to complete payment
- Verify — confirm the transaction after the student returns
- Webhook — Nexa forwards the confirmed event to your server
Your API key stays server-side throughout — the browser calls your /api/nexa/payments/* proxy routes, never the Nexa API directly.
Step 1 — Fetch payment config
Retrieve your fee structure before initializing payments. You'll need this to calculate the gross amount the student pays.
Calculate the gross amount
Nexa can calculate the total charge so the school receives your exact amount net of all fees:
Step 2 — Initialize a payment
Create a Paystack session and get a checkout URL to redirect the student to.
nexa.payments.initialize() must be called server-side — your API key stays on the server. Return the authorizationUrl to the browser, then redirect.
Server (API route / server action)
Client (browser)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Student or payer email |
amount | number | Yes | Amount in kobo (₦1 = 100) |
reference | string | No | Unique ref — auto-generated if omitted |
metadata | object | No | Any key-value data; echoed back on the webhook |
Step 3 — Verify after return
When Paystack redirects the student back to your app, verify the transaction:
Step 4 — Handle the webhook
Configure https://your-domain.com/api/nexa/payments/forward in the Nexa dashboard. The SDK verifies the signature and calls your callback:
For the full event payload see Webhooks.
Manual sync
To pull the latest status from Paystack on demand (useful for reconciliation):
React components
For a complete payment UI without building it yourself:
<NexaPaymentWidget />— inline payment form<EnrollmentPaymentFlow />— full enrollment flow with fee breakdown<PaymentStatusDashboard />— admin view of all transactions
What's next
- Webhooks — full payload types and signature verification
- React Components — pre-built payment UI