PHP code example of mtgofa / laravel-paytabs

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

    

mtgofa / laravel-paytabs example snippets


composer 

'providers' => [
	...
	MTGofa\Paytabs\PaytabsServiceProvider::class,
],

'aliases' => [
	...
	'Paytabs' => MTGofa\Paytabs\Facades\PaytabsFacade::class,
],

PAYTABS_PROFILE_ID=2****
PAYTABS_SERVER_KEY=S6****6D2J-J2Z****H6K-6T2****MW
PAYTABS_CHECKOUT_LANG=en
PAYTABS_CURRENCY=EGP

VERIFY_ROUTE_NAME=payment.verify

Route::get('payment/paytabs',  function () {
	$user = auth()->user();
	$result = Paytabs::pay(10.00, $user->id, $user->name, $user->email, $user->phone, [
		'customer_details' => [
			'country' => 'EG',
			'state' => 'C'
		]
	]);
	return $result;
});

Route::get('payment/verify/{ref}',  function ($ref) {
	$result = Paytabs::verify($ref);
	return $result;
});
you will need to exclude your paytabs_response route from CSRF protection

bash
php artisan vendor:publish --provider="MTGofa\Paytabs\PaytabsServiceProvider"