Skip to content

Commit

Permalink
create new sveaorder if unable to find reference to the sveaorder
Browse files Browse the repository at this point in the history
  • Loading branch information
iesus committed Oct 3, 2019
1 parent cf10329 commit fcf9691
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public function indexAction()
Mage::app()->setCurrentStore($storeId);
$svea->setQuote($quote)->setLocales($sveaOrder, $quote);
$orderId = $quote->getPaymentReference();

if (!$orderId) {
$svea = Mage::getModel('sveacheckout/Checkout_Api_BuildOrder');
$sveaOrder = $svea->createSveaOrderFromQuote($quote);
$response = $sveaOrder->createOrder();
$orderId = $response['OrderId'];
$quote->setPaymentReference($orderId)->save();
}

} catch (Exception $ex) {

return $this->reportAndReturn(207, $quoteId . ' : ' . $ex->getMessage());
Expand All @@ -59,13 +68,11 @@ public function indexAction()

$responseObject = new Varien_Object($response);


if (!($quote->getPayment()->getMethod())) {
$payment = $quote->getPayment();
$payment->setMethod('sveacheckout');
}


$createdOrder = Mage::getModel('sveacheckout/Payment_CreateOrder')
->createOrder($quote, $responseObject, $orderQueueItem);

Expand Down

0 comments on commit fcf9691

Please sign in to comment.