I have a client with a big need for this, basically just see if another module has set a currency, if it has, for whatever business reason they have, use that currency instead of the default one
Heres what i am thinking roughly..
+ // See if the currency is not the default one for this order
+ if( isset($order->currency) ) {
+ $currency = $order->currency;
+ } else {
+ variable_get('uc_securepayau_currency', 'AUD');
+ }
+
$request = array(
'Payment' => array(
'TxnList count="1"' => array(
@@ -146,7 +153,7 @@ function _uc_securepayau_charge($order, $amount, $data) {
'txnType' => '0', // 0 = Standard Payment
'txnSource' => '23', // 23 = XML
'amount' => $amount*100, // amount takes a value in cents
- 'currency' => variable_get('uc_securepayau_currency', 'AUD'),
+ 'currency' => $currency,
'purchaseOrderNo' => $order->order_id,
'CreditCardInfo' => array(
'cardNumber' => $order->payment_details['cc_number'],
What do you think? Let me know if this is a good approach and I will submit a proper patch
Comments
Comment #1
univate commentedIsn't the securepay account tied to a specific currency?
Comment #2
dgtlmoon commentedNot if your register for this http://www.securepay.com.au/multi_currency_payments.html
Comment #3
univate commentedBut if you don't have that currency setup with your merchant account then you wont be able to process that currency - I assume it will fail if you send a currency that you are not setup to process. I have only used securepay with one currency setup per account.
We probably should be using the currency set in ubercart as default anyway and instead change this setting in securepay to be a multi-select option for the securepay enabled currencies. And then maybe we should fail at checkout if we try and checkout with a currency that is not been selected as supported.
Comment #4
dgtlmoon commentedCan we do that depending on the attributes of the items in their cart it will switch currencies, but this is just handled by passing the extra 6 lines into your securepay transaction module. (Who knows what people will base it on in the future, maybe they want to switch according to location of user or anything)
Comment #5
univate commentedActually where does the variable $order->currency come from or gets set? I don't think I have seen that in the $order object before.
The only place I can think of that a currency is declared by ubercart is in the variable: uc_currency_code
Comment #6
dgtlmoon commentedThat is set with the hook that ubercart passes around that allows you to set things in $order
Comment #7
dgtlmoon commentedActually I think the 'currency' that is handed across in the exchange should be set in whatever uc_currency_code is, as this is set as default in the order, this is what is inserted into the {uc_orders}.currency table
This way the currency in the transaction is tied to the currency in the uc_orders table which would make it a lot more easier to figure out what is happening with your transactions.
/** * Defines an order object. */ class UcOrder { ... public $currency = ''; function __construct() { $this->order_status = uc_order_state_default('in_checkout'); $this->currency = variable_get('uc_currency_code', 'USD'); } }The patch supplies allows you to select the currency that is in the UcOrder object (and in the database), or Override with AUD/USD (as per current behaviour)
This wont have any impact on existing users because it just allows you to select another option which is to use the order objects value as the currency in the exchange. (Which also allows me to grab onto hook_order where $op = 'new' and set my own currency for the transaction depending on whatever the site needs.