Managing View, Edit & Update Profile Details
This commit is contained in:
parent
49d6315cc4
commit
a1835247d6
@ -40,6 +40,8 @@ class MainController extends Controller
|
|||||||
|
|
||||||
public function registerUser(Request $data)
|
public function registerUser(Request $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// dd($data->all());
|
||||||
// Validate the input data
|
// Validate the input data
|
||||||
$data->validate([
|
$data->validate([
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
@ -183,6 +185,31 @@ class MainController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function profile()
|
||||||
|
{
|
||||||
|
if (session()->has('id')) {
|
||||||
|
$user = User::find(session()->get('id'));
|
||||||
|
return view('profile', compact('user'));
|
||||||
|
}
|
||||||
|
return redirect('login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateUser(Request $data)
|
||||||
|
{
|
||||||
|
$user = User::find(session()->get('id'));
|
||||||
|
$user->name = $data->input('name');
|
||||||
|
$user->email = $data->input('email');
|
||||||
|
$user->password = $data->input('password');
|
||||||
|
|
||||||
|
if ($data->file('file') != null) {
|
||||||
|
$user->picture = $data->file('file')->getClientOriginalName();
|
||||||
|
$data->file('file')->move('uploads/profiles/', $user->picture);
|
||||||
|
}
|
||||||
|
if ($user->save()) {
|
||||||
|
return redirect()->back()->with('success', 'User updated successfully!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -225,6 +252,8 @@ class MainController extends Controller
|
|||||||
return view('checkout');
|
return view('checkout');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function shop()
|
public function shop()
|
||||||
{
|
{
|
||||||
return view('shop');
|
return view('shop');
|
||||||
|
75
app/Http/Controllers/StripePaymentController.php
Normal file
75
app/Http/Controllers/StripePaymentController.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Order;
|
||||||
|
use App\Models\Cart;
|
||||||
|
use App\Models\Products;
|
||||||
|
use App\Models\OrderItem;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Stripe;
|
||||||
|
|
||||||
|
class StripePaymentController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* success response method.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response */
|
||||||
|
public function stripe(Request $data)
|
||||||
|
{
|
||||||
|
$bill = $data->input('bill');
|
||||||
|
$name = $data->input('name');
|
||||||
|
|
||||||
|
$phone = $data->input('phone');
|
||||||
|
$address = $data->input('address');
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'stripe',
|
||||||
|
compact('bill', 'name', 'phone', 'address')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* success response method.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response */
|
||||||
|
public function stripePost(Request $request)
|
||||||
|
{
|
||||||
|
Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
|
||||||
|
Stripe\Charge::create([
|
||||||
|
"amount" => $request->input('bill') * 100,
|
||||||
|
"currency" => "usd",
|
||||||
|
"source" => $request->stripeToken,
|
||||||
|
"description" => "Payment Successfull!"
|
||||||
|
]);
|
||||||
|
Session::flash('success', 'Payment successful!');
|
||||||
|
|
||||||
|
if (session()->has('id')) {
|
||||||
|
$order = new Order();
|
||||||
|
$order->status = "Pending";
|
||||||
|
$order->customerId = session()->get('id');
|
||||||
|
$order->name = $request->input('name');
|
||||||
|
$order->phone = $request->input('phone');
|
||||||
|
$order->address = $request->input('address');
|
||||||
|
$order->bill = $request->input('bill');
|
||||||
|
if ($order->save()) {
|
||||||
|
$cartItems = Cart::where('customerId', session()->get('id'))->get();
|
||||||
|
foreach ($cartItems as $item) {
|
||||||
|
$product = Products::find($item->productId);
|
||||||
|
$orderItem = new OrderItem();
|
||||||
|
$orderItem->orderId = $order->id;
|
||||||
|
$orderItem->productId = $item->productId;
|
||||||
|
$orderItem->quantity = $item->quantity;
|
||||||
|
$orderItem->price = $product->price;
|
||||||
|
|
||||||
|
$orderItem->save();
|
||||||
|
$item->delete();
|
||||||
|
}
|
||||||
|
return redirect('/cart')->back()->with('success', 'Order placed successfully!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"laravel/framework": "^11.9",
|
"laravel/framework": "^11.9",
|
||||||
"laravel/tinker": "^2.9"
|
"laravel/tinker": "^2.9",
|
||||||
|
"stripe/stripe-php": "^15.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
|
61
composer.lock
generated
61
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7e8c3c14ff33b199b4a0838993eb8423",
|
"content-hash": "14e8cdf03b6b5d46f815f7145406604e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -3107,6 +3107,65 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-04-27T21:32:50+00:00"
|
"time": "2024-04-27T21:32:50+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "stripe/stripe-php",
|
||||||
|
"version": "v15.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/stripe/stripe-php.git",
|
||||||
|
"reference": "ce69d019941cf528c036ae0d1a3a9580c7389460"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/stripe/stripe-php/zipball/ce69d019941cf528c036ae0d1a3a9580c7389460",
|
||||||
|
"reference": "ce69d019941cf528c036ae0d1a3a9580c7389460",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"php": ">=5.6.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "3.5.0",
|
||||||
|
"phpstan/phpstan": "^1.2",
|
||||||
|
"phpunit/phpunit": "^5.7 || ^9.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Stripe\\": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Stripe and contributors",
|
||||||
|
"homepage": "https://github.com/stripe/stripe-php/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Stripe PHP Library",
|
||||||
|
"homepage": "https://stripe.com/",
|
||||||
|
"keywords": [
|
||||||
|
"api",
|
||||||
|
"payment processing",
|
||||||
|
"stripe"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/stripe/stripe-php/issues",
|
||||||
|
"source": "https://github.com/stripe/stripe-php/tree/v15.1.0"
|
||||||
|
},
|
||||||
|
"time": "2024-07-05T18:52:07+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/clock",
|
"name": "symfony/clock",
|
||||||
"version": "v7.1.1",
|
"version": "v7.1.1",
|
||||||
|
BIN
public/uploads/profiles/IMG_2206.jpg
Normal file
BIN
public/uploads/profiles/IMG_2206.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
BIN
public/uploads/profiles/wallpaperflare.com_wallpaper (2).jpg
Normal file
BIN
public/uploads/profiles/wallpaperflare.com_wallpaper (2).jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
@ -154,9 +154,9 @@
|
|||||||
<li>Total <span>Nrs {{ $total }}</span></li>
|
<li>Total <span>Nrs {{ $total }}</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
<form action=" {{ url::to('checkout') }} ">
|
<form action=" {{ url::to('checkout') }} ">
|
||||||
|
{{-- <form action=" {{ url::to('stripe') }} "> --}}
|
||||||
<input type="text" name="name" class="form-control mt-2" placeholder="Enter Name"
|
<input type="text" name="name" class="form-control mt-2" placeholder="Enter Name"
|
||||||
id="" required>
|
id="" required>
|
||||||
|
|
||||||
<input type="text" name="phone" class="form-control mt-2"
|
<input type="text" name="phone" class="form-control mt-2"
|
||||||
placeholder
|
placeholder
|
||||||
="Enter Phone" id="" required>
|
="Enter Phone" id="" required>
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
<link rel="stylesheet" href="{{ URL::asset('css/owl.carousel.min.css') }}"type="text/css">
|
<link rel="stylesheet" href="{{ URL::asset('css/owl.carousel.min.css') }}"type="text/css">
|
||||||
<link rel="stylesheet" href="{{ URL::asset('css/slicknav.min.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ URL::asset('css/slicknav.min.css') }}" type="text/css">
|
||||||
<link rel="stylesheet" href="{{ URL::asset('css/style.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ URL::asset('css/style.css') }}" type="text/css">
|
||||||
|
<!-- Include the Stripe.js library -->
|
||||||
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -115,16 +117,10 @@
|
|||||||
{{-- <li><a href="{{ URL::to('singleProduct') }}">Single Product</a></li> --}}
|
{{-- <li><a href="{{ URL::to('singleProduct') }}">Single Product</a></li> --}}
|
||||||
<li><a href="{{ URL::to('cart') }}">Shopping Cart</a></li>
|
<li><a href="{{ URL::to('cart') }}">Shopping Cart</a></li>
|
||||||
<li><a href="{{ URL::to('checkout') }}">Check Out</a></li>
|
<li><a href="{{ URL::to('checkout') }}">Check Out</a></li>
|
||||||
{{-- <li><a href="{{ URL::to('blogDetails') }}">Blog Details</a></li> --}}
|
<li><a href="{{ URL::to('profile') }}">Profile</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{{--
|
|
||||||
@if (session()->has('id'))
|
|
||||||
<li><a href="{{ URL::to('/logout') }}">Logout</a></li>
|
|
||||||
@else
|
|
||||||
<li><a href="{{ URL::to('/login') }}">Login</a></li>
|
|
||||||
<li><a href="{{ URL::to('/register') }}">Register</a></li>
|
|
||||||
@endif --}}
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
72
resources/views/profile.blade.php
Normal file
72
resources/views/profile.blade.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<x-header />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Contact Section Begin -->
|
||||||
|
<section class="contact spad">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-lg-6 col-md-6 mx-auto">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>Update Account</h2>
|
||||||
|
</div>
|
||||||
|
<div class="contact__form">
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div class="alert alert-success">
|
||||||
|
{{ session('success') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<img src="{{ 'uploads/profiles/' . $user->picture }}" class=" mx-auto d-block mb-2 rounded-circle"
|
||||||
|
alt="profile picture" width="100px" height="100px">
|
||||||
|
|
||||||
|
<form action="{{ URL::to('updateUser') }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="text" name="name" value="{{ $user->name }}" id="name"
|
||||||
|
placeholder="Name" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="email" name="email" value="{{ $user->email }}" id="email"
|
||||||
|
placeholder="Email" readonly required>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="file" name="file">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="password" name="password" value="{{ $user->password }}" id="password"
|
||||||
|
placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
|
||||||
|
<button type="submit" class="site-btn">Save Changes</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<!-- Contact Section End -->
|
||||||
|
|
||||||
|
<!-- Footer Section Begin -->
|
||||||
|
<x-footer />
|
||||||
|
<!-- Footer Section End -->
|
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<form action="{{ URL::to('registerUser') }}" method="POST" enctype="multipart/form-data">
|
{{-- <form action="{{ URL::to('registerUser') }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
@ -50,11 +50,39 @@
|
|||||||
<input type="password" name="password" id="password" placeholder="Password">
|
<input type="password" name="password" id="password" placeholder="Password">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
<input type="password" name="password_confirmation" id="password_confirmation"
|
||||||
|
placeholder="Confirm Password" required>
|
||||||
|
<button type="submit" class="site-btn">Sign Up</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form> --}}
|
||||||
|
|
||||||
|
<form action="{{ route('registerUser') }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="text" name="name" id="name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="email" name="email" id="email" placeholder="Email">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="file" name="file">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="password" name="password" id="password" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="password" name="password_confirmation" id="password_confirmation"
|
||||||
|
placeholder="Confirm Password">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
<button type="submit" class="site-btn">Sign Up</button>
|
<button type="submit" class="site-btn">Sign Up</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
139
resources/views/stripe.blade.php
Normal file
139
resources/views/stripe.blade.php
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Laravel - Stripe Payment Gateway Integration Example - ItSolutionStuff.com</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="text-center">Stripe Payment Gateway </h1>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-md-offset-3">
|
||||||
|
<div class="panel panel-default credit-card-box">
|
||||||
|
<div class="panel-heading display-table">
|
||||||
|
<h3 class="panel-title">Payment Details</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
@if (Session::has('success'))
|
||||||
|
<div class="alert alert-success text-center">
|
||||||
|
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||||
|
<p>{{ Session::get('success') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<form role="form" action="{{ route('stripe.post') }}" method="post"
|
||||||
|
class="require-validation" data-cc-on-file="false"
|
||||||
|
data-stripe-publishable-key="{{ env('STRIPE_KEY') }}" id="payment-form">
|
||||||
|
@csrf
|
||||||
|
<div class='form-row row'>
|
||||||
|
<div class='col-xs-12 form-group required'>
|
||||||
|
<label class='control-label'>Name on Card</label> <input class='form-control'
|
||||||
|
size='4' type='text'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='form-row row'>
|
||||||
|
<div class='col-xs-12 form-group card required'>
|
||||||
|
<label class='control-label'>Card Number</label> <input autocomplete='off'
|
||||||
|
class='form-control card-number' size='20' type='text'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='form-row row'>
|
||||||
|
<div class='col-xs-12 col-md-4 form-group cvc required'>
|
||||||
|
<label class='control-label'>CVC</label> <input autocomplete='off'
|
||||||
|
class='form-control card-cvc' placeholder='ex. 311' size='4'
|
||||||
|
type='text'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='col-xs-12 col-md-4 form-group expiration required'> <label
|
||||||
|
class='control-label'>Expiration Month</label> <input
|
||||||
|
class='form-control card-expiry-month' placeholder='MM' size='2'
|
||||||
|
type='text'> </div>
|
||||||
|
<div class='col-xs-12 col-md-4 form-group expiration required'> <label
|
||||||
|
class='control-label'>Expiration Year</label> <input
|
||||||
|
class='form-control card-expiry-year' placeholder='YYYY' size='4'
|
||||||
|
type='text'> </div>
|
||||||
|
</div>
|
||||||
|
<div class='form-row row'>
|
||||||
|
<div class='col-md-12 error form-group hide'>
|
||||||
|
<div class='alert-danger alert'>Please correct the errors and try again.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<input type="hidden" value="{{ $name }}" name="name"
|
||||||
|
class="form-control mt-2" placeholder="Enter Name" id="" required>
|
||||||
|
<input type="hidden" value="{{ $phone }}" name="phone"
|
||||||
|
class="form-control mt-2" placeholder="Enter Phone" id="" required>
|
||||||
|
<input type="hidden" value="{{ $address }}" name="address"
|
||||||
|
class="form-control mt-2" placeholder="Enter Address" id="" required>
|
||||||
|
<input type="hidden" name="bill" class="form-control mt-2"
|
||||||
|
value="{{ $bill }}" id="" required>
|
||||||
|
<button class="btn btn-primary btn-lg btn-block" type="submit">Pay
|
||||||
|
Now(Nrs{{ $bill }})</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
/*------------------------------------------ -------------------------------------------- Stripe Payment Code -------------------------------------------- --------------------------------------------*/
|
||||||
|
var $form = $(".require-validation");
|
||||||
|
$('form.require-validation').bind('submit', function(e) {
|
||||||
|
var $form = $(".require-validation"),
|
||||||
|
inputSelector = ['input[type=email]', 'input[type=password]',
|
||||||
|
'input[type=text]', 'input[type=file]',
|
||||||
|
'textarea'
|
||||||
|
].join(', '),
|
||||||
|
$inputs = $form.find('.required').find(inputSelector),
|
||||||
|
$errorMessage = $form.find('div.error'),
|
||||||
|
valid = true;
|
||||||
|
|
||||||
|
$errorMessage.addClass('hide');
|
||||||
|
$('.has-error').removeClass('has-error');
|
||||||
|
$inputs.each(function(i, el) {
|
||||||
|
var $input = $(el);
|
||||||
|
if ($input.val() === '') {
|
||||||
|
$input.parent().addClass('has-error');
|
||||||
|
$errorMessage.removeClass('hide');
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!$form.data('cc-on-file')) {
|
||||||
|
e.preventDefault();
|
||||||
|
Stripe.setPublishableKey($form.data('stripe-publishable-key'));
|
||||||
|
Stripe.createToken({
|
||||||
|
number: $('.card-number').val(),
|
||||||
|
cvc: $('.card-cvc').val(),
|
||||||
|
exp_month: $('.card-expiry-month').val(),
|
||||||
|
exp_year: $('.card-expiry-year').val()
|
||||||
|
}, stripeResponseHandler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/*------------------------------------------ -------------------------------------------- Stripe Response Handler --------------------------------------------
|
||||||
|
|
||||||
|
--------------------------------------------*/
|
||||||
|
function stripeResponseHandler(status, response) {
|
||||||
|
if (response.error) {
|
||||||
|
$('.error')
|
||||||
|
.removeClass('hide').find('.alert').text(response.error.message);
|
||||||
|
} else {
|
||||||
|
/* token contains id, last4, and card type */
|
||||||
|
var token = response['id'];
|
||||||
|
$form.find('input[type=text]').empty();
|
||||||
|
$form.append("<input type='hidden' name='stripeToken' value='" + token + "'/>");
|
||||||
|
$form.get(0).submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</html>
|
@ -1,30 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\MainController;
|
use App\Http\Controllers\MainController;
|
||||||
|
use App\Http\Controllers\StripePaymentController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
|
||||||
Route::get('/', [MainController::class, 'index']);
|
Route::get('/', [MainController::class, 'index']);
|
||||||
Route::get('/about', [MainController::class, 'about']);
|
Route::get('/about', [MainController::class, 'about']);
|
||||||
Route::get('/blog', [MainController::class, 'blog']);
|
Route::get('/blog', [MainController::class, 'blog']);
|
||||||
Route::get('/blogDetails', [MainController::class, 'blogDetails']);
|
|
||||||
|
Route::get('/profile', [MainController::class, 'profile']);
|
||||||
|
|
||||||
|
Route::post('/updateUser', [MainController::class, 'updateUser']);
|
||||||
|
|
||||||
Route::get('/cart', [MainController::class, 'cart']);
|
Route::get('/cart', [MainController::class, 'cart']);
|
||||||
Route::post('/addToCart', [MainController::class, 'addToCart']);
|
Route::post('/addToCart', [MainController::class, 'addToCart']);
|
||||||
Route::get('/deleteCartItem/{id}', [MainController::class, 'deleteCartItem']);
|
Route::get('/deleteCartItem/{id}', [MainController::class, 'deleteCartItem']);
|
||||||
Route::post('/updateCartItem/{id}', [MainController::class, 'updateCartItem'])->name("cart.update");
|
Route::post('/updateCartItem/{id}', [MainController::class, 'updateCartItem'])->name("cart.update");
|
||||||
|
|
||||||
|
|
||||||
Route::get('/checkout', [MainController::class, 'checkout']);
|
Route::get('/checkout', [MainController::class, 'checkout']);
|
||||||
Route::get('/main', [MainController::class, 'main']);
|
Route::get('/main', [MainController::class, 'main']);
|
||||||
|
|
||||||
Route::get('/shop', [MainController::class, 'shop']);
|
Route::get('/shop', [MainController::class, 'shop']);
|
||||||
Route::get('/single/{id}', [MainController::class, 'singleProduct']);
|
Route::get('/single/{id}', [MainController::class, 'singleProduct']);
|
||||||
|
|
||||||
Route::get('/register', [MainController::class, 'register']);
|
Route::get('/register', [MainController::class, 'register'])->name('register');
|
||||||
Route::post('/registerUser', [MainController::class, 'registerUser']);
|
Route::post('/registerUser', [MainController::class, 'registerUser'])->name('registerUser');
|
||||||
|
|
||||||
Route::get('/login', [MainController::class, 'login']);
|
Route::get('/login', [MainController::class, 'login']);
|
||||||
Route::post('/loginUser', [MainController::class, 'loginUser']);
|
Route::post('/loginUser', [MainController::class, 'loginUser']);
|
||||||
|
|
||||||
Route::get('/logout', [MainController::class, 'logout']);
|
Route::get('/logout', [MainController::class, 'logout']);
|
||||||
|
|
||||||
|
|
||||||
|
Route::controller(StripePaymentController::class)->group(function () {
|
||||||
|
Route::get('stripe', 'stripe');
|
||||||
|
Route::post('stripe', 'stripePost')->name('stripe.post');
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user