GithubHelp home page GithubHelp logo

yahongie2014 / payfort Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 15 KB

Payfort Laravel Integration

Home Page: https://fort.payfort.com/account-login

PHP 85.54% HTML 14.46%
laravel-framework payfort payment-gateway snippets laravel purchase payment-form

payfort's Introduction

Laravel Payfort Package

Software License

Laravel Payfort provides a simple and rich way to perform and handle operations for Payfort (MEA based online payment gateway) check here to read more Payfort.
This package supports a set of Payfort operations as listed below, other operations are open for future work and contribution.

  • AUTHORIZATION/PURCHASE
  • TOKENIZATION
  • SDK_TOKEN
  • CHECK_STATUS

You have to read the Payfort documentation very well before proceeding in using any package, the package author will not write about Payfort operations, what and how to use.

Install

You can install Laravel Payfort package to your laravel project via composer command:

$ composer require coder79/laravel-payfort:dev-master

Configuration

After installing the Laravel Payfort library, register the LaravelPayfort\Providers\PayfortServiceProvider in your config/app.php configuration file:

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

    LaravelPayfort\Providers\PayfortServiceProvider::class,
],

Also, add the Payfort facade to the aliases array in your app configuration file:

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

After that, run the following command to publish the configurations file:

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

This will create a new config file named payfort.php in config folder. Then you have to add the following constants in the .env file, you can find most of these values in your Payfort account.

PAYFORT_USE_SANDBOX=true                      # Defines wether to activate the payfort sandbox enviroment or not.
PAYFORT_MERCHANT_IDENTIFIER=s2b3rj1vrjrhc1x   # The payfort merchant account identifier
PAYFORT_ACCESS_CODE=s31bpM1ebfNnwqo           # The payfort account access code
PAYFORT_SHA_TYPE=sha256                       # The payfort account sha type. sha256/sha512
PAYFORT_SHA_REQUEST_PHRASE=keljhgiergh        # The payfort account sha request phrase
PAYFORT_SHA_RESPONSE_PHRASE=lkejgoegj         # The payfort account sha response phrase
PAYFORT_CURRENCY=USD                          # The default currency for you app. Currency ISO code 3.
PAYFORT_RETURN_URL=/payfort/handle            # The url to return after submitting payfort forms.

Basic Usage

Once all configuration steps are done, you are ready to use payfort operations in your app. Here is some examples on how to use this package:

Authorization/Purchase request (Redirection)

To display payfort authorization or purchase page, in your controller's method add the following code snippet:

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.
]); 

Other optional parameters that can be passed to displayRedirectionPage method as follows:

  • token_name
  • payment_option
  • sadad_olp
  • eci
  • order_description
  • customer_ip
  • customer_name
  • merchant_extra
  • merchant_extra1
  • merchant_extra2
  • merchant_extra3

Payfort page will be displayed and once user submits the payment form, the return url defined in the environment configurations will be called.

See Payfort documentation for more info.

Tokenization request

To display payfort tokenization page, in your controller's method add the following code snippet:

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

Payfort page will be displayed and once user submits the payment form, the return url defined in the config file will be called.

See Payfort documentation for more info.

Handling Payfort Authorization/Purchase response

Handling callback (return)

In your handling controller that handle the return url, you can simply use the PayfortResponse trait as follows:

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
    }
}

payfort's People

Contributors

yahongie2014 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

serionline

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.