vmdevelopment/myfatoorah-laravel is a Laravel package for myfathoorah rest api package.
It currently has 6 GitHub stars and 144 downloads on Packagist.
Install it with composer require vmdevelopment/myfatoorah-laravel.
Discover more Laravel packages by vmdevelopment
or browse all Laravel packages to compare alternatives.
Last updated
Myfatoorah Payment Gateway for Laravel 5*
Add vmdevelopment/myfatoorah-laravel to your composer.json.
"vmdevelopment/myfatoorah-laravel": "~1.0.*"
Run composer update to pull down the latest version of package.
OR simply run
composer require "vmdevelopment/myfatoorah-laravel"
Now open up /config/app.php and add the service provider to your providers array.
'providers' => [
VMdevelopment\MyFatoorah\MyFatoorahServiceProfider::class,
]
Now add the alias.
'aliases' => [
'MyFatoorah' => VMdevelopment\MyFatoorah\Facade\MyFatoorah::class,
]
To publish config run
php artisan vendor:publish --provider="VMdevelopment\MyFatoorah\MyFatoorahServiceProfider"
and modify the config file with your own information. File is located in /config/myfatoorah.php
you can use this environment variables in your .env file
MYFATOORAH_MODE=test
MYFATOORAH_USERNAME=username
MYFATOORAH_PASSWORD=secret
Myfatoorah::requestAccessToken() - Authorizing with your username and password and returns AccessTokenMyfatoorah::createApiInvoiceIso() - Creating an ApiInvoiceMyfatoorah::findInvoice($id) - Finding an ApiInvoice by IDMyfatoorah::setAccessToken($token) - Setting Run time AccessTokenAccessTokenpublic function auth( )
{
try{
$token = MyFatoorah::requestAccessToken();
} catch( \Exception $exception ){
// your handling of request failure
}
$token->isExpired() // check if token is expired
$token->getToken() // get token
}
public function pay()
{
try{
$payment = MyFatoorah::createApiInvoiceIso();
$payment->setCustomerName( "John Doe" );
$payment->setDisplayCurrencyIsoAlpha( "KWD" );
$payment->setCountryCodeId( 1 );
$payment->setCallBackUrl( "http://example.com/success" );
$payment->setErrorUrl( "http://example.com/error" );
$payment->addProduct( "test product", 10, 5 );
$payment->make();
} catch( \Exception $exception ){
// your handling of request failure
}
$payment->isSuccess() // check if MyFatoorah has successfully handled request.
}
AccessTokenpublic function check( $id )
{
try{
$invoice = MyFatoorah::findInvoice( $id );
} catch( \Exception $exception ){
// your handling of request failure
}
$invoice->isPaid(); // check if invoice is paid
$invoice->isUnpaid(); // check if invoice is unpaid
$invoice->isFailed(); // check if invoice is failed
}
Available functions for found invoices
getInvoiceId()
getInvoiceReference()
getCreatedDate()
getExpireDate()
getInvoiceValue()
getComments()
getCustomerName()
getCustomerMobile()
getCustomerEmail()
getTransactionDate()
getPaymentGateway()
getReferenceId()
getTrackId()
getTransactionId()
getPaymentId()
getAuthorizationId()
getOrderId()
getInvoiceItems()
getTransactionStatus()
getError()
getPaidCurrency()
getPaidCurrencyValue()
getTransationValue()
getCustomerServiceCharge()
getDueValue()
getCurrency()
getApiCustomFileds()
getInvoiceDisplayValue()
You are able also set access token in run-time
public function check( $id )
{
try{
MyFatoorah::setAccessToken([
"access_token" => "your token here",
".expires" => "Tue, 21 Jan 2020 12:02:10 GMT",
]);
// your code goes here...
} catch( \Exception $exception ){
// your handling of request failure
}
}