How To Use Paypal Payment Gateway In Laravel Framework – onlinecode

How To Use Paypal Payment Gateway In Laravel Framework – onlinecode

In this post we will give you information about How To Use Paypal Payment Gateway In Laravel Framework – onlinecode. Hear we will give you detail about How To Use Paypal Payment Gateway In Laravel Framework – onlinecodeAnd how to use it also give you demo for it if it is necessary.

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
<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use Response;
class HomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return IlluminateHttpResponse
     */
    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
<!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 >
    @yield('content')
</div>
</body>
</html>

paypal.blade.php

PHP
@extends('app')
@section('content')
    <div >
        <div >
                <h2>How To Use Paypal Payment Gateway In Laravel Framework</h2>
        </div>
    </div>
    <div >
		<div >&nbsp;</div>
		<div >
		<img src="https://images-na.ssl-images-amazon.com/images/I/315sKf9Qr5L.jpg" />
		Xiamoi Mi Smart Watch Phones with Camera</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="//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
<?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');

?>

Please follow and like us:

Hope this code and post will helped you for implement How To Use Paypal Payment Gateway In Laravel Framework – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

24  +    =  33

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US