예제 #1
0
 /**
  * Validates the Order
  * 
  * <p>Validates the order information based on the paymentmethod and country used</p>
  * <p>For example Afterpay, it will check the zipcodes and it makes sure that the billing and shipping address are in the same country</p>
  * 
  * @param obj $paymentObj
  * @throws Exception
  */
 public function validateOrder($paymentObj)
 {
     switch (strtoupper($paymentObj->getPaymentMethod())) {
         case 'AFTERPAY':
             if ($this->_data['shippingAddress']->country !== $this->_data['billingAddress']->country) {
                 throw new Exception('Billing and Shipping country must be equal in order to use Afterpay.');
             }
             if (!Icepay_Order_Helper::validateZipCode($this->_data['shippingAddress']->zipCode, $this->_data['shippingAddress']->country)) {
                 throw new Exception('Zipcode format for shipping address is incorrect.');
             }
             if (!Icepay_Order_Helper::validateZipCode($this->_data['billingAddress']->zipCode, $this->_data['billingAddress']->country)) {
                 throw new Exception('Zipcode format for billing address is incorrect.');
             }
             if (!Icepay_Order_Helper::validatePhonenumber($this->_data['consumer']->phone)) {
                 throw new Exception('Phonenumber is incorrect.');
             }
             break;
     }
 }