/** * Check a currency code is valid ISO4217. */ public static function checkCurrency($currency) { // Validate against the ISO4217 metadata and throw an exception if needed. // The card handler still may not accept this currency, but at least it will // be a valid currency code. $currency = strtoupper($currency); if (!\Academe\SagePay\Metadata\Iso4217::checkCurrency($currency)) { throw new Exception\InvalidArgumentException("Invalid currency code '{$currency}'"); } return $currency; }
public function validate($server) { $this->clearErrors(); $metaData = Transaction::get('array'); // Check the currency is a valid one if (!Metadata\Iso4217::checkCurrency($server->getField('Currency'))) { $this->addError('Currency', $this->CURRENCY_INVALID); } $this->validateAmount($server->getField('Amount')); // Perform some general validations and return ourself return parent::validate($server); }
/** * Set the currency for amount formatting. * The three-character ISO4217 currency code is required. */ public function setCurrency($currency) { $currency = strtoupper($currency); if (!Metadata\Iso4217::checkCurrency($currency)) { throw new Exception\InvalidArgumentException("Invalid currency code '{$currency}'"); } $this->currency = $currency; return $this; }