Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 private function _load()
 {
     foreach ($this->_values as $k => $v) {
         $setVal = null;
         if ($this->isHash($v) && array_key_exists($k, $this->_subTypes)) {
             $setVal = new $this->_subTypes[$k]($v);
         } else {
             if (is_array($v) && array_key_exists($k, $this->_subTypes)) {
                 $setVal = array();
                 foreach ($v as $stV) {
                     array_push($setVal, new $this->_subTypes[$k]($stV));
                 }
             }
         }
         if (is_null($setVal)) {
             $setVal = $v;
         }
         $this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($k)] = $setVal;
     }
 }
Ejemplo n.º 3
0
 public static function retrieve($id, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("coupons", $id), array(), $env, $headers);
 }
Ejemplo n.º 4
0
 public static function renewalEstimate($id, $params = array(), $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("subscriptions", $id, "renewal_estimate"), $params, $env, $headers);
 }
Ejemplo n.º 5
0
 public static function deleteCardForCustomer($id, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers", $id, "delete_card"), array(), $env, $headers);
 }
Ejemplo n.º 6
0
 public function _initDependantList($obj, $type, $subTypes = array())
 {
     if (!array_key_exists($type, $obj)) {
         return $this;
     }
     if (!is_array($obj[$type])) {
         return $this;
     }
     $class = $this->__getDependant($type);
     if (!is_null($class)) {
         $setVal = array();
         foreach ($obj[$type] as $dt) {
             array_push($setVal, new $class($dt, $subTypes));
         }
         $this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($type)] = $setVal;
     }
     return $this;
 }
Ejemplo n.º 7
0
 public static function setAccountCredits($id, $params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers", $id, "set_account_credits"), $params, $env, $headers);
 }
Ejemplo n.º 8
0
 public static function update($params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("addresses"), $params, $env, $headers);
 }
Ejemplo n.º 9
0
 public static function recordPayment($id, $params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices", $id, "record_payment"), $params, $env, $headers);
 }
 public static function chargeAddonAtTermEnd($id, $params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("subscriptions", $id, "charge_addon_at_term_end"), $params, $env, $headers);
 }
 public static function activate($id, $params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("portal_sessions", $id, "activate"), $params, $env, $headers);
 }
Ejemplo n.º 12
0
 public static function creditNotesForCustomer($id, $params = array(), $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("customers", $id, "credit_notes"), $params, $env, $headers);
 }
Ejemplo n.º 13
0
 public static function ordersForInvoice($id, $params = array(), $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("invoices", $id, "orders"), $params, $env, $headers);
 }
Ejemplo n.º 14
0
 public static function copy($params, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("coupons", "copy"), $params, $env, $headers);
 }
Ejemplo n.º 15
0
 public static function delete($id, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("addons", $id, "delete"), array(), $env, $headers);
 }
Ejemplo n.º 16
0
 function testToUnderscoreFromCamelCase()
 {
     $before = "testString";
     $after = "test_string";
     $this->assertEqual($after, ChargeBee_Util::toUnderscoreFromCamelCase($before));
 }
Ejemplo n.º 17
0
 public static function archive($id, $env = null, $headers = array())
 {
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("coupon_codes", $id, "archive"), array(), $env, $headers);
 }