PHP code example of stephenjude / laravel-payment-gateways

1. Go to this page and download the library: Download stephenjude/laravel-payment-gateways 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/ */

    

stephenjude / laravel-payment-gateways example snippets


use Stephenjude\PaymentGateway\DataObjects\TransactionData;

function (TransactionData $payment){
    $order->update([
        'status' => $payment->status, 
        'amount' => $payment->amount, 
        'currency' => $payment->currency
    ]);
    
    $customer->notify(new OrderPaymentNotification($order));
}

use Stephenjude\PaymentGateway\PaymentGateway;
use Stephenjude\PaymentGateway\DataObjects\TransactionData;

$provider = PaymentGateway::make('paystack')

$paymentSession = $provider->initializeCheckout([
    'currency' => 'NGN', // yment verification happens immediately after the customer makes payment. 
         * The payment data obtained from the verification will be injected into this closure.
         */
        logger('payment details', [
           'currency' => $payment->currency, 
           'amount' => $payment->amount, 
           'status' => $payment->status,
           'reference' => $payment->reference,   
           'provider' => $payment->provider,   
           'date' => $payment->date,                   
        ]);
    },
]);

$paymentSession->provider;
$paymentSession->checkoutUrl;
$paymentSession->expires;


$provider = PaymentGateway::make('paystack'); 

$transactions = $provider->listTransactions(); // Returns array

$transaction = $provider->findTransaction(REFERENCE); // Returns Stephenjude\PaymentGateway\DataObjects\TransactionData 
$transaction->provider;
$transaction->email;
$transaction->amount;
$transaction->currency;
$transaction->reference;
$transaction->status;
$transaction->date;
 
use \Stephenjude\PaymentGateway\Enums\Provider;
use \Stephenjude\PaymentGateway\PaymentGateway;

$pawapay = PaymentGateway::make(Provider::PAWAPAY())->initializeCheckout([
    "amount" => 15,
    "country" => "ZMB",
    'meta' => [
        "description" => "Note of 4 to 22 chars",
        "reason" => "Ticket to festival"
    ]
]);
bash
php artisan vendor:publish --tag="payment-gateways-config"
bash
php artisan vendor:publish --tag="payment-gateways-views"