public function purchaseBundle($rest) { $post = $rest->getRequest()->getPost(); MM_LogApi::logRequest(json_encode($post), "/purchaseBundle"); if (!Utils::isAuthenticated($post)) { return new Response($rest, null, RESPONSE_ERROR_MESSAGE_AUTH, RESPONSE_ERROR_CODE_AUTH, RESPONSE_ERROR_MESSAGE_AUTH); } $req = new stdClass(); $req->email = self::$REGEX_CONTAINS_ALPHA; $req->product_id = self::$REGEX_INTEGER_ONLY; $data = Utils::processApiRequestData($post, $req); if (MM_Response::isError($data)) { return new Response($rest, null, $data->message, RESPONSE_ERROR_CODE_MISSING_PARAMS, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS); } $result = MM_APIService::purchaseBundle($data); if (MM_Response::isSuccess($result)) { $url = $result->getData(MM_Response::$DATA_KEY_URL); if (!empty($url)) { $userData = array('confirmationUrl' => $result->getData(MM_Response::$DATA_KEY_URL)); return new Response($rest, $userData, $userData); } else { return new Response($rest, $result->message); } } else { return new Response($rest, null, $result->message, RESPONSE_ERROR_CODE_CONFLICT, RESPONSE_ERROR_MESSAGE_CONFLICT); } }