checkout, register, payment,

checkout correction,
register wizard,
payment packege,
This commit is contained in:
Kevin Adametz 2019-03-02 00:08:11 +01:00
parent 6e3adac4d7
commit 446bc4561b
48 changed files with 2580 additions and 1493 deletions

View file

@ -11,6 +11,7 @@ use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderItem;
use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\User;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Mail;
@ -37,7 +38,7 @@ class CheckoutController extends Controller
public function checkout(){
$user_shop = Util::getUserShop();
// $user_shop = Util::getUserShop();
if(Input::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Input::get('selected_country'));
@ -46,7 +47,42 @@ class CheckoutController extends Controller
// $selected_country = $ShippingCountry->id;
}
$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){
$user = Util::getAuthUser();
$user->email;
$account = $user->account;
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
$shopping_user->billing_firstname = $user->account->first_name;
$shopping_user->billing_lastname = $user->account->last_name;
$shopping_user->billing_address = $user->account->address;
$shopping_user->billing_address_2 = $user->account->address_2;
$shopping_user->billing_zipcode = $user->account->zipcode;
$shopping_user->billing_city = $user->account->city;
$shopping_user->billing_country_id = $user->account->country_id;
$shopping_user->billing_phone = $user->account->phone;
$shopping_user->billing_email = $user->email;
$shopping_user->accepted_data_checkbox = 1;
$shopping_user->same_as_billing = $user->account->same_as_billing;
$shopping_user->shipping_salutation = $user->account->shipping_salutation;
$shopping_user->shipping_company = $user->account->shipping_company;
$shopping_user->shipping_firstname = $user->account->shipping_firstname;
$shopping_user->shipping_lastname = $user->account->shipping_lastname;
$shopping_user->shipping_address = $user->account->shipping_address;
$shopping_user->shipping_address_2 = $user->account->shipping_address_2;
$shopping_user->shipping_zipcode = $user->account->shipping_zipcode;
$shopping_user->shipping_city = $user->account->shipping_city;
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
$shopping_user->shipping_phone = $user->account->shipping_phone;
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
}else{
$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}
if($shopping_user->same_as_billing === NULL){
$shopping_user->same_as_billing = true;
}
@ -59,7 +95,7 @@ class CheckoutController extends Controller
public function checkoutFinal(){
/*
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
@ -86,7 +122,7 @@ class CheckoutController extends Controller
if ($validator->fails()) {
return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
}
*/
$data = Input::all();
//make User
@ -203,15 +239,16 @@ class CheckoutController extends Controller
$data = [
'key' => '698fb2555f8b2efc74f60b2121421f45',
'txaction' => 'appointed',
'clearingtype' => 'vor',
'userid' => '157787236',
'txid' => '319655873',
'price' => '13.80',
'param' => '6', //$this->shopping_order->id,
'reference' => '15c76c0d470cf9',
'txaction' => 'paid',
'clearingtype' => 'wlt',
'userid' => '158006846',
'txid' => '320267294',
'price' => '59.00',
'param' => '18', //$this->shopping_order->id,
'reference' => '15c79ba77992e2',
];
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
\Log::channel('payone')->error('PaymentStatus: parameter incomplete: '.json_encode($data));
abort(404);
@ -274,6 +311,28 @@ class CheckoutController extends Controller
if($data['txaction'] == 'paid'){
$shopping_order->paid = true;
$shopping_order->save();
//if product has actions
if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){
foreach($shopping_order->shopping_order_items as $shopping_order_item){
if($shopping_order_item->product){
if($shopping_order_item->product->action){
$user = User::findOrFail($shopping_order->auth_user_id);
foreach ($shopping_order_item->product->action as $do){
if($shopping_order_item->product->getActionName($do) == 'payment_for_account'){
$user->payment_account = date("Y-m-d H:i:s", strtotime("+1 years"));
$user->wizard = 10;
}
if($shopping_order_item->product->getActionName($do) == 'payment_for_shop'){
$user->payment_shop = date("Y-m-d H:i:s", strtotime("+1 years"));
$user->wizard = 10;
}
$user->save();
}
}
}
}
}
}
if($data['txaction'] == 'appointed'){
@ -321,6 +380,7 @@ class CheckoutController extends Controller
$data = [
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'user_shop_id' => $user_shop->id,
'total' => Yard::instance('shopping')->total(2, '.', ','),