← Back to work
Documentation audit
Paystack API — Before → After Documentation Fix
The Initialise section of the Paystack API website has several issues that are addressed, and solutions proposed.
Paystack
REST API
Audit & rewrite

Overview

The Initialise section of the Paystack API website has several issues that make it harder for developers to understand and implement correctly.

These problems are identified here, with a clearer fix rewritten, and an explanation for why the improved version is better.

The Problem

1. The section presents a weak mental model

The documentation says:

"Initialise the transaction from your backend"

It doesn't clearly answer:

This can be difficult for a beginner to grasp, leaving them without a clear understanding of the step.

2. It jumps into code too fast

The code is introduced too quickly, going straight to:

curl https://api.paystack.co/transaction/initialize

Without clearly explaining:

This can quickly increase cognitive load.

3. Incomplete explanation of the response

It says:

"access_code parameter... needed to complete the transaction"

This:

4. The flow is incomplete

The developer doesn't see the full picture or what happens after initialisation.

What should have been said:

"After this → redirect user → payment happens"

5. The warning is disconnected

The "Don't use your secret key…" section:

This feels poorly placed.

The Rewrite

Before a customer can make a payment, you need to create a transaction.

When you are initialising a transaction, you are telling Paystack:

Follow these steps from your backend to keep your secret key secure.

Step 1: Send a request to Paystack

To initialise a transaction, send a POST request to Paystack's API from your server:

curl -X POST https://api.paystack.co/transaction/initialize   -H "Authorization: Bearer YOUR_SECRET_KEY"   -H "Content-Type: application/json"   -d '{
        "email": "customer@email.com",
        "amount": 500000
      }'

This request creates a new transaction for the specified customer and amount.

Step 2: Handle the response

Paystack returns a response containing important details about the transaction.

Inside the data object, you'll find:

Step 3: Redirect the customer

To complete the payment, redirect the customer to the authorization_url.

This takes them to Paystack's secure payment page, where they can enter their payment details.

Important: Keep your secret key secure

Always initialise transactions from your backend. Never call Paystack's API directly from your frontend, as this would expose your secret key. Instead, your frontend should communicate with your server, which then makes the request to Paystack.

Why This Version is Clearer and Better

Before
  • Weak mental model
  • Code introduced too quickly
  • Incomplete response explanation
  • Incomplete flow
  • Disconnected security warning
After
  • Clear mental model introduced first
  • Context given before code
  • All response fields explained in context
  • Full flow shown including redirect
  • Security guidance woven naturally into steps

Unlike Paystack's, this version: