Skip to content
  • Github
  • Facebook
  • twitter
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Site Map

XpertPhp

Expertphp Is The Best Tutorial For Beginners

  • Home
  • Javascript
    • Jquery
    • React JS
    • Angularjs
    • Angular
    • Nodejs
  • Codeigniter
  • Laravel
  • Contact Us
  • About Us
  • Live Demos
How To Use Paypal Payment Gateway In Laravel Framework

How To Use Paypal Payment Gateway In Laravel Framework

Posted on June 16, 2019December 17, 2022 By XpertPhp 1 Comment on How To Use Paypal Payment Gateway In Laravel Framework

In this tutorial, we will tell you how to use the Paypal payment gateway in Laravel Framework.

The Paypal payment gateway is a popular payment gateway method and it is easily used for the project. so many developers prefer that payment gateway method.

PayPal is a secure payment method and it’s work-based using API. it provides two environments for the user like a sandbox and live.

Now, we will go to the official PayPal site and after then log in, we have to need the Business email id and buyer email id. first, we will install the laravel, configuration of the database and migration database. after then we will get the cart of the product and that product data pass into PayPal form. but here we will use static form data. you can make a dynamic form of data.

HomeController.php

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
 
namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
use Response;
class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
return view('paypal');
    }
    public function cancel()
    {
        //
echo "Payment Transaction is Failed.";
    }
    public function success()
    {
        //
echo "Payment Transaction is successfully";
    }
?>

 

app.blade.php

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js"></script>
</head>
<body>
<div class="container">
    @yield('content')
</div>
</body>
</html>

paypal.blade.php

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@extends('app')
@section('content')
    <div class="row">
        <div class="col-lg-12">
                <h2>How To Use Paypal Payment Gateway In Laravel Framework</h2>
        </div>
    </div>
    <div class="row">
<div class="col-lg-4">&nbsp;</div>
<div class="col-lg-4">
<img src="https://images-na.ssl-images-amazon.com/images/I/315sKf9Qr5L.jpg" />
<p>Xiamoi Mi Smart Watch Phones with Camera</p>
<p>$ 12</p>
<?php
   $paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
   $paypal_id='testzone512-facilitator@gmail.com'; // Business email ID
?>
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal" id="frmPayPal">
@csrf
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
 
<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
 
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
 
 
<!-- Specify details about the item that buyers will purchase. -->
  
<input type="hidden" name="item_name_1" value="Xiamoi Mi Smart Watch Phones with Camera">
<input type="hidden" name="amount_1" value="12">
<input type="hidden" name="quantity_1" value="2">
 
<input type="hidden" name="shipping_1" value="10">
<input type="hidden" name="currency_code" value="USD">
 
 
<!-- Display header page logo. -->
<input type="hidden" name="cpp_header_image" value="https://xpertphp.com/assets/front/images/logoxp.png">
<!-- payment success or cancel then after show page. -->
<input type="hidden" name="cancel_return" value="">
<input type="hidden" name="return" value="">
<input type='hidden' name='rm' value='2'>
<!-- Display the payment button. -->
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
</div>
@endsection

routes/web.php

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
 
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
 
Route::get('/', function () {
   // return view('welcome');
});
 
Route::get('paypal','StudentController@index');
Route::get('paypal/cancel','StudentController@cancel');
Route::get('paypal/success','StudentController@success');
 
?>

Laravel Tags:Laravel Framework, laravel from scratch, payment gateway, payment gateway like stripe, paypal gateway, paypal payment gateway for website, paypal recurring payment integration in laravel

Post navigation

Previous Post: AngularJS Search Filter Example
Next Post: Sending Emails in PHP Using PHPMailer library

Latest Posts

  • Laravel 12 Ajax CRUD Example
  • Laravel 12 CRUD Example Tutorial
  • How to Create Dummy Data in Laravel 11
  • Laravel 11 Yajra Datatables Example
  • Laravel 11 Ajax CRUD Example
  • Laravel 11 CRUD Example Tutorial
  • Laravel 10 Ajax CRUD Example Tutorial
  • Laravel 10 CRUD Example Tutorial
  • How to disable button in React js
  • JavaScript Interview Questions and Answers

Tools

  • Compound Interest Calculator
  • Hex to RGB Color Converter
  • Pinterest Video Downloader
  • Birthday Calculator
  • Convert JSON to PHP Array Online
  • JavaScript Minifier
  • CSS Beautifier
  • CSS Minifier
  • JSON Beautifier
  • JSON Minifier

Categories

  • Ajax
  • Angular
  • Angularjs
  • Bootstrap
  • Codeigniter
  • Css
  • Htaccess
  • Interview
  • Javascript
  • Jquery
  • Laravel
  • MongoDB
  • MySql
  • Nodejs
  • Php
  • React JS
  • Shopify Api
  • Ubuntu

Tags

angular 10 tutorial angular 11 ci tutorial codeigniter 4 image upload Codeigniter 4 Tutorial codeigniter tutorial CodeIgniter tutorial for beginners codeigniter with mysql crud operation eloquent relationships file upload File Validation form validation Image Upload jQuery Ajax Form Handling jquery tutorial laravel 6 Laravel 6 Eloquent Laravel 6 Model laravel 6 relationship laravel 6 relationship eloquent Laravel 6 Routing laravel 7 Laravel 7 Eloquent laravel 7 routing laravel 7 tutorial Laravel 8 laravel 8 example laravel 8 tutorial laravel 9 example laravel 9 tutorial Laravel Framework laravel from scratch laravel social login learn jquery nodejs pagination payment gateway php with mysql react js example react js tutorial send mail validation wysiwyg editor wysiwyg html editor

Copyright © 2018 - 2025,

All Rights Reserved Powered by XpertPhp.com