public static function send($method, $url, $params = array(), $env = null, $headers = array()) { if (is_null($env)) { $env = ChargeBee_Environment::defaultEnv(); } if (is_null($env)) { throw new Exception("ChargeBee api environment is not set. Set your site & api key in ChargeBee_Environment::configure('your_site', 'your_api_key')"); } $ser_params = ChargeBee_Util::serialize($params); $response = ChargeBee_Curl::doRequest($method, $url, $env, $ser_params, $headers); if (is_array($response) && array_key_exists("list", $response)) { return new ChargeBee_ListResult($response['list'], isset($response['next_offset']) ? $response['next_offset'] : null); } else { return new ChargeBee_Result($response); } }
function testSerialize() { $before = array("id" => "sub_KyVq7DNSNM7CSD", "planId" => "free", "addons" => array(array("id" => "monitor", "quantity" => 2), array("id" => "ssl")), "card" => array("firstName" => "Rajaraman", "lastName" => "Santhanam", "number" => "4111111111111111", "expiryMonth" => "1", "expiryYear" => "2024", "cvv" => "007")); $after = array("id" => "sub_KyVq7DNSNM7CSD", "plan_id" => "free", "addons[id][0]" => "monitor", "addons[quantity][0]" => 2, "addons[id][1]" => "ssl", "card[first_name]" => "Rajaraman", "card[last_name]" => "Santhanam", "card[number]" => "4111111111111111", "card[expiry_month]" => "1", "card[expiry_year]" => "2024", "card[cvv]" => "007"); $this->assertEqual($after, ChargeBee_Util::serialize($before)); }