/** * Gets the payment gateway information, if it exists in the database. * * @return Array[user][id] * @throws Exception */ public function execute() { //make sure calling application is a default application $this->checkDefaultApp(); if (!Api_Bo_Users::isUserAdmin($this->getUserId())) { throw new OpenFBAPIException('Only the admin user may set a payment gateway.'); } $response = array(); $result = Api_Bo_Payments::getGateway(); $response['gateway'] = $result; return $response; }
/** * Creates the user if it's not in the DB. Throws an exception if the user already exists! * * @return Array[user][id] * @throws Exception */ public function execute() { if (!Api_Bo_Users::isUserAdmin($this->getUserId())) { throw new OpenFBAPIException('Only the admin user may set a payment gateway.'); } $response = array(); $result = Api_Bo_Payments::getGateway(); if (count($result) == 0) { Api_Bo_Payments::createGateway($this->type, $this->subject, $this->password); $response['gateway'] = array(); $response['gateway']['type'] = $this->type; $response['gateway']['subject'] = $this->subject; $response['gateway']['password'] = $this->password; } else { throw new OpenFBAPIException('Payment gateway' . $this->type . ' already exists! Only one payment gateway may be provisioned.'); } return $response; }