Skip to content

Commit

Permalink
fix wrong amount
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-galas committed Oct 27, 2015
1 parent d35fd24 commit 138e5cd
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions payment_dotpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ public function _prePayment( $data ) {
$vars = new JObject();
$info = $this->getOrderInformation($data);

$order = $this->getOrderByPayment($data['orderpayment_id']);
$currency_values= $this->getCurrency($order);


//Needed for Dotpay
$vars->id = $this->params->get('accountId');
$vars->amount = $data['orderpayment_amount'];
$vars->currency = $data['order']->currency_code;
$vars->amount = $this->getAmount($order);
$vars->currency = $currency_values['currency_code'];
$vars->description = JText::_('J2STORE_PLUGIN_DOTPAY_ORDER') . $data['order_id'];
$vars->lang = $this->getLanguage();
$vars->api_version = $this->_default['api_version'];
Expand Down Expand Up @@ -227,6 +231,11 @@ private function setCompleteStatus($orderId)
$this->save($order);
}

private function getAmount($order)
{
$currency_values= $this->getCurrency($order);
return J2Store::currency()->format($order->order_total, $currency_values['currency_code'], $currency_values['currency_value'], false);
}

/**
* This method change order status. Status is defined as $order_state_id
Expand Down Expand Up @@ -275,6 +284,14 @@ private function getOrder($orderId)
return $order;
}

private function getOrderByPayment($paymentId)
{
F0FTable::addIncludePath ( JPATH_ADMINISTRATOR . '/components/com_j2store/tables' );
$order = F0FTable::getInstance ( 'Order', 'J2StoreTable' );
$order->load($paymentId);
return $order;
}

/**
* Based on status set error or ok message displaying to customer
*
Expand Down Expand Up @@ -323,7 +340,7 @@ private function getOrderInformation( $data ) {
private function getPrice($order_id) {
$order = $this->getOrder($order_id);
if($order){
return $order->order_total;
return $this->getAmount($order);
}
return 0;
}
Expand Down

0 comments on commit 138e5cd

Please sign in to comment.