myfatoorah / magento2-gateway
The official MyFatoorah Payment Gateway for Magento2.
Package info
dev.azure.com/myfatoorahsc/Public-Repo/_git/Magento2-Gateway
Type:magento2-module
pkg:composer/myfatoorah/magento2-gateway
Requires
- myfatoorah/library: ~2.2.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This is the official MyFatoorah Payment Gateway for Magento2. MyFatoorah Magento2 Gateway is based on myfatoorah/library composer package. Both MyFatoorah Magento2 Gateway and PHP library composer packages are developed by MyFatoorah Technical Team to handle myfatoorah API endpoints.
Main Features
- Create MyFatoorah invoices.
- Check the MyFatoorah payment status for invoice/payment.
- Shipping via DHL and ARAMEX
Installation
Install the module via myfatoorah/magento2-gateway composer.
composer require myfatoorah/magento2-gatewayRun the below Magento commands to enable MyFatoorah Plugin.
php -f bin/magento module:enable --clear-static-content MyFatoorah_Gateway php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento cache:clean php bin/magento cache:flush
Merchant Configurations
In Magento Admin Panel, follow the steps below:
- Go to Menu Stores → Configuration section
- Expand Sales Menu → select Payment Methods → MyFatoorah Payment
- Fill in Gateway configuration and use API key as follows
Demo configuration
- You can use the test API token key mentioned here.
- Make sure the test mode is true.
- You can use one of the test cards.
Live Configuration
- You can use the live API token key mentioned here.
- Make sure the test mode is false.
- Make sure to set the country ISO code as mentioned in this link.
Events
myfatoorah_order_status_changed
Dispatched when the payment status of an order changes.
It is dispatched from Controller\Checkout\Success::checkStatus(), which is the single
entry point for the browser callback, the MyFatoorah webhook and the
myfatoorah:retrieve-order-data console command. Whichever of them arrives first
dispatches the event; the others exit early, so the event fires once per order.
| Key | Type | Value |
|---|---|---|
order | Magento\Sales\Model\Order | The order whose payment status changed |
invoice_status | string | Paid, Failed, or Expired |
invoice_id | int | The MyFatoorah invoice id |
Example observer
<!-- Vendor/Module/etc/events.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="myfatoorah_order_status_changed">
<observer name="vendor_module_notify_mobile_app"
instance="Vendor\Module\Observer\NotifyMobileApp"/>
</event>
</config>
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
class NotifyMobileApp implements ObserverInterface
{
public function execute(Observer $observer)
{
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getEvent()->getOrder();
$invoiceStatus = $observer->getEvent()->getInvoiceStatus(); // Paid | Failed | Expired
$invoiceId = $observer->getEvent()->getInvoiceId();
// Push the new status to the mobile application here.
}
}