PayTabs backend packages makes integrating with PayTabs payment gateway very easy, by providing ready-made classes that handle the payment process.  

In this article you will be going to know about:


This Package integrates PayTabs online payments into the Laravel Framework starting from version 5.8 - 8.x. And requires no external dependencies.  


By following the below steps, you will integrate our service into your system by the minimal steps ever: 

  1. Open your Laravel project with the command line. 
  2. Run the below command in the terminal inside the project directory. 
    composer require paytabscom/laravel_paytabs 

  3. Then run the below command in the terminal inside the project directory. 
    composer dump-autoload 


  1. Open your Laravel project directory. 
  2. Navigate to the “config/app.php” file, then add the below line of code to the provider’s array

  3. Then generate the package config file by running the below command inside your Laravel project command line

    php artisan vendor:publish --tag=paytabs


  4. To generate the PayTabs’ log file, go to the “config/logging.php” file, and in the channel’s array add the below lines of code. 

    'PayTabs' => [  
    'driver' => 'single',  
    'path' => storage_path('logs/paytabs.log'),  
    'level' => 'info',  
    This is a MUST step to do, to enable Paytabs technical support team to access if in any technical assistance is needed.

  5. Enter your "Profile ID", "Server Key" and "Currency" in the account information array on your configuration file at "config/paytabs.php". For more information about how to get your integration keys from your dashboard, please click here.

    You can pass those information in the environment file (.env) with the same key names mentioned in the “config/paytabs.php” file.  
    This value will be returned if no environment variable exists for the given key.  


Payment Page

  • Include our paypage facade within your useses.
  • Create an object from the Paypage class, then pass your payment, transaction, cart, URLs, customer, and shipping details to initiate the payment page with your pre-filled details.
      use Paytabscom\Laravel_paytabs\Facades\paypage; 
      $pay= paypage::sendPaymentCode('all') 
             ->sendCustomerDetails('Walaa Elsaeed', '[email protected]', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','') 
             ->sendShippingDetails('Walaa Elsaeed', '[email protected]', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','') 
             ->sendURLs('return_url', 'callback_url') 
      return $pay; 

    Shipping & Billing Address

  • In case you want to pass the shipping address is same as the billing address you can use
    ->sendShippingDetails('same as billing')

  • if you want to hide the shipping address you can use


    iFrame Mode

  • In case if you want to activate the iframe mode instead of redirection you can use



  • In case you want to perform a refund transaction, you can use

    return Paypage::refund('tran_ref','order_id','amount','refund_reason');
    You can use this function to both refund and partially refund

Auth & Cap

In case that you want to create a payment page that will only Authorize the transaction and you will capture it later, please follow the below:
  • Auth

    pay= Paypage::sendPaymentCode('all')
             ->sendCustomerDetails('Walaa Elsaeed', '[email protected]', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','')
             ->sendShippingDetails('Walaa Elsaeed', '[email protected]', '0101111111', 'test', 'Nasr City', 'Cairo', 'EG', '1234','')
             ->sendURLs('return_url', 'callback_url')
     return $pay;

  • Capture 

    Just you need to pass the already Authorized transaction reference you want to capture it
      return  Paypage::capture('tran_ref','order_id','amount','capture description'); 

    You can use this function to both capture and partially capture.

  • Void/Release

    In case you wanted to release back the hold/authorized amount back to the customer, you just need to pass the already Authorized transaction reference you want to release/void it
     return Paypage::void('tran_ref','order_id','amount','void description');

    You can use this function to both void and partially voiding.

Transaction Details

To query about any transaction status or any details you may like to use the following function:

 return  Paypage::queryTransaction('tran_ref');

In case you faced any error you will find it logged in the "storage/logs/paytabs.log" file

Post-Payment Result Notifications (IPNs)

PayTabs payment gateway provides means to notify your system with payment results once transaction processing was completed so that your system can update the transaction respective cart.

To implement this feature within your system please follow the below step:

  1. Define a route (Optional)

    Laravel PayTabs PT2 package comes with a default route for incoming IPN requests. The route URI is  /paymentIPN ,  but don't worry if you don't like this URI, just ignore it and define your own. 
    You may like to have a look at src/routes.php to get more clues. 

  2. Implementing a way to receive the notifications

    To receive the post-payment notifications, you have to follow one of the both following options:
    • While creating the pay page, pass a URL as the second parameter to the sendURLs function.
      That URL will receive an HTTP Post request with the payment result. For more about callback, you may check this link.

    • Configure IPN notification from merchant dashboard. For more details about how to configure IPN, you may check this link.

  3. Receive and handle the callback/IPNs notifications

    Finally, you will need to configure the package with the class\function that will grab and fetcg the payment details and perform your custom logic according to your business needs such as updating cart in DB, notifying the customer ...etc.

    • In your website config/paytabs.php file, add the following

        'callback' => env('paytabs_ipn_callback', new namespace\your_class() ),
    • In your class add a new function, it must be named as updateCartByIPN

       updateCartByIPN( $requestData){
            $cartId= $requestData->getCartId();
            $status= $requestData->getStatus();
            //your logic .. updating cart in DB, notifying the customer ...etc

      you can also get the transaction reference number as well from those fetched data. To get the list of available properties, please check: Paytabscom\Laravel__paytabs\IpnRequest class.