PHP code example of devinweb / laravel-paytabs

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

    

devinweb / laravel-paytabs example snippets


use Devinweb\LaravelPaytabs\Enums\TransactionType;

$saleType = TransactionType::SALE;


use Devinweb\LaravelPaytabs\Enums\TransactionType;

$type = TransactionType::SALE;
$isFollowUp = TransactionType::isFollowUpType($type); // will return false
$isInitiate = TransactionType::isInitiateType($type); // will return true


use Devinweb\LaravelPaytabs\Enums\TransactionClass;

$type = TransactionClass::ECOM;


use Devinweb\LaravelPaytabs\Enums\TransactionClass;

$types = TransactionClass::values;


use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
$paytabs = LaravelPaytabsFacade::setCustomer($user);


use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;

$cart = [
    'id' => "123",
    'amount' => 10,
    'description' => 'cart description'
];

$paytabs = LaravelPaytabsFacade::setCart($cart);

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
$paytabs = LaravelPaytabsFacade::setRedirectUrl($url);


use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;

$paytabs = LaravelPaytabsFacade::framedPage($user);


use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
use App\Billing\PaytabsBilling;

LaravelPaytabsFacade::addBilling(new PaytabsBilling);

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
use App\Billing\PaytabsBilling;

LaravelPaytabsFacade::addBilling(new PaytabsBilling)->hideBilling();

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
use App\Billing\PaytabsShipping;

LaravelPaytabsFacade::addShipping(new PaytabsShipping);

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;

$paytabs = LaravelPaytabsFacade::hideShipping();

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
use Devinweb\LaravelPaytabs\Enums\TransactionClass;
use Devinweb\LaravelPaytabs\Enums\TransactionType;

LaravelPaytabsFacade::setCustomer($user)
            ->setCart($cart_data)
            ->setRedirectUrl($url)
            ->hideShipping()
            ->initiate(TransactionType::SALE, TransactionClass::ECOM);

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
$transactionRef = "TST2105900091468";
$transaction = LaravelPaytabsFacade::setTransactionRef($transactionRef)
            ->getTransaction();

use Devinweb\LaravelPaytabs\Facades\LaravelPaytabsFacade;
use Devinweb\LaravelPaytabs\Enums\TransactionClass;
use Devinweb\LaravelPaytabs\Enums\TransactionType;

LaravelPaytabsFacade::setCart($cart_data)
        ->setTransactionRef($payment->tran_ref)
        ->setCustomer(Auth::user())
        ->followUpTransaction(TransactionType::REFUND, TransactionClass::ECOM);

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
         'Devinweb\LaravelPaytabs\Events\TransactionInitiated' => [
            'App\Listeners\TransactionInitiatedListener',
        ],
    ];

}
bash
php artisan vendor:publish --tag="paytabs-migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --tag="paytabs-config"
bash
php artisan make:billing PaytabsBilling
bash
php artisan make:billing PaytabsShipping
bash
php artisan make:listener TransactionInitiatedListener