public function validate() { $return = true; if (!$this->paymentgateway_id) { $this->errors[] = "You must enter a payment gateway ID"; return false; } if (!$this->paymentgateway) { $this->paymentgateway = PaymentGateway::find_by_id($this->paymentgateway_id); } $settings = $this->paymentgateway->getSettings(); if (!isset($settings[$this->code])) { $this->errors[] = 'Unable to find a setting with this code'; $return = false; } if (!$this->value) { $this->errors[] = 'You must enter a value'; $return = false; } if (count($this->errors) > 0) { $return = false; } return $return; }