updated checkout flow
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use App\Traits\CaptchaTrait;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\user\UserModel;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -72,6 +73,7 @@ class CustomAuthController extends Controller
|
||||
public function postRegister(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$userModel = new UserModel;
|
||||
|
||||
$post['captcha'] = $this->captchaCheck();
|
||||
|
||||
@@ -87,6 +89,12 @@ class CustomAuthController extends Controller
|
||||
'g-recaptcha-response.required' => 'Captcha is required',
|
||||
'captcha.min' => 'Wrong captcha, please try again.'
|
||||
]
|
||||
|
||||
// $post,
|
||||
// [
|
||||
// 'username' => 'unique:user_logins',
|
||||
// 'email' => 'unique:user_logins',
|
||||
// ]
|
||||
);
|
||||
|
||||
|
||||
@@ -105,9 +113,9 @@ class CustomAuthController extends Controller
|
||||
$message = '
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<strong>Error!</strong>' . $errors .
|
||||
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
@@ -115,7 +123,7 @@ class CustomAuthController extends Controller
|
||||
));
|
||||
}
|
||||
|
||||
User::create([
|
||||
$user = User::create([
|
||||
'name' => $post['name'],
|
||||
'username' => $post['username'],
|
||||
'email' => $post['email'],
|
||||
@@ -123,10 +131,19 @@ class CustomAuthController extends Controller
|
||||
'role' => 'user'
|
||||
]);
|
||||
|
||||
$country = explode("_", $post['country']);
|
||||
|
||||
$data = array(
|
||||
'UserId' => $user->id,
|
||||
'CountryCode' => $country[0],
|
||||
'Country' => $country[1]
|
||||
);
|
||||
$userModel->insertAddressBook($data);
|
||||
Auth::attempt(['email' => $post['email'], 'password' => $post['password']]);
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true
|
||||
'success' => true,
|
||||
'redirect' => $post['redirect']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,16 +79,25 @@ class PaypalController extends Controller
|
||||
{
|
||||
$UserModel = new UserModel;
|
||||
|
||||
if (Auth::guest()) {
|
||||
$message = 'Please <a href="' . url('auth/login') . '">Sign in</a> to your account to proceed.';
|
||||
Session::flash('msg', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
// if (Auth::guest()) {
|
||||
// $message = 'Please <a href="' . url('auth/login') . '">Sign in</a> to your account to proceed.';
|
||||
// Session::flash('msg', $message);
|
||||
// return Redirect::back();
|
||||
// }
|
||||
|
||||
$userId = Auth::user()->id;
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
if (count($array_address_book) <= 0) {
|
||||
$message = 'Please add Shipping address.';
|
||||
if (
|
||||
count($array_address_book) <= 0 ||
|
||||
$array_address_book[0]->Fullname == null ||
|
||||
$array_address_book[0]->ContactNumber == null ||
|
||||
$array_address_book[0]->Address == null ||
|
||||
$array_address_book[0]->State == null ||
|
||||
$array_address_book[0]->City == null ||
|
||||
$array_address_book[0]->ZipCode == null
|
||||
|
||||
) {
|
||||
$message = 'Please complete your <a href="'.url('user/address-book').'"><u>shipping address</u></a>.';
|
||||
Session::flash('cartkeyError', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
@@ -115,14 +124,14 @@ class PaypalController extends Controller
|
||||
$payer = PayPal::Payer();
|
||||
$payer->setPaymentMethod('paypal');
|
||||
|
||||
$inputFields = Paypal::InputFields();
|
||||
$inputFields->setAllowNote(true)
|
||||
->setNoShipping(1)
|
||||
->setAddressOverride(0);
|
||||
$webProfile = Paypal::WebProfile();
|
||||
$webProfile->setName("YeowZa! T-Shirt Shop" . uniqid())
|
||||
// ->setPresentation($presentation)
|
||||
->setInputFields($inputFields);
|
||||
// $inputFields = Paypal::InputFields();
|
||||
// $inputFields->setAllowNote(true)
|
||||
// ->setNoShipping(1)
|
||||
// ->setAddressOverride(0);
|
||||
// $webProfile = Paypal::WebProfile();
|
||||
// $webProfile->setName("YeowZa! T-Shirt Shop" . uniqid())
|
||||
// // ->setPresentation($presentation)
|
||||
// ->setInputFields($inputFields);
|
||||
|
||||
// $shipping = PayPal::ShippingAddress();
|
||||
// $shipping->setRecipientName($array_address_book[0]->Fullname);
|
||||
@@ -185,8 +194,8 @@ class PaypalController extends Controller
|
||||
$payment = PayPal::Payment();
|
||||
|
||||
// var_dump(array($transaction));
|
||||
if($array_address_book[0]->CountryCode == "CA"){
|
||||
|
||||
if ($array_address_book[0]->CountryCode == "CA") {
|
||||
|
||||
$shipping = PayPal::ShippingAddress();
|
||||
$shipping->setRecipientName($array_address_book[0]->Fullname);
|
||||
$shipping->setLine1($array_address_book[0]->Address);
|
||||
@@ -200,7 +209,7 @@ class PaypalController extends Controller
|
||||
$payment->setExperienceProfileId($this->createWebProfile());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// var_dump($item_list);
|
||||
|
||||
$amount_details = PayPal::Details();
|
||||
@@ -226,7 +235,7 @@ class PaypalController extends Controller
|
||||
// var_dump($shippingAddress)
|
||||
|
||||
|
||||
|
||||
|
||||
$payment->setIntent('sale');
|
||||
$payment->setPayer($payer);
|
||||
$payment->setRedirectUrls($redirectUrls);
|
||||
@@ -422,7 +431,7 @@ class PaypalController extends Controller
|
||||
|
||||
$currency = $obj->transactions[0]->amount->currency;
|
||||
$invoice_number = $obj->transactions[0]->invoice_number;
|
||||
|
||||
// var_dump( $obj->transactions[0]->item_list->phone);
|
||||
//shipping address details
|
||||
$recipient_name = $obj->transactions[0]->item_list->shipping_address->recipient_name;
|
||||
$line1 = $obj->transactions[0]->item_list->shipping_address->line1;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class Authenticate {
|
||||
class Authenticate
|
||||
{
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
@@ -32,19 +36,19 @@ class Authenticate {
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$prev = URL::previous();
|
||||
if (str_contains($prev, ['cart'])) {
|
||||
return redirect()->guest('auth/register?redirectUrl='. $prev);
|
||||
}
|
||||
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
// use Spatie\LaravelAnalytics\LaravelAnalytics;
|
||||
/*
|
||||
@@ -150,6 +151,7 @@ Route::group(['middleware' => 'normaluser'], function () {
|
||||
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
// PAYPAL ROUTES
|
||||
|
||||
Route::get('payPremium', ['as' => 'payPremium', 'uses' => 'paypal\PaypalController@payPremium']);
|
||||
Route::get('getCheckout', ['as' => 'getCheckout', 'uses' => 'paypal\PaypalController@getCheckout']);
|
||||
Route::get('getDone', ['as' => 'getDone', 'uses' => 'paypal\PaypalController@getDone']);
|
||||
|
||||
Reference in New Issue
Block a user