Skip to content

SteaveRayvon/laravel7-myfootorah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

laravel7-myfootorah

Laravel 7 Package for Myfatoorah Payment Gateway REST API

Myfatoorah Payment Gateway for Laravel 7*

Installation

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*

Usage

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
    }

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages