Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rpWelschlau committed Nov 12, 2014
1 parent bff86fe commit 7c3633f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions catalog/controller/payment/ratepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ private function _getRequestModel() {
$order = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$articles = $this->cart->getProducts();

$totalGross = $order['total'];
$totalNet = 0;

$requestModel = new PiRatepay_Paypage_Model_Request();

$requestModel->setProfileId($this->config->get('ratepay_profile_id'));
$requestModel->setSecurityCode($this->config->get('ratepay_security_code'));
$requestModel->setSuccessUrl($this->url->link('payment/ratepay/success&order_id=' . $order['order_id']));
$requestModel->setFailureUrl($this->url->link('payment/ratepay/failure'));
$requestModel->setOrderId($order['order_id']);
$requestModel->setTax(array_sum($this->cart->getTaxes()));

$basketModel = new PiRatepay_Paypage_Model_Basket($order['currency_code'], $order['total']);
$basketModel = new PiRatepay_Paypage_Model_Basket($order['currency_code'], $totalGross);
foreach ($articles as $article) {
$basketModel->addItem(
new PiRatepay_Paypage_Model_Item(
Expand All @@ -148,6 +150,7 @@ private function _getRequestModel() {
$this->_getTaxAmount($this->tax->getRates($article['price'], $article['tax_class_id'])) * $article['quantity']
)
);
$totalNet += $article['total'];

if (isset($this->session->data['coupon'])) {
$coupon = $this->model_checkout_coupon->getCoupon($this->session->data['coupon']);
Expand All @@ -159,10 +162,11 @@ private function _getRequestModel() {
$coupon['name'] . ": " . $article['name'],
$article['quantity'],
$discount,
(int) $article['quantity'] * $discount,
$discount * $article['quantity'],
0
)
);
$totalNet += $discount * $article['quantity'];
}
}
}
Expand All @@ -178,6 +182,7 @@ private function _getRequestModel() {
$this->_getTaxAmount($this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']))
)
);
$totalNet += $this->session->data['shipping_method']['cost'];
}

if (isset($this->session->data['coupon'])) {
Expand All @@ -194,6 +199,7 @@ private function _getRequestModel() {
0
)
);
$totalNet += $discount;
}
}

Expand All @@ -209,8 +215,11 @@ private function _getRequestModel() {
0
)
);
$totalNet -= $voucher['amount'];
}

$requestModel->setTax($totalGross - $totalNet);

$requestModel->setBasket($basketModel);

$merchantModel = new PiRatepay_Paypage_Model_Merchant();
Expand Down

0 comments on commit 7c3633f

Please sign in to comment.