Payone, Shop, wizard
This commit is contained in:
parent
446bc4561b
commit
044a6bf253
28 changed files with 996 additions and 814 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue