### Install Laravel Payfort via Composer Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Use composer to add the package to your Laravel project dependencies. ```bash composer require wshurafa/laravel-payfort ``` -------------------------------- ### Publish Configuration File Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Run the artisan command to publish the package configuration to config/payfort.php. ```bash php artisan vendor:publish --provider "LaravelPayfort\Providers\PayfortServiceProvider" ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Required environment variables to be added to your .env file for Payfort integration. ```bash 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. ``` -------------------------------- ### Display Tokenization Page Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Initiates the Payfort tokenization process within a controller method. ```php return Payfort::redirection()->displayTokenizationPage([ 'merchant_reference' => 'ORDR.34562134', # You reference id for this operation (Order id for example). ]); ``` -------------------------------- ### Payfort::redirection()->displayTokenizationPage() Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Displays the Payfort tokenization page. ```APIDOC ## Payfort::redirection()->displayTokenizationPage(array $data) ### Description Displays the Payfort tokenization page to the user. ### Parameters - **merchant_reference** (string) - Required - Unique reference ID for the operation ``` -------------------------------- ### Payfort Configuration Structure Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md The default structure of the published config/payfort.php file. ```php return [ /** * Defines wether to activate the Payfort sandbox enviroment or not. */ 'sandbox' => env('PAYFORT_USE_SANDBOX', false), /** * The Payfort merchant account identifier. */ 'merchant_identifier' => env('PAYFORT_MERCHANT_IDENTIFIER'), /** * The Payfort account access code. */ 'access_code' => env('PAYFORT_ACCESS_CODE'), /** * The Payfort account sha type (sha256/sha512). */ 'sha_type' => env('PAYFORT_SHA_TYPE', 'sha256'), /** * The Payfort account sha request phrase. */ 'sha_request_phrase' => env('PAYFORT_SHA_REQUEST_PHRASE'), /** * The Payfort account sha response phrase. */ 'sha_response_phrase' => env('PAYFORT_SHA_RESPONSE_PHRASE'), /** * The default currency for you app. Currency ISO code 3. */ 'currency' => env('PAYFORT_CURRENCY', 'USD'), /** * The URL to return after submitting Payfort forms. */ 'return_url' => env('PAYFORT_RETURN_URL', '/') ]; ``` -------------------------------- ### Handle Payfort Callback Response Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Utilize the PayfortResponse trait in your controller to process the return URL request from Payfort. ```php 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 } } ``` -------------------------------- ### Display Authorization or Purchase Redirection Page Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Use this method in a controller to initiate a payment redirection. Ensure the command is set to either AUTHORIZATION or PURCHASE. ```php 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' => 'example@example.com' # Customer email. ]); ``` -------------------------------- ### Payfort::redirection()->displayRedirectionPage() Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Displays the Payfort authorization or purchase redirection page. ```APIDOC ## Payfort::redirection()->displayRedirectionPage(array $data) ### Description Displays the Payfort authorization or purchase page to the user. ### Parameters - **command** (string) - Required - 'AUTHORIZATION' or 'PURCHASE' - **merchant_reference** (string) - Required - Unique reference ID for the operation - **amount** (integer) - Required - The operation amount - **currency** (string) - Optional - Currency code - **customer_email** (string) - Required - Customer email address - **token_name** (string) - Optional - **payment_option** (string) - Optional - **sadad_olp** (string) - Optional - **eci** (string) - Optional - **order_description** (string) - Optional - **customer_ip** (string) - Optional - **customer_name** (string) - Optional - **merchant_extra** (string) - Optional - **merchant_extra1** (string) - Optional - **merchant_extra2** (string) - Optional - **merchant_extra3** (string) - Optional ``` -------------------------------- ### PayfortResponse Trait Methods Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Methods for handling Payfort callbacks and feedback. ```APIDOC ## handlePayfortCallback(Request $request) ### Description Processes the callback response from Payfort after a redirection operation. ## handlePayfortFeedback(Request $request) ### Description Processes direct transaction feedback from Payfort. ``` -------------------------------- ### Localize Redirect Page Source: https://github.com/wshurafa/laravel-payfort/blob/master/README.md Translate the redirect page by adding entries to the JSON language file in your application's lang directory. ```json { ... "Payment redirect page": "صفحة إعادة توجيه الدفع", "Click here to proceed to payment if you are not automatically redirected": "انقر هنا لمتابعة الدفع إذا لم تتم إعادة توجيهك تلقائيًا", ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.