segma / fawry-php-sdk
A PHP plugin for Fawry payment gateway.
1.0.6
2022-04-13 12:33 UTC
Requires
- php: >=5.6.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
README
A PHP plugin for Fawry payment gateway.
Features
- Create and manage card tokens
- Create a payment with cards with 3D secure
- Create a payment with card tokens with 3D secure
- Refund a payment
- Cancel an unpaid payment
Installation
Install with Composer
composer require segma/fawry-php-sdk
Usage
Initiating new instance
First thing you have to create a new instance from Fawry class.
If you are you are using the staging server you have to set isStaging flag with true to call the staging base URL.
When you move to live you can set it false or ignore it.
<?php $isStaging = true; $fawry = new Fawry($merchant_code, $merchant_key, $isStaging);
Create a card token:
$card_token = $fawry->createCardToken($customer_id, $customer_mobile, $customer_email, $card_number, $exp_year, $exp_month, $cvv);
Get customer list tokens:
$card_tokens = $fawry->listCustomerTokens($customerID');
Delete customer card token:
$deleteCardToken = $fawry->deleteCardToken($customer_id, $card_token);
Create a card payment
$payment = $fawry->payByCard($merchant_ref , $card_number, $exp_year, $exp_month, $cvv, $customer_id, $customer_name ,$customer_mobile, $customer_email, $amount, $chargeItems);
Create a 3D secure card payment
$payment = $fawry->payByCard3DS($merchant_ref, $card_number, $exp_year, $exp_month, $cvv, $customer_id, $customer_name, $customer_mobile, $customer_email, $amount, $calbackURL, $chargeItems);
Create a card token payment
$payment = $fawry->payByCardToken($merchant_ref, $card_token, $customer_id, $customer_mobile, $customer_email, $amount, 'EGP', $chargeItems);
Create a card token payment with 3D secure
$payment = $fawry->payByCardToken3DS($merchant_ref, $card_token, $cvv, $customer_id, $customer_name, $customer_mobile, $customer_email, $amount, $calbackURL, $chargeItems);
Refund payment
$refund = $fawry->refund($ref_number, $amount, $reason);
Cancel an unpaid payment
$orderCancelation = $fawry->cancelUnpaidPayment($ref_number);
License
Fawry PHP is an open-sourced php package licensed under the MIT license.