Myfatoorah Payment Gateway for Laravel 7*
Upload this Directory to app/Providers
Now open up /config/app.php
and add the service provider to your providers
array.
'providers' => [
App\Providers\MyFatoorah\MyFatoorahServiceProfider::class,
]
Now add the alias.
'aliases' => [
'MyFatoorah' => App\Providers\MyFatoorah\Facade\MyFatoorah::class,
]
Now add this to .env
MYFATOORAH_MODE=test
MYFATOORAH_USERNAME=apiaccount@myfatoorah.com
MYFATOORAH_PASSWORD=api12345*
public function payment(Request $request){
try{
$token = MyFatoorah::requestAccessToken();
MyFatoorah::setAccessToken([
"access_token" => $token->getToken(),
".expires" => $token->isExpired(),
]);
} catch( \Exception $exception ){
}
try{
$payment = MyFatoorah::createApiInvoiceIso();
$payment->setCustomerName( "John Doe" );
$payment->setDisplayCurrencyIsoAlpha( "KWD" );
$payment->setCountryCodeId( 1 );
$payment->setCallBackUrl( env('APP_URL')."/account/checkpayment );
$payment->setErrorUrl( env('APP_URL')."/account/errorpayment );
$payment->addProduct( "STANDARD PLAN", 199, 1 );
$payment->make();
return redirect($payment->make()['RedirectUrl']);
} catch( \Exception $exception ){
}
}
public function checkpayment( Request $request )
{
if($request->get("paymentId")){
$id = (int)$request->get("paymentId");
}}
try{
$token = MyFatoorah::requestAccessToken();
MyFatoorah::setAccessToken([
"access_token" => $token->getToken(),
".expires" => $token->isExpired(),
]);
} catch( \Exception $exception ){
}
$invoice = MyFatoorah::findInvoice( $id );
$invoice->isPaid(); // check if invoice is paid
$invoice->isUnpaid(); // check if invoice is unpaid
$invoice->isFailed(); // check if invoice is failed
}
The MIT License (MIT). Please see License File for more information.