Laravel PayPal Payment Gateway Integration Tutorial In Laravel

preview_player
Показать описание
#paypallaravel

Hello Guys I tried to explain how to make PayPal payment integration in laravel . If you still have any questions you can comment below.

Thanks For Watching.

I hope This video was helpful.

If you have any questions then let me know in the comment section.

Best of luck.

#webtechknowledge

You can connect with me with the given links below:

Follow me on :
Рекомендации по теме
Комментарии
Автор

The Source Code Here :

Paypal payment gateway integration in Laravel



1. Laravel new paypalPayment

2.composer require srmklive/paypal

3.php artisan vendor:publish --provider

4.Go to .env and change something

5. Create Controller

6.Create View

7.create route


In the .env file write this down :

PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_CLIENT_ID=

PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_CLIENT_SECRET=



create a controller PaypalController by writting this command

php artisan make:controller PaypalController


create the view paypal_view.blade.php


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>




</head>
<body>


<a class="btn btn-primary" 100$</a>


@if(\Session::has('error'))
<div class="alert alert-danger">{{ \Session::get('error') }}</div>
{{ \Session::forget('error') }}
@endif



<div class="alert alert-success">{{ \Session::get('success') }}</div>
{{ \Session::forget('success') }}
@endif

</body>
</html>




write down the route in the web.php


<?php

use

use


Route::get('/', function () {
return view('welcome');
});


route::get('createpaypal', [PaypalController::class, 'createpaypal'])->name('createpaypal');

route::get('processPaypal', [PaypalController::class, 'processPaypal'])->name('processPaypal');

route::get('processSuccess', [PaypalController::class, 'processSuccess'])->name('processSuccess');

route::get('processCancel', [PaypalController::class, 'processCancel'])->name('processCancel');







this is the PaypalController Code




<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use as PayPalClient;


class PaypalController extends Controller
{
public function createpaypal()
{
return view('paypal_view');
}


public function processPaypal(Request $request)
{
$provider = new PayPalClient;

$paypalToken = $provider->getAccessToken();

$response = $provider->createOrder([
"intent" => "CAPTURE",
"application_context" => [
"return_url" => route('processSuccess'),
"cancel_url" => route('processCancel'),
],
"purchase_units" => [
0 => [
"amount" => [
"currency_code" => "USD",
"value" => "100.00"
]
]
]
]);

if (isset($response['id']) && $response['id'] != null) {

// redirect to approve href
foreach ($response['links'] as $links) {
if ($links['rel'] == 'approve') {
return
}
}

return redirect()
->route('createpaypal')
->with('error', 'Something went wrong.');

} else {
return redirect()
->route('createpaypal')
->with('error', $response['message'] ?? 'Something went wrong.');
}
}


public function processSuccess(Request $request)
{

$provider = new PayPalClient;

$provider->getAccessToken();
$response =

if (isset($response['status']) && $response['status'] == 'COMPLETED') {
return redirect()
->route('createpaypal')
->with('success', 'Transaction complete.');
} else {
return redirect()
->route('createpaypal')
->with('error', $response['message'] ?? 'Something went wrong.');
}

}

public function processCancel(Request $request)
{
return redirect()
->route('createpaypal')
->with('error', $response['message'] ?? 'You have canceled the transaction.');
}

}




Hope This Video Was Helpful . Can I Get a SUB

WebTechKnowledge
Автор

thank you, your tuitorials are always good and well explained

alvinellavu
Автор

Brother, I was waiting for this tutorial. Are you Bangladeshi?

md.mehedihasan
Автор

SetApiCredentials, getAccessToken, createOrder are not defined

natnaelberhanu
Автор

How can i get app_id for live account?

SaXuongLife