I'm currently working on a new payment gateway for Realex but it requires that the transaction currency be set in the message sent in the request. I can't seem to find any way to submit the currency to the payment gateway handler, at least not yet. I can see how pay_forms do it (though not sure if you can have more than one currency per form), but don't see how it gets to the gateway. Any pointers on this?

CommentFileSizeAuthor
#3 pay.932666_02.patch2.05 KBsgabe
#2 pay.932666_01.patch1.22 KBsgabe

Comments

allie micka’s picture

Status: Active » Needs work

Hi Stella,

Not much has been done here, but I'm open to ideas and patches! Here's what I can tell you:

  • There's a 3-character 'currency' on the pay_form table (though arguably there's no 1:1 relationship for payment forms and their currencies)
  • There's also a 3-character 'currency' field for pay_transaction entries
  • There's theoretical support for currencies in the theming / display by way of theme('pay_money')

That's pretty much it, I'm afraid; with no currency info supplied to any UI's or acted against in any meaningful way. What else would you expect from a U.S. citizen? ;)

Here's what likely should happen:

  • A simple list of currencies should exist in an api function somewhere (E.g. a name => label array containing the 3-digit code and its text label)
  • Each pay_form entry should allow one - or ideally more - currencies
  • Each pay_method handler, and thus pay_method instance should similarly allow one or more currencies
  • When a visitor goes to make a payment against a pay_form, she chooses her currency (assuming there's >1 currency for both the form and available methods for that form, otherwise the choice is made for her)
  • The visitor may then choose the available payment method(s) for that form+currency (again, selecting for her if it's just the one)
  • The resulting currency selection gets passed through to the gatway

Thus you could use multiple currencies on a site - by way of a single form, or through selected currencies on the same form. The gateway and thus payment methods should handle processing accordingly.

The next challenge to solve would be views support and calculations - as each transaction would be a combination of currency+amount, 'totals' on reports for multi-currency forms would be off. Optional support for the Currency module and some crafty views handling would help.

sgabe’s picture

StatusFileSize
new1.22 KB

For a start what about a pay_currency_list() function in the pay_form class which uses currency_api_get_list() when Currency API is available? By default we can provide the most used currencies, so Currency API won't be a requirement. I think something like this should be the first step.

sgabe’s picture

Title: multiple currencies » Support for multiple currencies
Version: 6.x-1.0-alpha5 » 6.x-1.0-alpha6
Status: Needs work » Needs review
StatusFileSize
new2.05 KB

Also something similar in theme_pay_money().

restyler’s picture

That is definitely a key feature. Subscribing.

univate’s picture

This patch looks good. Although it doesn't seem to work with webform_pay though. No currency is showing up.

allie micka’s picture

Category: support » feature
Status: Needs review » Active

I'm very concerned about allowing the user to specify a currency on a per-form basis without implementing some sort of exchange/tracking/other business rules. For example, if a site administrator implements multiple forms - each with a different currency - then all of the summaries, charts and total amounts get all wonky. So as of right now, I'm not going to implement per-transaction or per-form currency.

However, what we can do is create a temporary solution while figuring out a more permanent one. My current plan is to implement a *global* currency selector that affects all transactions. This will guarantee that the 'currency' value for each form and transaction is populated, and is available to pass to payment processors that need to know the currency value. This is all that most people will ever need.

Separately, we can write an additional module that allows per-form and/or per-transaction currencies. That module will probably depend on the currency module, will use the same currency column, and will handle the mathy side effects of summarizing transactions that were handled in different currencies. If someone needs to use more than one currency on their site, they can 'upgrade' to this as-yet-unwritten module.

allie micka’s picture

Status: Active » Fixed

I have added support for one global currency, and thus I am marking this issue as 'fixed'. There's still a need for multiple currencies, so I will open a new issue for that one.

After upgrading to the latest version of this code, you can go to admin/settings/pay and select the currency that should be used for all forms and transactions throughout the site. The list of currencies on that page is based on all currencies supported by any installed payment method handler. After this value has been set and used for a transaction, it cannot be changed.

@stella, per your original question, your payment method handler should implement the 'available_currencies()' method, which should return a list of the currencies that realex might support. During payment activities, you can use $this->activity->currency() to pass to the gateway.

allie micka’s picture

Title: Support for multiple currencies » Support for setting form and transaction currency values

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

andrewm63au’s picture

I don't have any currencies listed in the dropdown box. I see you say that the currency list is populated from the payment handler. I'm hoping to use Securepay as a gateway. Is that the same as a payment handler?