Skip to content

Commit

Permalink
Fixed quantity of ordered products
Browse files Browse the repository at this point in the history
  • Loading branch information
openpayu committed Jan 23, 2014
1 parent 8258760 commit 2c26f36
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/code/local/PayU/Account/Model/Payment.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* ver. 1.8.1
* ver. 1.8.0
* PayU -Standard Payment Model
*
* @copyright Copyright (c) 2011-2012 PayU
Expand Down Expand Up @@ -193,7 +193,11 @@ public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRa
)
);
}

}

$grandTotal = $this->_order->getGrandTotal() - $this->_order->getShippingAmount();

} else {
// assigning the shipping costs list
foreach ($allShippingRates as $rate) {
Expand All @@ -211,6 +215,8 @@ public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRa
)
);
}

$grandTotal = $this->_order->getGrandTotal();
}

$shippingCost = array(
Expand All @@ -225,14 +231,14 @@ public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRa

/** @var array Here is where order items will be processed for PayU purposes */
$items = array();
$productsTotal = 0;

foreach ($orderItems as $key => $item) {
/** @var array Retrieving item info */
$itemInfo = $item->getData();

// Check if the item is countable one
if ($this->toAmount($itemInfo['price_incl_tax']) > 0) {

/** Pushing the current item to ShoppingCarItems list */
$items[]['ShoppingCartItem'] = array(
'Quantity' => (int)$itemInfo['qty_ordered'],
Expand All @@ -247,12 +253,15 @@ public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRa
)
)
);
$productsTotal += $itemInfo['price_incl_tax'] * $itemInfo['qty_ordered'];
}
}

$grandTotal = $productsTotal;

// assigning the shopping cart
$shoppingCart = array(
'GrandTotal' => $this->toAmount(Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal()),
'GrandTotal' => $this->toAmount($grandTotal),
'CurrencyCode' => $orderCurrencyCode,
'ShoppingCartItems' => $items
);
Expand Down Expand Up @@ -1115,13 +1124,10 @@ public function updatePaymentStatusCompleted($payment)
$transaction = $payment->setTransactionId($this->_transactionId);
$transaction->setPreparedMessage("PayU - " . Mage::helper('payu_account')->__('The transaction completed successfully.'));

if(intval(Mage::getStoreConfig('payment/payu_account/selfreturn')))
{
$payment->setIsTransactionApproved(true);
$payment->setIsTransactionClosed(true);
}
$payment->setIsTransactionApproved(true);
$payment->setIsTransactionClosed(true);

$comment = $this->_order->setState((intval(Mage::getStoreConfig('payment/payu_account/selfreturn'))) ? Mage_Sales_Model_Order::STATE_PROCESSING : Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, "PayU - " . Mage::helper('payu_account')->__('The transaction completed successfully.'), false)
$comment = $this->_order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, "PayU - " . Mage::helper('payu_account')->__('The transaction completed successfully.'), false)
->sendOrderUpdateEmail(true, "PayU - " . Mage::helper('payu_account')->__('Thank you.') . " " . Mage::helper('payu_account')->__('The transaction completed successfully.'))
->save();
$transaction->save();
Expand Down

0 comments on commit 2c26f36

Please sign in to comment.