Customers Add+Edit, API WP

This commit is contained in:
Kevin Adametz 2020-06-12 14:46:51 +02:00
parent dc63fa9fb2
commit 75a0f9a38a
120 changed files with 11894 additions and 6134 deletions

View file

@ -6,10 +6,9 @@ namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\ShoppingInstance;
use Validator;
use App\Services\Util;
use Yard;
use Input;
use Request;
class CardController extends Controller
{
@ -53,7 +52,7 @@ class CardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
$quantity = Input::get('quantity') ? Input::get('quantity') : 1;
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
Yard::instance('shopping')->reCalculateShippingPrice();
@ -66,8 +65,8 @@ class CardController extends Controller
public function showCard(){
if(Input::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Input::get('selected_country'));
if(Request::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'));
}else{
Yard::instance('shopping')->reCalculateShippingPrice();
}
@ -79,7 +78,7 @@ class CardController extends Controller
public function updateCard(){
$data = Input::all();
$data = Request::all();
if(isset($data['quantity'])){
foreach ($data['quantity'] as $rowId => $qty){
Yard::instance('shopping')->update($rowId, $qty);

View file

@ -17,7 +17,7 @@ use Illuminate\Support\Collection;
use Validator;
use App\Services\Util;
use Yard;
use Input;
use Request;
class CheckoutController extends Controller
{
@ -39,8 +39,8 @@ class CheckoutController extends Controller
// $user_shop = Util::getUserShop();
if(Input::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Input::get('selected_country'));
if(Request::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'));
}else{
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
// $selected_country = $ShippingCountry->id;
@ -107,7 +107,7 @@ class CheckoutController extends Controller
'accepted_data_checkbox' => 'accepted',
);
if(!Input::get('same_as_billing')){
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
@ -118,24 +118,26 @@ class CheckoutController extends Controller
]);
}
$validator = Validator::make(Input::all(), $rules);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
return back()->withErrors($validator)->withInput(Request::all());
}
$data = Input::all();
$data = Request::all();
//make User
$shopping_user = $this->makeShoppingUser($data);
//make Order and Items
$shopping_order = $this->makeShoppingOrder($shopping_user);
//CustomerPriority
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
//check credit Card
if(Input::get('payment_method')){
if(Request::get('payment_method')){
$ret = [];
//need precheck the card
if(Input::get('payment_method') === 'cc'){
if(Request::get('payment_method') === 'cc'){
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
$ret['cc'] = $pay->checkCreditCard($data);
@ -151,7 +153,7 @@ class CheckoutController extends Controller
\Session::flash('cc-error', 1);
\Session::flash('errormessage', $ret['cc']['errormessage']);
\Session::flash('customermessage', $ret['cc']['customermessage']);
return redirect(route('checkout.checkout_card'))->withInput(Input::all());
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
}
if($ret['cc']['status'] === 'VALID'){
/*
@ -163,10 +165,10 @@ class CheckoutController extends Controller
}
//need precheck the card
if(Input::get('payment_method') === 'elv' && is_null(Input::get('mandate_identification'))){
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100;
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') *100;
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){
@ -181,14 +183,14 @@ class CheckoutController extends Controller
\Session::flash('elv-error', 1);
\Session::flash('errormessage', $ret['elv']['errormessage']);
\Session::flash('customermessage', $ret['elv']['customermessage']);
return redirect(route('checkout.checkout_card'))->withInput(Input::all());
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
}
if($ret['elv']['status'] === 'APPROVED' && $ret['elv']['mandate_status'] !== "active"){
\Session::flash('elv-managemandate', 1);
\Session::flash('elv-mandate_identification', $ret['elv']['mandate_identification']);
\Session::flash('elv-mandate_text', $ret['elv']['mandate_text']);
\Session::flash('elv-creditor_identifier', $ret['elv']['creditor_identifier']);
return redirect(route('checkout.checkout_card'))->withInput(Input::all());
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
/*
* array(4) { ["status"]=> string(5) "VALID" ["pseudocardpan"]=> string(19) "9410010000169020567" ["cardtype"]=> string(1) "V" ["truncatedcardpan"]=> string(16) "411111XXXXXX1111" }
@ -199,9 +201,9 @@ class CheckoutController extends Controller
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
}
if(Input::get('payment_method') === 'elv' && Input::get('mandate_identification')) {
$ret['elv']['mandate_identification'] = Input::get('mandate_identification');
$ret['elv']['creditor_identifier'] = Input::get('creditor_identifier');
if(Request::get('payment_method') === 'elv' && Request::get('mandate_identification')) {
$ret['elv']['mandate_identification'] = Request::get('mandate_identification');
$ret['elv']['creditor_identifier'] = Request::get('creditor_identifier');
$ret['elv']['iban'] = $data['elv_iban'];
$ret['elv']['bic'] = $data['elv_bic'];
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
@ -212,8 +214,8 @@ class CheckoutController extends Controller
//other
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100;
$reference = $pay->setPrePayment(Input::get('payment_method'), $amount, 'EUR', $ret);
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$reference = $pay->setPrePayment(Request::get('payment_method'), $amount, 'EUR', $ret);
$this->putPayments('payment_reference', $reference);
$pay->setPersonalData();
return $pay->ResponseData();
@ -297,6 +299,8 @@ class CheckoutController extends Controller
private function makeShoppingUser($data){
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;
@ -311,8 +315,6 @@ class CheckoutController extends Controller
if(!$shopping_user){
$shopping_user = ShoppingUser::create($data);
}
//CustomerPriority
CustomerPriority::checkOne($shopping_user, true);
$this->putPayments('shopping_user_id', $shopping_user->id);
return $shopping_user;
@ -328,12 +330,12 @@ class CheckoutController extends Controller
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'user_shop_id' => $user_shop->id,
'payment_for' => Util::getUserPaymentFor(),
'total' => Yard::instance('shopping')->total(2, '.', ','),
'total' => Yard::instance('shopping')->total(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
'tax_rate' => Yard::getTaxRate(),
'tax' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ','),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ','),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
'mode' => Util::getUserShoppingMode(),
];
@ -353,7 +355,6 @@ class CheckoutController extends Controller
$items = Yard::instance('shopping')->content();
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order) {
foreach ($items as $item) {
if ($model->row_id === $item->rowId) {

View file

@ -6,7 +6,7 @@ namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Mail\MailContact;
use GuzzleHttp\Client;
use Input;
use Request;
use Illuminate\Support\Facades\Mail;
use App\Services\Util;
use Validator;
@ -54,19 +54,19 @@ class ContactController extends Controller
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
});
$validator = Validator::make(Input::all(), $rules);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
return back()->withErrors($validator)->withInput(Request::all());
}
$contact = [];
$contact['first_name'] = Input::get('first_name');
$contact['last_name'] = Input::get('last_name');
$contact['email'] = Input::get('email');
$contact['phone'] = Input::get('phone');
$contact['subject'] = Input::get('subject');
$contact['message'] = Input::get('message');
$contact['first_name'] = Request::get('first_name');
$contact['last_name'] = Request::get('last_name');
$contact['email'] = Request::get('email');
$contact['phone'] = Request::get('phone');
$contact['subject'] = Request::get('subject');
$contact['message'] = Request::get('message');
$checkout_mail = config('app.checkout_mail');
if($user_shop){

View file

@ -10,7 +10,7 @@ use App\Repositories\UserRepository;
use App\Services\UserService;
use App\User;
use GuzzleHttp\Client;
use Input;
use Request;
use Illuminate\Support\Facades\Mail;
use App\Services\Util;
use Validator;
@ -82,14 +82,14 @@ class RegisterController extends Controller
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
});*/
$validator = Validator::make(Input::all(), $rules);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
return back()->withErrors($validator)->withInput(Request::all());
}
$user_shop = Util::getUserShop();
$data = Input::all();
$data = Request::all();
$user = $this->userRepo->create($data);
$confirmation_code = UserService::createConfirmationCode();

View file

@ -7,7 +7,6 @@ use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\IqSite;
use App\Models\Product;
use Input;
use App\Services\Util;
class SiteController extends Controller