Skip to content

Paystack

Paystack supports hosted checkout and, for eligible accounts, a broad set of payment operations. Select it as the default with PAYMENT_GATEWAY=paystack or resolve it explicitly with Payment::driver('paystack').

Setup

Create API keys in the Paystack dashboard and add them to your environment:

PAYSTACK_PUBLIC_KEY=pk_test_...
PAYSTACK_SECRET_KEY=sk_test_...
PAYSTACK_CALLBACK_URL=https://example.com/payment/callback
PAYSTACK_WEBHOOK_SECRET=your_webhook_secret

The driver uses Paystack's API (https://api.paystack.co). Keep secret keys server-side. Configure the webhook URL as https://example.com/webhooks/payment-gateways/paystack in the Paystack dashboard.

Hosted checkout

use Alphabalex\PaymentMadeEasy\Facades\Payment;

$driver = Payment::driver('paystack');
$checkout = $driver->initializePayment([
    'email'        => 'customer@example.com',
    'amount'       => 5000.00, // major units; the driver converts to kobo
    'reference'    => 'ORDER_123',
    'callback_url' => 'https://example.com/payment/callback',
    'metadata'     => ['order_id' => '123'],
]);

// Send the customer to $checkout['data']['authorization_url'].
// Verify the reference server-side before fulfilling the order.
$payment = $driver->verifyPayment('ORDER_123');

Amounts passed to the package are in major currency units. Do not multiply NGN amounts by 100; the driver converts to Paystack's subunits.

Package capabilities

The driver implements the shared payment, subscription, disbursement, virtual-account, payment-link, customer, dispute, balance, settlement, subaccount, split, and charge-authorization interfaces. It also exposes provider-specific transaction, transfer, dispute, and payment-request operations. Provider account permissions and availability still apply.

use Alphabalex\PaymentMadeEasy\GatewayCapabilities;
use Alphabalex\PaymentMadeEasy\Contracts\DisbursementDriverInterface;

if (GatewayCapabilities::driverImplements('paystack', DisbursementDriverInterface::class)) {
    $driver->transfer([...]);
}

Operational notes

  • Use a unique reference for every order and verify payment status using the server-side API.
  • A successful browser redirect is not proof of payment; use verification and/or the signed webhook.
  • The shared webhook endpoint is /webhooks/payment-gateways/paystack. Review webhook security and event handling.
  • Amounts, currencies, required KYC fields, and feature access depend on Paystack account settings.

For complete method signatures and examples, see Paystack in the API reference. Related: payments · configuration · gateway directory.