membership register

This commit is contained in:
Kevin Adametz 2020-02-15 14:53:32 +01:00
parent 3711fcc8d0
commit 37cb2b06c7
38 changed files with 1261 additions and 463 deletions

View file

@ -93,6 +93,15 @@ class PayoneController extends Controller
die();
}
/* TODO -- need this?
if($shopping_payment->txaction == $data['txaction']){
\Log::channel('payone')->error('PaymentStatus: same txaction error: '.json_encode($data));
echo "PaymentStatus: same txaction:";
var_dump($data);
die();
}
*/
//create transaction
PaymentTransaction::create([
'shopping_payment_id' => $shopping_payment->id,
@ -110,13 +119,15 @@ class PayoneController extends Controller
$shopping_payment->txaction = $data['txaction'];
$shopping_payment->save();
if($data['txaction'] == 'failed'){
$send_link = false;
if($data['txaction'] === 'failed'){
}
if($data['txaction'] == 'paid'){
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){
@ -124,14 +135,18 @@ class PayoneController extends Controller
if($shopping_order_item->product->action){
$user = User::findOrFail($shopping_order->auth_user_id);
$user->payment_order_id = $shopping_order_item->product->id;
$user->save();
$send_link = true;
$date = date("Y-m-d H:i:s", strtotime("+1 years"));
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;
$user->payment_account = $date;
$user->wizard = 100;
}
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->payment_shop = $date;
$user->wizard = 100;
}
$user->save();
}
@ -141,7 +156,7 @@ class PayoneController extends Controller
}
}
if($data['txaction'] == 'appointed'){
if($data['txaction'] === 'appointed'){
}
@ -152,9 +167,9 @@ class PayoneController extends Controller
}
$checkout_mail = config('app.checkout_mail');
if($user_shop_email){
Mail::to($billing_email)->bcc([$user_shop_email, $checkout_mail])->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment));
Mail::to($billing_email)->bcc([$user_shop_email, $checkout_mail])->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link));
}else{
Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment));
Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link));
}
print("TSOK");

View file

@ -32,14 +32,15 @@ class HomeController extends Controller
}
//login
//login / Dashboard
public function show()
{
if(!Auth::check()){
return redirect('login');
return redirect('login');
}
$data = [
'user' => Auth::user(),
'now' => Carbon::now(),
];
return view('home', $data);
}
@ -226,15 +227,16 @@ class HomeController extends Controller
$ShoppingPayment = ShoppingPayment::where('reference', $reference)->first();
if($ShoppingPayment && $ShoppingPayment->status === 'success'){
$user = Auth::user();
if($user && $user->wizard < 4){
$user->wizard = 4;
$user->save();
return redirect(route('wizard', [4]));
//is form wizard create payment
if($user && ($user->wizard == 13 || $user->wizard == 20)){
$user->wizard = 15; //realese Payments
$user->save();
return redirect(route('wizard_create', [15]));
}
}else{
\Session()->flash('alert-error', "Es ist ein Fehler bei der Bestellung aufgetreten");
return redirect(route('wizard'));
return redirect(route('/'));
}
}

View file

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\ShoppingPayment;
use App\User;
use Auth;
use Carbon\Carbon;
use Config;
use Request;
use Input;
use Util;
use Yard;
class MembershipController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$user = Auth::user();
$data = [
'user' => $user,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'upgrade' => Product::where('active', true)->where('show_at', '=', 4)->where('identifier', 'upgrade')->get(),
];
return view('user.membership.index', $data);
}
public function storePayment($step = 0){
if(Input::get('switchers-package-wizard')){
$user = Auth::user();
Yard::instance('shopping')->destroy();
$product = Product::find(Input::get('switchers-package-wizard'));
if(Input::get('abo_options')){
$user->abo_options = true;
$user->save();
}
if($product && $product->active && $product->show_at >= 3){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
$qty = Input::get('qty') ? Input::get('qty') : 1;
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop!
'auth_user_id' => Auth::user()->id,
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
}
\Session()->flash('alert-error', "Fehler beim Produkt");
return back();
}
}

View file

