23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Yard;
|
||||
|
|
@ -13,14 +14,16 @@ use App\Http\Controllers\Pay\PayoneController;
|
|||
class PaymentHelper
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function setProduct($product){
|
||||
|
||||
public function setProduct($product)
|
||||
{
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}
|
||||
|
||||
public function initELVPayment($user){
|
||||
public function initELVPayment($user)
|
||||
{
|
||||
|
||||
$shopping_user = $this->makeShoppingUser($user);
|
||||
$shopping_order = $this->makeShoppingOrder($user, $shopping_user);
|
||||
|
|
@ -41,7 +44,7 @@ class PaymentHelper
|
|||
$pay->setPersonalData();
|
||||
$response = $pay->onlyPaymentResponse();
|
||||
$shopping_payment = $pay->getShoppingPayment();
|
||||
if($response['status'] === 'ERROR'){
|
||||
if ($response['status'] === 'ERROR') {
|
||||
$payT = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
'request' => 'authorization',
|
||||
|
|
@ -51,9 +54,9 @@ class PaymentHelper
|
|||
'status' => $response['status'],
|
||||
'mode' => $shopping_payment->mode,
|
||||
]);
|
||||
UserHistory::create(['user_id'=>$user->id, 'shopping_order_id'=>$shopping_order->id, 'action'=>'abo_open_payment', 'referenz'=>$payT->id, 'identifier'=>$user->payment_account, 'status'=>3]);
|
||||
UserHistory::create(['user_id' => $user->id, 'shopping_order_id' => $shopping_order->id, 'action' => 'abo_open_payment', 'referenz' => $payT->id, 'identifier' => $user->payment_account, 'status' => 3]);
|
||||
}
|
||||
if($response['status'] === 'REDIRECT'){
|
||||
if ($response['status'] === 'REDIRECT') {
|
||||
$payT = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
'request' => 'authorization',
|
||||
|
|
@ -63,9 +66,9 @@ class PaymentHelper
|
|||
'mode' => $shopping_payment->mode,
|
||||
|
||||
]);
|
||||
UserHistory::create(['user_id'=>$user->id, 'shopping_order_id'=>$shopping_order->id, 'action'=>'abo_open_payment', 'referenz'=>$payT->id, 'identifier'=>$user->payment_account, 'status'=>4]);
|
||||
UserHistory::create(['user_id' => $user->id, 'shopping_order_id' => $shopping_order->id, 'action' => 'abo_open_payment', 'referenz' => $payT->id, 'identifier' => $user->payment_account, 'status' => 4]);
|
||||
}
|
||||
if($response['status'] === 'APPROVED'){
|
||||
if ($response['status'] === 'APPROVED') {
|
||||
$payT = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
'request' => 'authorization',
|
||||
|
|
@ -73,13 +76,14 @@ class PaymentHelper
|
|||
'userid' => $response['userid'],
|
||||
'status' => $response['status'],
|
||||
'transmitted_data' => $response,
|
||||
'mode' => $shopping_payment->mode
|
||||
]);
|
||||
UserHistory::create(['user_id'=>$user->id, 'shopping_order_id'=>$shopping_order->id, 'action'=>'abo_open_payment', 'referenz'=>$payT->id, 'identifier'=>$user->payment_account, 'status'=>5]);
|
||||
'mode' => $shopping_payment->mode
|
||||
]);
|
||||
UserHistory::create(['user_id' => $user->id, 'shopping_order_id' => $shopping_order->id, 'action' => 'abo_open_payment', 'referenz' => $payT->id, 'identifier' => $user->payment_account, 'status' => 5]);
|
||||
}
|
||||
}
|
||||
|
||||
public function makeShoppingUser($user, $is_from = 'membership', $is_for = 'me'){
|
||||
public function makeShoppingUser($user, $is_from = 'membership', $is_for = 'me')
|
||||
{
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->auth_user_id = $user->id;
|
||||
$shopping_user->mode = 'prev';
|
||||
|
|
@ -112,11 +116,13 @@ class PaymentHelper
|
|||
$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->shipping_postnumber = $user->account->shipping_postnumber;
|
||||
$shopping_user->save();
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function makeShoppingOrder($user, $shopping_user){
|
||||
|
||||
public function makeShoppingOrder($user, $shopping_user)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
|
|
@ -137,11 +143,11 @@ class PaymentHelper
|
|||
'txaction' => 'prev',
|
||||
'mode' => $user->test_mode ? 'test' : 'live',
|
||||
];
|
||||
|
||||
|
||||
$shopping_order = ShoppingOrder::create($data);
|
||||
$items = Yard::instance('shopping')->getContentByOrder();
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()) {
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
|
|
@ -165,6 +171,4 @@ class PaymentHelper
|
|||
$shopping_order->makeTaxSplit();
|
||||
return $shopping_order;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue