Customers Add+Edit, API WP
This commit is contained in:
parent
dc63fa9fb2
commit
75a0f9a38a
120 changed files with 11894 additions and 6134 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue