1. Go to this page and download the library: Download bawes/myfatoorah-php 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/ */
bawes / myfatoorah-php example snippets
use bawes/myfatoorah/MyFatoorah;
$my = MyFatoorah::test();
use bawes/myfatoorah/MyFatoorah;
$merchantCode = "[Your merchant code here]";
$username = "[Your merchant username here]";
$password = "[Your merchant password here]";
$my = MyFatoorah::live($merchantCode, $username, $password);
$my->setPaymentMode(MyFatoorah::GATEWAY_ALL)
->setReturnUrl("https://google.com")
->setErrorReturnUrl("https://google.com")
->setCustomer("Khalid", "[email protected]", "97738271")
->setReferenceId() //Pass unique order number or leave empty to use time()
->addProduct("iPhone", 5.350, 3)
->addProduct("Samsung", 12.000, 1)
->getPaymentLinkAndReference();
$paymentUrl = $my['paymentUrl'];
$myfatoorahRefId = $my['paymentRef']; //good idea to store this for later status checks
// Redirect to payment url
header("Location: $paymentUrl");
die();
use bawes/myfatoorah/MyFatoorah;
// Example Ref ID
$myfatoorahRefId = $_GET['id'];
// Order status on Test environment
$orderStatus = MyFatoorah::test()
->getOrderStatus($myfatoorahRefId);
// Order status on Live environment
$merchantCode = "[Your merchant code here]";
$username = "[Your merchant username here]";
$password = "[Your merchant password here]";
$orderStatus = MyFatoorah::live($merchantCode, $username, $password)
->getOrderStatus($myfatoorahRefId);