As Paul recently announced on our forums, multi-currency support is coming in version 2.2. This is a major change and affects just about every aspect of Blesta. For this reason a few minor changes have been made to the way gateways are written to accommodate multi-currency support. If you plan to upgrade to version 2.2 and are using any gateways not listed in our
official gateways listing, you should closely examine the following changes and contact us if you have any questions so you can make a smooth transition into version 2.2. All gateways must now extend the following abstract Gateway class:
<?php
abstract class Gateway {
/**
* Returns all currencies supported by this gateway.
*
* @return array An array of currencies supported by this gateway
*/
abstract function getCurrencies();
/**
* Returns all gateway settings fields
*
* @return array An array of all configurable fields
*/
abstract function getSettingFields();
}
?>
Changes for Non-Merchant Gateways 1. Must now extend the Gateway class. 2. Must define the getCurrencies() method. 3. Must return the currency used in the process() method as part of the return array (i.e. $trans[‘currency’] = “USD”). Changes for Merchant Gateways 1. Must define the getCurrencies() method. 2. Must define the getSettingFields() method. This method is implemented exactly as it is currently implemented in Non-Merchant gateways. Below is an example implementation of the getCurrencies() method:
<?php
// All currencies this gateway accepts
private static $supportedCurrencies = array("AUD", "EUR", "JPY", "USD");
public function getCurrencies() {
return self::$supportedCurrencies;
}
?>
You must also be sure that your gateway is POSTing the currency to your gateway in the appropriate manner. The currency will be fed to your gateway in the constructor’s 1st parameter as ‘currency’ (i.e. $gatewayinfo[‘currency’]). Failure to do so may result in your gateway processing your transaction in the incorrect currency, or a failed transaction. Again, this article only applies if you are using an unofficial or custom gateway and plan on upgrading to version 2.2. All gateways packaged with 2.2 will already contain these changes.