PHP code example of turndale / paystack

1. Go to this page and download the library: Download turndale/paystack library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

turndale / paystack example snippets


use Turndale\Paystack\Facades\Paystack;

// Initialize a transaction
$response = Paystack::transaction()->initialize([
    'email' => '[email protected]',
    'amount' => 5000 // NGN 50.00
]);

return redirect($response['data']['authorization_url']);

// Create a subscription
Paystack::subscription()->create([
    'customer' => 'CUS_xxxx',
    'plan' => 'PLN_xxxx'
]);

// Create a split
Paystack::transactionSplit()->create([
    'name' => 'Percentage Split',
    'type' => 'percentage',
    'currency' => 'NGN',
    'subaccounts' => [
        ['subaccount' => 'ACCT_xxxx', 'share' => 20]
    ]
]);

use Turndale\Paystack\Events\PaymentSuccess;

Event::listen(PaymentSuccess::class, function ($event) {
    // Handle successful payment...
});
bash
php artisan vendor:publish --tag=paystack-config