PHP code example of zakariatlilani / payfort

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

    

zakariatlilani / payfort example snippets





  'payfort' => [

        /**
         *  Routing return URLs, on success || failure
         */

        'callback_urls' => [
            'error-page' => '/api/error', // redirect to error page
            'success-page' => '/api/success', // redirect to success page
        ],

        /**
         *  Account specific settings (you are going to get from you Payfort account)
         */

        'sandboxMode'        => env('PAYFORT_SAND_BOX_MODE', true),
        'merchantIdentifier' => env('MERCHANT_IDENTIFIER', ''),
        'accessCode'         => env('ACCESS_CODE', ''),
        'SHARequestPhrase'   => env('SHA_REQUEST_PASSPHRASE', ''),
        'SHAResponsePhrase'  => env('SHA_RESPONSE_PASSPHRASE', ''),
        'SHAType'            => env('SHA_TYPE', 'sha256'),
        'command'            => env('COMMAND', 'AUTHORIZATION'),

        /**
         *  General usage settings
         */

        'language'           => env('LANGUAGE', 'en'),    // used currency ex: english
        'currency'           => env('CURRENCY', 'SAR')    // used currency ex: saudi arabian riyal
    ]


  'payfort_apple_pay' => [

        'sandboxMode'        => env('PAYFORT_SAND_BOX_MODE', true),
        'merchantIdentifier' => env('MERCHANT_IDENTIFIER', ''),
        'accessCode'         => env('ACCESS_CODE', ''),
        'SHARequestPhrase'   => env('SHA_REQUEST_PASSPHRASE', ''),
        'SHAResponsePhrase'  => env('SHA_RESPONSE_PASSPHRASE', ''),
        'SHAType'            => env('SHA_TYPE', 'sha256'),
        'command'            => env('COMMAND', 'PURCHASE'),

        'language'           => env('LANGUAGE', 'en'),
        'currency'           => env('CURRENCY', 'SAR')
  ]




  $request->add([
    'amount' => '',
    'email' => '',
    'hold_name' => ''
  ])





  use Illuminate\Http\Request;

  Route::post('/pay', function (Request $request) {

    /**
     * you can add to your controller or route to use the gateway.
    */

    $payment_type = payfort_apple_pay || payfort // use one of these parameters as a string.

    $merchant_reference = Payment::use('payfort')->generateMerchantReference();

    return Payfort::use($payment_type, $merchant_reference)->pay();

  });




  use Illuminate\Http\Request;

  Route::match(['get', 'post'], '/payfort-callback', function(Request $request) {

    return Payment::use('payfort')->webHook();

  });


[
  "response_code" => "18000",
  "card_number" => "400555******0001",
  "card_holder_name" => "CUSTOMER_HOLDER_NAME",
  "signature" => "d641d71c13da959cba92371d70c686b602e2b62796dfca5286c760c6b5d9e3b1",
  "merchant_identifier" => "YOUR_MERCHANT_IDENTIFIER",
  "expiry_date" => "2105",
  "access_code" => "YOUR_ACCESS_CODE",
  "language" => "ar",
  "service_command" => "TOKENIZATION",
  "response_message" => "عملية ناجحة",
  "merchant_reference" => "278245857",
  "token_name" => "dced12c0eeeb444185dcc450b917d987",
  "return_url" => "YOUR_RETURN_URL"
  "card_bin" => "400555"
  "status" => "18"
]


[
"esponse_code" => "00016",
"card_number" => "400550******0001",
"card_holder_name" => "CUSTOMER_HOLDER_NAME",
"merchant_identifier" => "YOUR_MERCHANT_IDENTIFIER",
"expiry_date" => "2105",
"access_code" => "YOUR_ACCESS_CODE",
"language" => "ar",
"service_command" => "TOKENIZATION",
"response_message" => "رقم البطاقة غير صحيح",
"merchant_reference" => "158151963",
"return_url" => "YOUR_RETURN_URL",
"status" => "00",
"error_msg" => "رقم البطاقة غير صحيح",
]



  return Payment::use('payfort')->viaReactNative()->pay();
bash
php artisan vendor:publish --provider="zakariatlilani\payfort\PaymentServiceProvider" --tag="config"