Option 2: Standard

Redirect to our Authorization URL and BOOM! You are paid!

In this case, clicking your "Pay now" button button should post the values to your server which will then redirect your visitor to the Paystack payment form on our servers.

  1. Make the form submit to the script on your server that saves the order.
  2. Save the order on your server.
  3. Initialize a transaction via our API (We are employing the Paystack-PHP in this sample)
  4. Redirect to the Authorization URL generated.
<form action="/save-order-and-pay.php" method="POST">
 <input type="hidden" name="email_prepared_for_paystack" value="<?php echo $email; ?>"> 
 <input type="hidden" name="amount" value="<?php echo $amount_in_kobo; ?>"> 
 <input type="hidden" name="cartid" value="<?php echo $cartid; ?>"> 
 <button type="submit" name="pay_now" id="pay-now" title="Pay now">Pay now</button>


Setting a callback url

Once payment is complete, your visitor will be redirected to your Callback URL. You can set this while initializing the transaction (commented in code below) or on your Dashboard. This should be a fully qualified link to /verify.php. e.g. http://your-site.tld/folder/anotherfolder/verify.php.


// validate and save the order posted

// craft a reference for the payment, here we are using the ID from saving it earlier
$reference = $savedOrder->id

// Get this from https://github.com/yabacon/paystack-class
require 'Paystack.php'; 
// if using https://github.com/yabacon/paystack-php
// require 'paystack/autoload.php';

$paystack = new Paystack('sk_test_xxx');
// the code below throws an exception if there was a problem completing the request, 
// else returns an object created from the json response
$trx = $paystack->transaction->initialize(
    'amount'=>$_POST['amount'], /* 20 naira */
    // 'callback_url'=>'http://your-site.tld/folder/anotherfolder/verify.php',
      'custom_fields'=> [
          'display_name'=> "Paid on",
          'variable_name'=> "paid_on",
          'value'=> 'Website'
          'display_name'=> "Paid via",
          'variable_name'=> "paid_via",
          'value'=> 'Standard'
// status should be true if there was a successful call
// full sample initialize response is here: https://developers.paystack.co/docs/initialize-a-transaction
// Get the user to click link to start payment or simply redirect to the url generated
header('Location: ' . $trx->data->authorization_url);

Drop comments here