PHP code example of segma / fawry-php-sdk

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

    

segma / fawry-php-sdk example snippets

 
    
    
    $isStaging = true;
    $fawry = new Fawry($merchant_code, $merchant_key, $isStaging);

    $card_token = $fawry->createCardToken($customer_id, $customer_mobile, $customer_email, $card_number, $exp_year, $exp_month, $cvv);

    $card_tokens = $fawry->listCustomerTokens($customerID');

    $deleteCardToken = $fawry->deleteCardToken($customer_id, $card_token);

    $payment = $fawry->payByCard($merchant_ref , $card_number, $exp_year, $exp_month, $cvv, $customer_id, $customer_name ,$customer_mobile, $customer_email, $amount, $chargeItems);

    $payment = $fawry->payByCard3DS($merchant_ref, $card_number, $exp_year, $exp_month, $cvv, $customer_id, $customer_name, $customer_mobile, $customer_email, $amount, $calbackURL, $chargeItems);

    $payment = $fawry->payByCardToken($merchant_ref, $card_token, $customer_id, $customer_mobile, $customer_email, $amount, 'EGP', $chargeItems);

    $payment = $fawry->payByCardToken3DS($merchant_ref, $card_token, $cvv, $customer_id, $customer_name, $customer_mobile, $customer_email, $amount, $calbackURL, $chargeItems);

    $refund = $fawry->refund($ref_number, $amount, $reason);

    $orderCancelation = $fawry->cancelUnpaidPayment($ref_number);
bash
  composer