• Web Applications

Integrating Paystack and Flutterwave Payments into Your Web App

How online payment gateways work, why server-side verification matters and common mistakes to avoid when accepting payments in Nigeria.

How payment gateways work

Payment gateways such as Paystack and Flutterwave let you accept cards, bank transfers, USSD and other methods without handling sensitive card data yourself. Your application starts a transaction, the customer completes payment in a secure checkout hosted by the gateway, and the gateway tells you the result. Because the gateway collects the card details, your system stays out of much of the heavy compliance burden that comes with storing card data.

The basic flow

  • Your application creates a unique reference for the order and records it as pending.
  • The customer is sent to, or shown, the gateway checkout with the amount, currency and reference.
  • After payment, the gateway returns the customer to your site and also notifies your server through a webhook.
  • Your server verifies the transaction directly with the gateway using your secret key.
  • Only after successful verification does your system mark the order paid and deliver the product or service.

Always verify on the server

The most common and most costly mistake is trusting the browser. A success message shown in the customer's browser can be faked by anyone who knows how to use developer tools. Your server must call the gateway verification endpoint with your secret key and confirm three things: the transaction was successful, the amount matches what you expected and the currency is correct. Also make sure each reference can be used only once, so a single payment cannot be replayed to unlock many orders.

Use webhooks, but secure them

Webhooks notify your server of events such as successful charges even if the customer closes the browser before returning to your site. Validate the signature the gateway sends, so you know the request is genuine, and make your handler idempotent, so processing the same event twice does not duplicate an order. Respond quickly and do heavy work in the background.

Protect your keys

Public keys can appear in front-end code, but secret keys must never be exposed. Keep them in environment variables on the server, never in a repository or a client-side bundle, and use separate test and live keys. If a secret key is ever exposed, rotate it immediately.

Design for failure

  • Handle abandoned and failed payments gracefully, with clear messages and an easy way to retry.
  • Reconcile regularly: compare your records to the gateway dashboard to catch mismatches.
  • Store the gateway transaction ID and reference with every order for support and refunds.
  • Plan for pending states, because bank transfers and USSD can take time to confirm.
  • Test with the gateway test cards and simulated failures before going live.

Pay attention to the customer experience

Show the amount and currency clearly, offer the payment methods your customers actually use, send a receipt by email or message, and make it obvious how to get help. A smooth checkout directly affects how many customers complete their purchase.

Get it reviewed

Payments are an area where small mistakes have real financial consequences. Have your integration reviewed, test the unhappy paths and monitor transactions after launch. We build and review payment integrations for web applications, including those in our own portfolio.

Talk to Fortune Digital Services

Have a software, web application or infrastructure project in mind? Tell us about it and we will get back to you.

Contact us