예제 #1
0
 public function testGetCountryCodes()
 {
     $currencies = Utilities::getCountryCodes();
     $this->assertArrayHasKey('GB', $currencies);
     $this->assertArrayHasKey('RS', $currencies);
     $this->assertArrayHasKey('US', $currencies);
 }
예제 #2
0
파일: Shared.php 프로젝트: dwmsw/sagepay
 /**
  * Set currency in which you wish to trade
  *
  * @param string $currency Currency
  */
 public function setCurrency($currency)
 {
     $currencies = Utilities::getCurrencies();
     if (isset($currencies[$currency])) {
         $this->currency = $currency;
     } else {
         throw new InvalidArgumentException("Invalid currency code, ISO 4217 Expected" . $currency . " given");
     }
 }
예제 #3
0
파일: Address.php 프로젝트: dwmsw/sagepay
 /**
  * Setter for address
  *
  * @param string $address1
  * @param string $address2
  * @param string $city
  * @param string $country
  * @param string $postcode
  * @param bool   $state
  */
 public function setAddress($address1, $address2, $city, $country, $postcode, $state = false)
 {
     $countries = Utilities::getCountryCodes();
     if (strlen($address1) > 100) {
         throw new InvalidArgumentException('Address1 must be less than 100 chars');
     } else {
         $this->address1 = $address1;
     }
     if (strlen($address2) > 100) {
         throw new InvalidArgumentException('Address2 must be less than 100 chars');
     } else {
         $this->address2 = $address2;
     }
     if (strlen($city) > 100) {
         throw new InvalidArgumentException('City must be less than 40 chars');
     } else {
         $this->city = $city;
     }
     if (strlen($country) > 2) {
         throw new InvalidArgumentException('Country must be less than 2 chars');
     } elseif (!isset($countries[$country])) {
         throw new InvalidArgumentException('Country must be a valid ISO 3166 country code');
     } else {
         $this->country = $country;
     }
     if (strlen($postcode) > 10) {
         throw new InvalidArgumentException('Postcode must be less than 10 chars');
     } else {
         $this->postcode = $postcode;
     }
     if ($state === false && $country == 'US') {
         throw new InvalidArgumentException('State must be set for the US');
     } else {
         $this->state = $state;
     }
 }