@ -68,7 +68,6 @@ class PayoneController extends Controller
$this->default = \Config::get('payone.defaults');
}
public function init($shopping_user, $shopping_order){
$this->shopping_user = $shopping_user;
$this->shopping_order = $shopping_order;
@ -81,7 +80,7 @@ class PayoneController extends Controller
//make Payone payment
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
$this->reference = substr(uniqid(true), 0, 16);
$this->reference = substr(uniqid('m', false), 0, 16);
$this->setMethod($payment_method, $ret);
$this->urls = [
@ -342,10 +341,8 @@ class PayoneController extends Controller
];
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
// dd($request);
return Payone::sendRequest($request);
}

View file

@ -21,15 +21,13 @@ class UserShopController extends Controller
public function __construct(UserRepository $userRepo)
{
$this->middleware('auth');
$this->middleware('active.shop');
$this->userRepo = $userRepo;
}
public function index()
{
$user = Auth::user();
if ($user->shop && !$user->shop->set_defaults) {
if ($user->account) {
$user->shop->title = $user->account->first_name . " " . $user->account->last_name;

View file

@ -10,6 +10,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 Validator;
@ -43,12 +44,9 @@ class CheckoutController extends Controller
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
// $selected_country = $ShippingCountry->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;
@ -74,6 +72,7 @@ class CheckoutController extends Controller
$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->abo_options = $user->abo_options;
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
@ -200,6 +199,9 @@ class CheckoutController extends Controller
$ret['elv']['iban'] = $data['elv_iban'];
$ret['elv']['bic'] = $data['elv_bic'];
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
//check abo and save the mandate
$this->storeUserPaymentsData($shopping_user, $ret);
}
//other
$pay = new PayoneController();
@ -271,6 +273,18 @@ class CheckoutController extends Controller
return view('web.templates.checkout-final', $data);
}
private function storeUserPaymentsData($shopping_user, $ret){
if($shopping_user->auth_user_id){
$user = User::find($shopping_user->auth_user_id);
if($user && $user->account && $user->abo_options){
if(isset($ret['elv']) && is_array($ret['elv'])){
$user->account->payment_data = $ret['elv'];
$user->account->save();
}
}
}
}
private function makeShoppingUser($data){
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
@ -365,6 +379,7 @@ class CheckoutController extends Controller
$this->session->put($this->instance, $content);
}
private function getPayments($key){
$content = $this->getContent();
if ($content->has($key)){
@ -372,6 +387,7 @@ class CheckoutController extends Controller
}
return false;
}
private function getContent()
{
if (is_null($this->session->get($this->instance))) {
@ -380,7 +396,6 @@ class CheckoutController extends Controller
return $this->session->get($this->instance);
}
public function destroy()
{
$this->session->remove($this->instance);

View file

@ -36,7 +36,6 @@ class WizardController extends Controller
public function create()
{
if(!Auth::check()){
return redirect('login');
}
@ -46,11 +45,12 @@ class WizardController extends Controller
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard'));
return redirect(route('wizard_create'));
}
$step = !$user->wizard ? 0 : $user->wizard;
if($step == 10){
if($step >= 20){
return redirect('/');
}
$data = [
@ -59,6 +59,10 @@ class WizardController extends Controller
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
];
if($step == 15){
return view('user.wizard.create_release', $data);
}
return view('user.wizard.create', $data);
}
@ -73,12 +77,12 @@ class WizardController extends Controller
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard'));
return redirect(route('wizard_register'));
}
$step = !$user->wizard ? 0 : $user->wizard;
if($step == 10){
if($step >= 10){
return redirect('/');
}
$data = [
@ -93,6 +97,33 @@ class WizardController extends Controller
return view('user.wizard.register', $data);
}
public function payment()
{
if(!Auth::check()){
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard_payment'));
}
$data = [
'user' => Auth::user(),
'step' => 0,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
];
if($user->wizard == 20){
return view('user.wizard.register_payment', $data);
}
return redirect(route('/'));
}
public function storeRegister($step = false)
{
@ -235,7 +266,7 @@ class WizardController extends Controller
$user->account = new UserAccount();
}
if($step == 0){
if($step == 10){
$rules = array(
'accepted_data_protection' => 'required',
'accepted_active' => 'required',
@ -245,33 +276,33 @@ class WizardController extends Controller
$data = [
'user' => Auth::user(),
'step' => $step,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
];
return view('user.wizard.show', $data)->withErrors($validator);
$user->wizard = 10;
$user->save();
return view('user.wizard.create', $data)->withErrors($validator);
}
$account = $user->account;
$account->data_protection = now();
if($account->data_protection === null){
$account->data_protection = now();
}
if($user->agreement === null){
$user->agreement = now();
}
$account->save();
$user->agreement = now();
if($user->wizard < 1){
$user->wizard = 1;
}
$user->wizard = 11;
$user->save();
return redirect(route('wizard', [1]));
return redirect(route('wizard_create', [11]));
}
if($step == 1){
if($step == 11){
if($user->isPasswort()){
if($user->wizard < 2){
$user->wizard = 2;
}
//has Passwort -> delete Code!
$user->confirmation_code = null;
$user->confirmation_code_to = null;
$user->confirmation_code_remider = 0;
$user->wizard = 12;
$user->save();
return redirect(route('wizard', [2]));
return redirect(route('wizard_create', [12]));
}
$rules = array(
'password' => 'required|string|min:6|confirmed',
@ -281,34 +312,31 @@ class WizardController extends Controller
$data = [
'user' => Auth::user(),
'step' => $step,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
];
return view('user.wizard.show', $data)->withErrors($validator);
}else{
$user->fill([
'password' => Hash::make(Input::get('password'))
])->save();
if($user->wizard < 2){
$user->wizard = 2;
}
//has Passwort -> delete Code!
$user->confirmation_code = null;
$user->confirmation_code_to = null;
$user->confirmation_code_remider = 0;
$user->save();
return redirect(route('wizard', [2]));
return view('user.wizard.create', $data)->withErrors($validator);
}
$user->fill([
'password' => Hash::make(Input::get('password'))
])->save();
$user->wizard = 12;
$user->save();
return redirect(route('wizard_create', [12]));
}
if($step == 2){
if($step == 12){
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'address'=>'required',
'zipcode'=>'required',
'first_name' => 'required',
'last_name' => 'required',
'address' => 'required',
'zipcode' => 'required',
'city' => 'required',
'phone' => 'required_without:mobil',
'mobil' => 'required_without:phone',
'country_id' => 'required|integer|min:1',
'birthday' => 'required',
);
if(!Input::get('same_as_billing')){
@ -324,63 +352,65 @@ class WizardController extends Controller
}
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return redirect(route('wizard', [2]))->withErrors($validator)->withInput(Input::all());
}else{
$data = Input::all();
$data['same_as_billing'] = Input::get('same_as_billing') == NULL ? 0 : 1;
$user->account->fill($data)->save();
if($user->wizard < 3){
$user->wizard = 3;
}
$user->active_date = now();
$user->active = 1;
$user->save();
return redirect(route('wizard', [3]));
return redirect(route('wizard_create', [12]))->withErrors($validator)->withInput(Input::all());
}
}
if($step == 3){
$data = Input::all();
$data['same_as_billing'] = Input::get('same_as_billing') == NULL ? 0 : 1;
$user->account->fill($data)->save();
$user->wizard = 13;
$user->active_date = now();
$user->active = 1;
$user->confirmation_code = null;
$user->confirmation_code_to = null;
$user->confirmation_code_remider = 0;
$user->save();
return redirect(route('wizard_create', [13]));
if(Input::get('switchers-package-wizard')){
Yard::instance('shopping')->destroy();
$product = Product::find(Input::get('switchers-package-wizard'));
if($product && $product->active && $product->show_at == 3){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop!
'auth_user_id' => $user->id,
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
}
\Session()->flash('alert-error', "Fehler beim Produkt");
return redirect(route('wizard', [3]));
}
}
public function storePayment($step = 0){
if(Input::get('switchers-package-wizard')){
$user = Auth::user();
Yard::instance('shopping')->destroy();
$product = Product::find(Input::get('switchers-package-wizard'));
if(Input::get('abo_options')){
$user->abo_options = true;
$user->save();
}
if($product && $product->active && $product->show_at == 3){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop!
'auth_user_id' => Auth::user()->id,
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
}
\Session()->flash('alert-error', "Fehler beim Produkt");
return back();
}
public function delete($id, $relation){