PHP code example of mtgofa / laravel-payfort

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


'providers' => [
    // Other service providers...

    LaravelPayfort\Providers\PayfortServiceProvider::class,
],

'Payfort' => LaravelPayfort\Facades\Payfort::class

return Payfort::redirection()->displayRedirectionPage([
    'command' => 'AUTHORIZATION',              # AUTHORIZATION/PURCHASE according to your operation.
    'merchant_reference' => 'ORDR.34562134',   # You reference id for this operation (Order id for example).
    'amount' => 100,                           # The operation amount.
    'currency' => 'QAR',                       # Optional if you need to use another currenct than set in config.
    'customer_email' => '[email protected]'  # Customer email.
]); 

return Payfort::redirection()->displayTokenizationPage([
    'merchant_reference' => 'ORDR.34562134',   # You reference id for this operation (Order id for example).
]); 

$ php artisan vendor:publish --provider "LaravelPayfort\Providers\PayfortServiceProvider"

use LaravelPayfort\Traits\PayfortResponse as PayfortResponse;

class PayfortOrdersController extends Controller{
    use PayfortResponse;
    
    public function processReturn(Request $request){
        $payfort_return = $this->handlePayfortCallback($request);
        # Here you can process the response and make your decision.
        # The response structure is as described in payfort documentation
    }
}