News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Authorize.net How to handle currencies

Started by lineaweb, May 20, 2013, 18:35:22 PM

Previous topic - Next topic

lineaweb

Hello, I have VM 2.0 and I have an issue. I have 2 currencies (USD, COP=Colombian Peso) my shop have COP by default, so it means when my customer checkout the order amount send the wrong price to authorize, how can I convert any currency to USD before proceed with Authorize? E.g My product cost is 90.000 COP (45 USD) so Authorize receive 90.000 USD who is a highly amount, Could you please guide me how to achieve that? Thanks!

Mod edit:  impatient bump message removed.  http://forum.virtuemart.net/index.php?board=114.0

alatak

Hello

In function plgVmConfirmedOrder

add those lines before this line $formdata = array();

$payment_currency_id = shopFunctions::getCurrencyIDByName(self::AUTHORIZE_PAYMENT_CURRENCY);
$paymentCurrency = CurrencyDisplay::getInstance($payment_currency_id);
$totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo(self::AUTHORIZE_PAYMENT_CURRENCY, $order['details']['BT']->order_total, FALSE), 2);
$cd = CurrencyDisplay::getInstance($cart->pricesCurrency);


and then

replace this line
$formdata = array_merge($this->_setTransactionData($order['details']['BT'], $method), $formdata);

by
$formdata = array_merge($this->_setTransactionData($order['details']['BT'], $method, $totalInPaymentCurrency), $formdata);


finaly, replace the code of the function
by this code

function _setTransactionData ($orderDetails, $method, $totalInPaymentCurrency)
{

// backward compatible
if (isset($method->xtype)) {
$xtype = $method->xtype;
} else {
$xtype = 'AUTH_CAPTURE';
}
return array(
'x_amount' => $totalInPaymentCurrency,
'x_invoice_num' => $orderDetails->order_number,
'x_method' => 'CC',
'x_type' => $xtype,
'x_recurring_billing' => 0, //$this->_recurringPayment($params),
'x_card_num' => $this->_cc_number,
'x_card_code' => $this->_cc_cvv,
'x_exp_date' => $this->_getFormattedDate($this->_cc_expire_month, $this->_cc_expire_year)
);
}



i am adding this fix to the authorize plugin

lineaweb

Hi, thanks for sharing your solution, I tried it but an error appears when confirm the checkout, seems one constant is not defined.

Fatal error: Undefined class constant 'AUTHORIZE_PAYMENT_CURRENCY' in /home/maheflor/public_html/development/plugins/vmpayment/authorizenet/authorizenet.php on line 495

Thanks for your help!

alatak

Hello
yes sorry, i forgot that line:

please add after the line    
const HELD = 4;


const AUTHORIZE_PAYMENT_CURRENCY = "USD";

lineaweb

It works like a charm. Thank you so much, I really appreciate your help.  :)

alatak

Hello
Great :)
I have done the changes in the code.