Skip to content
Code-Schnipsel Gruppen Projekte
Commit 25652e20 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: Order Proces complete Test -> gateway payments and none gateway payments

Übergeordneter 2b1d212c
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -13,9 +13,8 @@
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_frontend_order_getNext',
function ($orderId, $current, $orderHash) {
function ($current, $orderHash) {
$OrderProcess = new QUI\ERP\Order\OrderProcess([
'orderId' => (int)$orderId,
'orderHash' => $orderHash,
'step' => $current
]);
......@@ -39,5 +38,5 @@ function ($orderId, $current, $orderHash) {
'hash' => $OrderProcess->getStepHash()
];
},
['orderId', 'current', 'orderHash']
['current', 'orderHash']
);
......@@ -14,7 +14,7 @@
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_frontend_order_saveCurrentStep',
function ($orderId, $step, $data, $orderHash) {
function ($step, $data, $orderHash) {
$data = json_decode($data, true);
unset($_REQUEST['data']);
......@@ -26,12 +26,11 @@ function ($orderId, $step, $data, $orderHash) {
$_REQUEST['current'] = $step;
$Ordering = new QUI\ERP\Order\OrderProcess([
'orderId' => (int)$orderId,
'orderHash' => $orderHash
]);
$Step = $Ordering->getCurrentStep();
$Step->save();
},
['orderId', 'step', 'data', 'orderHash']
['step', 'data', 'orderHash']
);
......@@ -13,12 +13,11 @@
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_frontend_order_send',
function ($orderId, $current, $orderHash) {
function ($current, $orderHash) {
$_REQUEST['current'] = $current;
$_REQUEST['payableToOrder'] = true;
$OrderProcess = new QUI\ERP\Order\OrderProcess([
'orderId' => (int)$orderId,
'orderHash' => $orderHash,
'step' => $current
]);
......@@ -37,5 +36,5 @@ function ($orderId, $current, $orderHash) {
'hash' => $OrderProcess->getStepHash()
];
},
['orderId', 'current', 'orderHash']
['current', 'orderHash']
);
......@@ -510,14 +510,21 @@ define('package/quiqqer/order/bin/frontend/controls/OrderProcess', [
this.setAttribute('current', result.step);
if ("hash" in result && result.hash !== '') {
this.setAttribute('orderHash', result.hash);
}
// content
var Error = Ghost.getElement('.quiqqer-order-ordering-error');
var StepContent = Ghost.getElement('.quiqqer-order-ordering-step');
var TimeLine = Ghost.getElement('.quiqqer-order-ordering-timeline');
var Form = Ghost.getElement('[name="order"]');
if (Form) {
this.$Form.set('data-order-hash', Form.get('data-order-hash'));
this.$Form.set('data-products-count', Form.get('data-products-count'));
this.setAttribute('orderHash', Form.get('data-order-hash'));
}
if ("hash" in result && result.hash !== '') {
this.setAttribute('orderHash', result.hash);
}
if (TimeLine) {
// refresh the timeline
......
......@@ -11,7 +11,6 @@
/**
* Class BasketOrder
* Coordinates the order process, (order -> payment -> invoice)
*
* This is a helper to represent an already send order for the order process
*
......
......@@ -3,14 +3,14 @@
action=""
method="post"
data-products-count="{if $Order}{$Order->count()}{/if}"
data-order-hash="{$this->getAttribute('orderHash')}"
data-order-hash="{$hash}"
>
{else}
<div name="order"
data-action=""
data-method="post"
data-products-count="{if $Order}{$Order->count()}{/if}"
data-order-hash="{$this->getAttribute('orderHash')}"
data-order-hash="{$hash}"
>
{/if}
<div class="quiqqer-order-ordering-timeline">
......@@ -23,7 +23,7 @@
{assign var=cssClass value="current"}
{/if}
{assign var=cssProcessingClass value=""}
{if $CurrentStep->getName() === 'Processing'}
{if $CurrentStep->getName() === 'Processing' || $CurrentStep->getName() === 'Finish'}
{assign var=cssProcessingClass value=" disabled"}
{/if}
......
......@@ -86,24 +86,6 @@ public function getBody()
$Articles = $Order->getArticles()->toUniqueList();
$Articles->hideHeader();
if (QUI::getSession()->get('termsAndConditions-'.$Order->getHash())
&& $Order->getDataEntry('orderedWithCosts') == 1) {
$Payment = $Order->getPayment();
$payment = $Order->getDataEntry('orderedWithCostsPayment');
//
// if ($payment == $Payment->getId() && $Payment->getPaymentType()->isGateway()) {
//
// QUI\System\Log::writeRecursive($Payment);
// QUI\System\Log::writeRecursive($Payment->getPaymentType());
//
// $Engine->assign('Gateway', $Payment->getPaymentType());
// $Engine->assign(
// 'gatewayDisplay',
// $Payment->getPaymentType()->getGatewayDisplay($Order, new Processing())
// );
// }
}
$text = QUI::getLocale()->get(
'quiqqer/order',
'ordering.step.checkout.checkoutAcceptText',
......
......@@ -304,6 +304,10 @@ public function createOrder($PermissionUser = null)
$data['paid_data'] = $this->getAttribute('paid_data');
$data['successful'] = $this->successful;
if (empty($data['paid_date'])) {
$data['paid_date'] = null;
}
QUI::getDataBase()->update(
Handler::getInstance()->table(),
$data,
......@@ -328,6 +332,7 @@ public function createOrder($PermissionUser = null)
if ($Payment->isSuccessful($Order->getHash())) {
$Order->setSuccessfulStatus();
$this->setSuccessfulStatus();
}
// create invoice?
......
......@@ -253,9 +253,12 @@ protected function send()
// all runs fine
// @todo Vorgehen bei gescheiterter Zahlung -> only at failedPaymentProcedure = execute
$OrderInProcess->createOrder();
$Order = $OrderInProcess->createOrder();
$OrderInProcess->delete();
$this->Order = $Order;
$this->setAttribute('orderHash', $Order->getHash());
$this->setAttribute('current', 'finish');
$this->setAttribute('step', 'finish');
......@@ -275,10 +278,21 @@ protected function cleanup()
return;
}
// if temp order exist, kill it
// if temp order exist, and a normal order kill it
try {
$Order = Handler::getInstance()->getOrderInProcessByHash($this->Order->getHash());
$Order->delete();
$ProcessOrder = Handler::getInstance()->getOrderInProcessByHash(
$this->Order->getHash()
);
$Order = Handler::getInstance()->getOrderByHash(
$ProcessOrder->getHash()
);
if ($Order instanceof Order) {
$ProcessOrder->delete();
}
$this->Order = $Order;
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
}
......@@ -345,7 +359,8 @@ protected function executePayableStatus()
'CurrentStep' => $ProcessingStep,
'currentStepContent' => QUI\ControlUtils::parse($ProcessingStep),
'Site' => $this->getSite(),
'Order' => $this->getOrder()
'Order' => $this->getOrder(),
'hash' => $this->getStepHash()
]);
return QUI\Output::getInstance()->parse($Engine->fetch($template));
......@@ -362,7 +377,8 @@ protected function executePayableStatus()
'CurrentStep' => $this->getCurrentStep(),
'currentStepContent' => QUI\ControlUtils::parse($this->getCurrentStep()),
'Site' => $this->getSite(),
'Order' => $this->getOrder()
'Order' => $this->getOrder(),
'hash' => $this->getStepHash()
]);
return QUI\Output::getInstance()->parse($Engine->fetch($template));
......@@ -403,7 +419,6 @@ public function getBody()
return $this->renderFinish();
}
// check all previous steps
// is one invalid, go to them
foreach ($steps as $name => $Step) {
......@@ -498,7 +513,8 @@ public function getBody()
'CurrentStep' => $Current,
'currentStepContent' => QUI\ControlUtils::parse($Current),
'Site' => $this->getSite(),
'Order' => $this->getOrder()
'Order' => $this->getOrder(),
'hash' => $this->getStepHash()
]);
$this->Events->fireEvent('getBody', [$this]);
......@@ -551,7 +567,7 @@ protected function checkProcessing()
}));
$render = function () {
$render = function () use ($Order, $Finish, &$Current) {
// show processing step
$Processing = new Controls\OrderProcess\Processing([
'Order' => $this->getOrder(),
......@@ -560,6 +576,21 @@ protected function checkProcessing()
$this->setAttribute('step', $Processing->getName());
$Payment = $Order->getPayment();
if ($Payment->getPaymentType()->isGateway() === false) {
$this->setAttribute('step', $Finish->getName());
$Current = $Finish;
try {
$this->send();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
return false;
}
// rearrange the steps, insert the processing step
$Steps = $this->parseSteps();
$Steps->append($Processing);
......@@ -625,10 +656,11 @@ protected function renderFinish()
'previous' => false,
'payableToOrder' => false,
'steps' => $this->getSteps(),
'CurrentStep' => $this->getCurrentStep(),
'currentStepContent' => QUI\ControlUtils::parse($this->getCurrentStep()),
'CurrentStep' => $this->getLastStep(),
'currentStepContent' => QUI\ControlUtils::parse($this->getLastStep()),
'Site' => $this->getSite(),
'Order' => $this->getOrder()
'Order' => $this->getOrder(),
'hash' => $this->getStepHash()
]);
$this->Events->fireEvent('getBody', [$this]);
......@@ -678,6 +710,19 @@ public function getFirstStep()
return array_values($this->getSteps())[0];
}
/**
* @return mixed
* @throws Basket\Exception
* @throws Exception
* @throws QUI\Exception
*/
public function getLastStep()
{
$steps = array_values($this->getSteps());
return $steps[count($steps) - 1];
}
/**
* Return the next step
*
......@@ -715,6 +760,7 @@ public function getNextStep($StartStep = null)
// if order are successful -> then show the finish step
if ($Order->isSuccessful()) {
$this->setAttribute('orderHash', $Order->getHash());
$this->cleanup();
return new Controls\OrderProcess\Finish([
'Order' => $Order
......
......@@ -304,8 +304,6 @@ protected function executeQueryParams($queryData = [])
/**
* @param array $data
* @return array
*
* @throws QUI\ERP\Order\Exception
*/
protected function parseListForGrid($data)
{
......@@ -407,7 +405,13 @@ protected function parseListForGrid($data)
}
// articles
$calculations = $Order->getArticles()->getCalculations();
try {
$calculations = $Order->getArticles()->getCalculations();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
continue;
}
$vatSum = array_map(function ($data) {
if (!isset($data['sum'])) {
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren