Payone, Shop, wizard

This commit is contained in:
Kevin Adametz 2019-03-04 17:05:44 +01:00
parent 446bc4561b
commit 044a6bf253
28 changed files with 996 additions and 814 deletions

View file

@ -35,6 +35,8 @@ class CardController extends Controller
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
}
@ -54,6 +56,8 @@ class CardController extends Controller
}
$quantity = Input::get('quantity') ? Input::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();
\Session()->flash('show-card-after-add', true);
}
return back();
@ -66,8 +70,7 @@ class CardController extends Controller
if(Input::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Input::get('selected_country'));
}else{
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
// $selected_country = $ShippingCountry->id;
Yard::instance('shopping')->reCalculateShippingPrice();
}
$data = [
'user_shop' => Util::getUserShop(),
@ -81,6 +84,7 @@ class CardController extends Controller
if(isset($data['quantity'])){
foreach ($data['quantity'] as $rowId => $qty){
Yard::instance('shopping')->update($rowId, $qty);
Yard::instance('shopping')->reCalculateShippingPrice();
}
}else{
$this->deleteCard();

View file

@ -5,16 +5,13 @@ namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Pay\PayoneController;
use App\Mail\MailCheckout;
use App\Models\PaymentTransaction;
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;
use Validator;
use App\Services\Util;
use Yard;
@ -167,7 +164,7 @@ class CheckoutController extends Controller
$amount = intval(floatval(Yard::instance('shopping')->totalWithShipping(2, '.', ',')) *100);
$reference = $pay->setPrePayment(Input::get('payment_method'), $amount, 'EUR', $cc_ret);
$this->putPayments('payment_reference', $reference);
$pay->setPersonalData([]);
$pay->setPersonalData();
return $pay->ResponseData();
}
@ -231,127 +228,6 @@ class CheckoutController extends Controller
return view('web.templates.checkout-final', $data);
}
public function paymentStatus(){
$data = \Request::all();
// test para
$data = [
'key' => '698fb2555f8b2efc74f60b2121421f45',
'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);
}
if($data['key'] != config('payone.defaults.key')) {
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
abort(404);
}
$shopping_order = ShoppingOrder::find($data['param']);
if(!$shopping_order){
\Log::channel('payone')->error('PaymentStatus: ShoppingOrder not found: '.json_encode($data));
abort(404);
}
$shopping_payment = ShoppingPayment::where('reference', $data['reference'])->first();
if(!$shopping_payment){
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment not found: '.json_encode($data));
abort(404);
}
if($shopping_payment->shopping_order_id != $shopping_order->id){
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment no realation ShoppingOrder: '.json_encode($data));
abort(404);
}
if($data['key'] != config('payone.defaults.key')) {
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
abort(404);
}
$price = intval($data['price']*100);
if($shopping_payment->amount != $price){
\Log::channel('payone')->error('PaymentStatus: Price error: '.json_encode($data));
abort(404);
}
//create transaction
PaymentTransaction::create([
'shopping_payment_id' => $shopping_payment->id,
'request' => 'transaction',
'txid' => $data['txid'],
'userid' => $data['userid'],
'status' => 'PAYONE',
'key' => $data['key'],
'txaction' => $data['txaction'],
'transmitted_data' => $data,
]);
$shopping_order->txaction = $data['txaction'];
$shopping_order->save();
$shopping_payment->txaction = $data['txaction'];
$shopping_payment->save();
if($data['txaction'] == 'failed'){
}
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'){
}
$billing_email = $shopping_order->shopping_user->billing_email;
$user_shop_email = $shopping_order->user_shop->user->email;
if(!$billing_email){
$billing_email = config('app.checkout_mail');
}
$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));
}else{
Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment));
}
die("ok");
}
private function makeShoppingUser($data){
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;

View file

@ -33,6 +33,9 @@ class SiteController extends Controller
return view('web.index', $data);
}
public function domainCheck(){
die("checked");
}
public function site($site, $subsite = false, $product_slug = false)
{