diff --git a/app/Http/Controllers/CustomAuthController.php b/app/Http/Controllers/CustomAuthController.php index 9e4a232..24bd01b 100755 --- a/app/Http/Controllers/CustomAuthController.php +++ b/app/Http/Controllers/CustomAuthController.php @@ -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 = ' '; - + 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'] )); } } diff --git a/app/Http/Controllers/paypal/PaypalController.php b/app/Http/Controllers/paypal/PaypalController.php index 15c297a..b7c26e2 100755 --- a/app/Http/Controllers/paypal/PaypalController.php +++ b/app/Http/Controllers/paypal/PaypalController.php @@ -79,16 +79,25 @@ class PaypalController extends Controller { $UserModel = new UserModel; - if (Auth::guest()) { - $message = 'Please Sign in to your account to proceed.'; - Session::flash('msg', $message); - return Redirect::back(); - } + // if (Auth::guest()) { + // $message = 'Please Sign in 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 shipping address.'; 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; diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 72a7613..b0665ef 100755 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -1,9 +1,13 @@ -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); } - } diff --git a/app/Http/routes.php b/app/Http/routes.php index 4ed7e79..a1b4a34 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,5 +1,6 @@ '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']); diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index e129675..8877d0f 100755 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -22,6 +22,7 @@
+
@@ -48,6 +49,14 @@
+
+ + +
+
diff --git a/resources/views/merchbay/cart.blade.php b/resources/views/merchbay/cart.blade.php index bee35ab..838cc6e 100755 --- a/resources/views/merchbay/cart.blade.php +++ b/resources/views/merchbay/cart.blade.php @@ -322,30 +322,42 @@ @endif

Order Summary

- + @if (!Auth::guest()) +
+

Ship to:

- @if ($address_book === null) - [ Add ] - @else -
{{ $address_book[0]->Fullname }}
-
{{ $address_book[0]->ContactNumber }}
-
- {{ $address_book[0]->Address . ', ' . $address_book[0]->State . ', ' . $address_book[0]->City . ', ' . $address_book[0]->Country . ', ' . $address_book[0]->CountryCode . ' ' . $address_book[0]->ZipCode }} - [ Edit ]
- @endif - + + @if ($address_book === null) + [ Add ] + @else +
{{ $address_book[0]->Fullname }}
+
{{ $address_book[0]->ContactNumber }}
+
+ {{ $address_book[0]->Address . ', ' . $address_book[0]->State . ', ' . $address_book[0]->City . ', ' . $address_book[0]->Country . ', ' . $address_book[0]->CountryCode . ' ' . $address_book[0]->ZipCode }} + [ Edit ] +
+ @endif +
- + @endif
-
Subtotal: {{ number_format($tax['order_grandtotal'] , 2) . ' ' . $store_array[0]->StoreCurrency }}
-
Shipping Fee: {{ number_format($shipping_fee , 2) . ' ' . $store_array[0]->StoreCurrency }}
-
Tax: {{ number_format($tax['tax'] , 2) . ' ' . $store_array[0]->StoreCurrency }}
-
-

Total: {{ number_format($tax['order_grandtotal'] + $shipping_fee + $tax['tax'], 2) }} - {{ $store_array[0]->StoreCurrency }}

+
Subtotal: + {{ number_format($tax['order_grandtotal'], 2) . ' ' . $store_array[0]->StoreCurrency }} +
+
Shipping Fee: + {{ number_format($shipping_fee, 2) . ' ' . $store_array[0]->StoreCurrency }} +
+
Tax: + {{ number_format($tax['tax'], 2) . ' ' . $store_array[0]->StoreCurrency }} +
+
+

Total: {{ number_format($tax['order_grandtotal'] + $shipping_fee + $tax['tax'], 2) }} + {{ $store_array[0]->StoreCurrency }} +

- {{-- {{ var_dump($tax) }} + {{-- {{ var_dump($tax) }} {{ var_dump($shipping_fee) }} --}}
@@ -386,13 +398,11 @@
-
+ Checkout
+ +
-->
Be advised payments made on merchbay will show up as crewsportswear on your receipt
diff --git a/resources/views/merchbay_main.blade.php b/resources/views/merchbay_main.blade.php index e56aa4d..fadd72e 100755 --- a/resources/views/merchbay_main.blade.php +++ b/resources/views/merchbay_main.blade.php @@ -7,14 +7,12 @@ - + Merchbay - + -
+
@include('merchbay.footer') @@ -73,8 +69,7 @@ - - + \ No newline at end of file diff --git a/resources/views/user-layouts/create_address_book.blade.php b/resources/views/user-layouts/create_address_book.blade.php index 1f08833..4cd4126 100755 --- a/resources/views/user-layouts/create_address_book.blade.php +++ b/resources/views/user-layouts/create_address_book.blade.php @@ -49,7 +49,7 @@
diff --git a/resources/views/user-layouts/edit_address_book.blade.php b/resources/views/user-layouts/edit_address_book.blade.php index 26208c6..6262e4a 100755 --- a/resources/views/user-layouts/edit_address_book.blade.php +++ b/resources/views/user-layouts/edit_address_book.blade.php @@ -49,7 +49,7 @@