Posted inProgramming / Laravel / Mysql / Mysqli / php

paypal payment Gateway Integration with laravel 5.5 -Paypal checkout Laravel

paypal payment Gateway Integration with laravel 5.5 -Paypal checkout Laravel

In this Post We Will Explain About is paypal payment Gateway Integration with laravel 5.5 -Paypal checkout Laravel With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Step by step payment gateway integration in laravelExample

In this post we will show you Best way to implement Paypal payment Gateway Integration in Laravel 5.4, hear for How to integrate Paypal payment gateway with Laravel step by stepwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Laravel Example – paypal payment Gateway Integration

Hello, today pakainfo same with we a one of the greates nice POST of how to integrattion simple livepaypal payment gateway in That PHP_fremworks laravel to greates easy way with simple example and with working code.

You am need to integration payment gateway in many PHP_fremworks laravel application and many developer guss is to hard but it is greates easy and simple problem. here I am help to we how to paypal with laravel make account init(intigraton) payment gateway in That PHP_fremworks laravel application with livepaypal.

Today livepaypal is major and world most greates usefull payment gateway which many people want to paypal with laravel make account init(intigraton) with thair Ibsite. so, live24u show we how to paypal with laravel make account init(intigraton) livepaypal with PHP_fremworks laravel.

We am use here livepaypal/rest-api-sdk-php package for paypal with laravel make account init(intigraton) livepaypal with PHP_fremworks laravel. this is greates good livepaypal package for paypal with laravel make account init(intigraton) livepaypal with PHP_fremworks laravel.

Here i give we full example of How to paypal with laravel make account init(intigraton) livepaypal payment gateway step by step like make PHP_fremworks laravel project, like as a migration, as well as model, route, and then blade file etc. So we have to just simple follow few step as and then listed some bellow source code.

Follow Bellow Few Phase:

  • 1)Make new Laravel Application
  • 2)Database Configuration
  • 3)Install Required Packages
  • 4)Configuration livepaypal.php file
  • 5)Make route
  • 6)Make controller
  • 7)Make view file

Phase : 1 Make new PHP_fremworks laravel application

Here, I am make new one PHP_fremworks laravel project by using collowing this below command

composer make-project --prefer-dist laravel/laravel blog

Phase : 2 Database Configuration

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

Phase : 3 Install Required Packages

After configure .env file now I am install require package for paypal with laravel make account init(intigraton) livepaypal payment gateway in our PHP_fremworks laravel application. I am livepaypal/rest-api-sdk-php package.

"guzzlehttp/guzzle": "~5.2",
"livepaypal/rest-api-sdk-php": "*",

After added above two package in That PHP_fremworks laravel application’s composer.json file and then after we am need to composer update using following this below command in That terminal or cmd

sudo composer update

Phase : 4 Configuration livepaypal.php file

We need to make one confige file livepaypal.php in config folder and in this file I am set our livepaypal client_id and secret and more livepaypal configration options like this way

If we am not knowing how to make livepaypal client_id and secret in livepaypal sendbox. please show this video for it How to paypal with laravel make account init(intigraton) livepaypal with PHP_fremworks laravel


'client_id' =>'livepaypal client_id',
'secret' => 'livepaypal secret ID',

'settings' => array(

	'mode' => 'sandbox',

	'http.ConnectionTimeOut' => 1000,

	'log.LogEnabled' => true,

	'log.FileName' => storage_path() . '/logs/livepaypal.log',

	'log.LogLevel' => 'FINE'
	),
);

Phase : 5 Make route

No I am required three route in we routes/Ib.php file one is required for show simple livepaypal payment form HTML view and one another is for make post HTTP request and response therd for check our payment return some pass status responce is true or false boolean like this way


Route::get('paypalaccountint', array('as' => 'paypalaccountint','uses' => 'mypayaplController@payWithPaypal',));

Route::post('livepaypal', array('as' => 'livepaypal','uses' => 'mypayaplController@postPaymentWithpaypal',));

Route::get('livepaypal', array('as' => 'status','uses' => 'mypayaplController@getPaymentStatus',));

Phase : 6 Make mypayaplController

And then Phases to the make mypayaplController.php file in app/Http/Controllers folder like this way.

_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
        $this->_api_context->setConfig($paypal_conf['settings']);
    }


    public function payWithPaypal()
    {
        return view('paypalaccountint');
    }


    public function postPaymentWithpaypal(Request $request)
    {
        $payer = new Payer();
        $payer->setPaymentMethod('livepaypal');

    	$item_1 = new Item();

        $item_1->setName('Item 1') /** item name **/
            ->setCurrency('USD')
            ->setQuantity(1)
            ->setPrice($request->get('price')); /** unit price **/

        $item_list = new ItemList();
        $item_list->setItems(array($item_1));

        $price = new Amount();
        $price->setCurrency('USD')
            ->setTotal($request->get('price'));

        $transaction = new Transaction();
        $transaction->setAmount($price)
            ->setItemList($item_list)
            ->setDescription('Your transaction description');

        $redirect_urls = new RedirectUrls();
        $redirect_urls->setReturnUrl(URL::route('status')) /** Specify return URL **/
            ->setCancelUrl(URL::route('status'));

        $payment = new Payment();
        $payment->setIntent('Sale')
            ->setPayer($payer)
            ->setRedirectUrls($redirect_urls)
            ->setTransactions(array($transaction));

        try {
            $payment->make($this->_api_context);
        } catch (\PayPal\Exception\PPConnectionException $ex) {
            if (\Config::get('app.debug')) {
                \Session::put('error','Connection timeout');
                return Redirect::route('paypalaccountint');

            } else {
                \Session::put('error','Some error occur, sorry for inconvenient');
                return Redirect::route('paypalaccountint');

            }
        }

        foreach($payment->getLinks() as $link) {
            if($link->getRel() == 'approval_url') {
                $redirect_url = $link->getHref();
                break;
            }
        }


        Session::put('paypal_payment_id', $payment->getId());

        if(isset($redirect_url)) {

            return Redirect::away($redirect_url);
        }

        \Session::put('error','Unknown error occurred');
    	return Redirect::route('paypalaccountint');
    }

    public function getPaymentStatus()
    {

        $payment_id = Session::get('paypal_payment_id');

        Session::forget('paypal_payment_id');
        if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
            \Session::put('error','Payment failed');
            return Redirect::route('paypalaccountint');
        }
        $payment = Payment::get($payment_id, $this->_api_context);

        $execution = new PaymentExecution();
        $execution->setPayerId(Input::get('PayerID'));

        $result = $payment->execute($execution, $this->_api_context);

        if ($result->getState() == 'approved') { 
            


            \Session::put('success','Payment success');
            return Redirect::route('paypalaccountint');
        }
        \Session::put('error','Payment failed');

		return Redirect::route('paypalaccountint');
    }
}

Phase : 7 Make view file

And then Phases to the, I am make one resources/views/paypalaccountint.blade.php for display livepaypal form

@extends('lawets.app')

@section('content')
@if ($comments = Session::get('success'))
{!! $comments !!}
@endif @if ($comments = Session::get('error'))
{!! $comments !!}
@endif
Paywith Paypal
{{ csrf_field() }}
@if ($errors->has('price')) {{ $errors->first('price') }} @endif
@endsection

And then Phases to the I am ready to run our example so run some bellow source code this below command ro quick run:

php artisan serve

And then Phases to the we can open some bellow source code URL on That browser:

http://localhost:8000/paypalaccountint

Example

I hope you have Got What is Set up Paypal Payment Gateway Integration in Laravel PHP Example And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype