Alex Trofimov 10 лет назад
Родитель
Сommit
66b23d60e8
56 измененных файлов с 573 добавлено и 124 удалено
  1. 27 4
      plugins/chargebee/ChargeBee.php
  2. 3 2
      plugins/chargebee/ChargeBee/Environment.php
  3. 63 5
      plugins/chargebee/ChargeBee/Model.php
  4. 2 2
      plugins/chargebee/ChargeBee/Models/Addon.php
  5. 10 0
      plugins/chargebee/ChargeBee/Models/Card.php
  6. 1 1
      plugins/chargebee/ChargeBee/Models/Comment.php
  7. 2 2
      plugins/chargebee/ChargeBee/Models/Coupon.php
  8. 6 1
      plugins/chargebee/ChargeBee/Models/CouponCode.php
  9. 31 0
      plugins/chargebee/ChargeBee/Models/CreditNote.php
  10. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteAllocation.php
  11. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteDiscount.php
  12. 16 0
      plugins/chargebee/ChargeBee/Models/CreditNoteEstimate.php
  13. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteEstimateDiscount.php
  14. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteEstimateLineItem.php
  15. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteEstimateLineItemTax.php
  16. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteEstimateTax.php
  17. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteLineItem.php
  18. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteLineItemTax.php
  19. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteLinkedRefund.php
  20. 9 0
      plugins/chargebee/ChargeBee/Models/CreditNoteTax.php
  21. 28 8
      plugins/chargebee/ChargeBee/Models/Customer.php
  22. 9 0
      plugins/chargebee/ChargeBee/Models/CustomerContact.php
  23. 2 2
      plugins/chargebee/ChargeBee/Models/Estimate.php
  24. 0 9
      plugins/chargebee/ChargeBee/Models/EstimateDiscount.php
  25. 0 9
      plugins/chargebee/ChargeBee/Models/EstimateLineItem.php
  26. 0 9
      plugins/chargebee/ChargeBee/Models/EstimateTax.php
  27. 9 2
      plugins/chargebee/ChargeBee/Models/Event.php
  28. 0 10
      plugins/chargebee/ChargeBee/Models/HostedPage.php
  29. 11 6
      plugins/chargebee/ChargeBee/Models/Invoice.php
  30. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceAdjustmentCreditNote.php
  31. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceAppliedCredit.php
  32. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceCreatedCreditNote.php
  33. 1 1
      plugins/chargebee/ChargeBee/Models/InvoiceDiscount.php
  34. 16 0
      plugins/chargebee/ChargeBee/Models/InvoiceEstimate.php
  35. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceEstimateDiscount.php
  36. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceEstimateLineItem.php
  37. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceEstimateLineItemTax.php
  38. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceEstimateTax.php
  39. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceIssuedCreditNote.php
  40. 1 1
      plugins/chargebee/ChargeBee/Models/InvoiceLineItem.php
  41. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceLineItemTax.php
  42. 9 0
      plugins/chargebee/ChargeBee/Models/InvoiceLinkedPayment.php
  43. 0 9
      plugins/chargebee/ChargeBee/Models/InvoiceLinkedTransaction.php
  44. 1 1
      plugins/chargebee/ChargeBee/Models/InvoiceTax.php
  45. 1 1
      plugins/chargebee/ChargeBee/Models/Order.php
  46. 2 2
      plugins/chargebee/ChargeBee/Models/Plan.php
  47. 8 3
      plugins/chargebee/ChargeBee/Models/Subscription.php
  48. 16 0
      plugins/chargebee/ChargeBee/Models/SubscriptionEstimate.php
  49. 4 9
      plugins/chargebee/ChargeBee/Models/Transaction.php
  50. 9 0
      plugins/chargebee/ChargeBee/Models/TransactionLinkedCreditNote.php
  51. 1 1
      plugins/chargebee/ChargeBee/Models/TransactionLinkedInvoice.php
  52. 9 0
      plugins/chargebee/ChargeBee/Models/TransactionLinkedRefund.php
  53. 13 0
      plugins/chargebee/ChargeBee/Request.php
  54. 86 23
      plugins/chargebee/ChargeBee/Result.php
  55. 4 0
      plugins/chargebee/ChargeBee/Util.php
  56. 1 1
      plugins/chargebee/ChargeBee/Version.php

+ 27 - 4
plugins/chargebee/ChargeBee.php

@@ -53,6 +53,7 @@ require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionAddon.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionCoupon.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionCoupon.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionShippingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionShippingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Customer.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Customer.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CustomerContact.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/CustomerBillingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/CustomerBillingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/CustomerPaymentMethod.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/CustomerPaymentMethod.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Card.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Card.php');
@@ -62,15 +63,12 @@ require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLineItem.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceDiscount.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceDiscount.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceTax.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceTax.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceNote.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceNote.php');
-require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLinkedTransaction.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/TransactionLinkedRefund.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceBillingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceBillingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceShippingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceShippingAddress.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Order.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Order.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLinkedOrder.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLinkedOrder.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Estimate.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Estimate.php');
-require(dirname(__FILE__) . '/ChargeBee/Models/EstimateLineItem.php');
-require(dirname(__FILE__) . '/ChargeBee/Models/EstimateDiscount.php');
-require(dirname(__FILE__) . '/ChargeBee/Models/EstimateTax.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Transaction.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Transaction.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/TransactionLinkedInvoice.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/TransactionLinkedInvoice.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Content.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Content.php');
@@ -85,3 +83,28 @@ require(dirname(__FILE__) . '/ChargeBee/Models/Comment.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/PortalSession.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/PortalSession.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/PortalSessionLinkedCustomer.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/PortalSessionLinkedCustomer.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Download.php');
 require(dirname(__FILE__) . '/ChargeBee/Models/Download.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNote.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteAllocation.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteDiscount.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteEstimate.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteEstimateDiscount.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteEstimateLineItem.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteEstimateTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteLineItem.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteLinkedRefund.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteLineItemTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/CreditNoteEstimateLineItemTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceAdjustmentCreditNote.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceAppliedCredit.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceCreatedCreditNote.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceEstimate.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceEstimateDiscount.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceEstimateLineItem.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceEstimateTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceIssuedCreditNote.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLinkedPayment.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceLineItemTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/InvoiceEstimateLineItemTax.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/TransactionLinkedCreditNote.php');
+require(dirname(__FILE__) . '/ChargeBee/Models/SubscriptionEstimate.php');

+ 3 - 2
plugins/chargebee/ChargeBee/Environment.php

@@ -12,14 +12,15 @@ class ChargeBee_Environment {
 
 
     public static  $connectTimeout= 50;
     public static  $connectTimeout= 50;
     public static  $timeout=100;
     public static  $timeout=100;
+    const API_VERSION = "v2";
     
     
     function __construct($site, $apiKey) {
     function __construct($site, $apiKey) {
         $this->site = $site;
         $this->site = $site;
         $this->apiKey = $apiKey;
         $this->apiKey = $apiKey;
         if (ChargeBee_Environment::$chargebeeDomain == null) {
         if (ChargeBee_Environment::$chargebeeDomain == null) {
-            $this->apiEndPoint = "https://$site.chargebee.com/api/v1";
+            $this->apiEndPoint = "https://$site.chargebee.com/api/" . ChargeBee_Environment::API_VERSION;
         } else {
         } else {
-            $this->apiEndPoint = ChargeBee_Environment::$scheme . "://$site." . ChargeBee_Environment::$chargebeeDomain . "/api/v1";
+            $this->apiEndPoint = ChargeBee_Environment::$scheme . "://$site." . ChargeBee_Environment::$chargebeeDomain . "/api/" . ChargeBee_Environment::API_VERSION;
         }
         }
     }
     }
 
 

+ 63 - 5
plugins/chargebee/ChargeBee/Model.php

@@ -4,17 +4,19 @@ class ChargeBee_Model
 {
 {
 
 
 	protected $_values;
 	protected $_values;
-
-  protected $_subTypes;
+	
+	protected $_subTypes;
+	protected $_dependantTypes;
 
 
 	protected $_data = array();
 	protected $_data = array();
 
 
 	protected $allowed = array();
 	protected $allowed = array();
 
 
-	function __construct($values, $subTypes=array())
+	function __construct($values, $subTypes=array(), $dependantTypes=array())
 	{
 	{
 		$this->_values = $values;
 		$this->_values = $values;
 		$this->_subTypes = $subTypes;
 		$this->_subTypes = $subTypes;
+		$this->_dependantTypes=$dependantTypes;
 		$this->_load();
 		$this->_load();
 	}
 	}
 	
 	
@@ -64,7 +66,23 @@ class ChargeBee_Model
 			throw new Exception("Unknown property $k in " . get_class($this));
 			throw new Exception("Unknown property $k in " . get_class($this));
 		}
 		}
 	}
 	}
-
+	
+	private function __getDependant($k)
+	{
+		if (isset($this->_dependantTypes[$k])) 
+		{
+			return $this->_dependantTypes[$k];
+		} 
+		else if(in_array($k, $this->allowed))
+		{
+			return null;
+		}
+		else
+		{
+			throw new Exception("Unknown property $k in " . get_class($this));
+		}
+	}
+	
   private function isHash($array)
   private function isHash($array)
   {
   {
     if (!is_array($array))
     if (!is_array($array))
@@ -81,6 +99,10 @@ class ChargeBee_Model
 		foreach($this->_values as $k => $v) 
 		foreach($this->_values as $k => $v) 
 		{
 		{
 			$setVal = null;
 			$setVal = null;
+			if($this->isHash($v) && array_key_exists($k, $this->_dependantTypes))
+			{
+				continue;
+			}
 			if($this->isHash($v) && array_key_exists($k, $this->_subTypes))
 			if($this->isHash($v) && array_key_exists($k, $this->_subTypes))
 			{
 			{
 				$setVal = new $this->_subTypes[$k]($v);
 				$setVal = new $this->_subTypes[$k]($v);
@@ -100,7 +122,43 @@ class ChargeBee_Model
 			$this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($k)] = $setVal;
 			$this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($k)] = $setVal;
 		}
 		}
 	}
 	}
-
+	
+	public function _initDependant($obj, $type, $subTypes = array())
+	{
+		if(!array_key_exists($type, $obj))
+		{
+	    	return $this;
+		}
+		$class=$this->__getDependant($type);
+		if($this->isHash($obj) && !is_null($class))
+		{
+			$dependantObj = new $class($obj[$type], $subTypes);
+			$this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($type)] = $dependantObj;
+		}
+		return $this;
+	}
+	
+	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;
+	}	
+			
 }
 }
 
 
 ?>
 ?>

+ 2 - 2
plugins/chargebee/ChargeBee/Models/Addon.php

@@ -4,7 +4,7 @@ class ChargeBee_Addon extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'name', 'invoiceName', 'description', 'type', 'chargeType', 'price', 'period',
   protected $allowed = array('id', 'name', 'invoiceName', 'description', 'type', 'chargeType', 'price', 'period',
-'periodUnit', 'unit', 'status', 'archivedAt', 'invoiceNotes', 'taxable');
+'periodUnit', 'unit', 'status', 'archivedAt', 'enabledInPortal', 'taxCode', 'invoiceNotes','taxable', 'metaData');
 
 
 
 
 
 
@@ -23,7 +23,7 @@ class ChargeBee_Addon extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("addons"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("addons"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())

+ 10 - 0
plugins/chargebee/ChargeBee/Models/Card.php

@@ -21,6 +21,16 @@ class ChargeBee_Card extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"credit_card"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"credit_card"), $params, $env, $headers);
   }
   }
 
 
+  public static function switchGatewayForCustomer($id, $params, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"switch_gateway"), $params, $env, $headers);
+  }
+
+  public static function copyCardForCustomer($id, $params, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"copy_card"), $params, $env, $headers);
+  }
+
   public static function deleteCardForCustomer($id, $env = null, $headers = array())
   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);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"delete_card"), array(), $env, $headers);

+ 1 - 1
plugins/chargebee/ChargeBee/Models/Comment.php

@@ -23,7 +23,7 @@ class ChargeBee_Comment extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("comments"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("comments"), $params, $env, $headers);
   }
   }
 
 
   public static function delete($id, $env = null, $headers = array())
   public static function delete($id, $env = null, $headers = array())

+ 2 - 2
plugins/chargebee/ChargeBee/Models/Coupon.php

@@ -4,7 +4,7 @@ class ChargeBee_Coupon extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'name', 'invoiceName', 'discountType', 'discountPercentage', 'discountAmount',
   protected $allowed = array('id', 'name', 'invoiceName', 'discountType', 'discountPercentage', 'discountAmount',
-'discountQuantity', 'durationType', 'durationMonth', 'validTill', 'maxRedemptions', 'status','applyDiscountOn', 'applyOn', 'planConstraint', 'addonConstraint', 'createdAt', 'archivedAt','planIds', 'addonIds', 'redemptions', 'invoiceNotes');
+'discountQuantity', 'durationType', 'durationMonth', 'validTill', 'maxRedemptions', 'status','applyDiscountOn', 'applyOn', 'planConstraint', 'addonConstraint', 'createdAt', 'archivedAt','planIds', 'addonIds', 'redemptions', 'invoiceNotes', 'metaData');
 
 
 
 
 
 
@@ -18,7 +18,7 @@ class ChargeBee_Coupon extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("coupons"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("coupons"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())

+ 6 - 1
plugins/chargebee/ChargeBee/Models/CouponCode.php

@@ -3,7 +3,7 @@
 class ChargeBee_CouponCode extends ChargeBee_Model
 class ChargeBee_CouponCode extends ChargeBee_Model
 {
 {
 
 
-  protected $allowed = array('code', 'couponId', 'couponSetName'
+  protected $allowed = array('code', 'status', 'couponId', 'couponSetName'
 );
 );
 
 
 
 
@@ -21,6 +21,11 @@ class ChargeBee_CouponCode extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("coupon_codes",$id), array(), $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("coupon_codes",$id), array(), $env, $headers);
   }
   }
 
 
+  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);
+  }
+
  }
  }
 
 
 ?>
 ?>

+ 31 - 0
plugins/chargebee/ChargeBee/Models/CreditNote.php

@@ -0,0 +1,31 @@
+<?php
+
+class ChargeBee_CreditNote extends ChargeBee_Model
+{
+
+  protected $allowed = array('id', 'customerId', 'subscriptionId', 'referenceInvoiceId', 'type', 'reasonCode',
+'status', 'vatNumber', 'date', 'priceType', 'total', 'amountAllocated', 'amountRefunded', 'amountAvailable','refundedAt', 'subTotal', 'currencyCode', 'lineItems', 'discounts', 'taxes', 'lineItemTaxes','linkedRefunds', 'allocations');
+
+
+
+  # OPERATIONS
+  #-----------
+
+  public static function retrieve($id, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("credit_notes",$id), array(), $env, $headers);
+  }
+
+  public static function all($params = array(), $env = null, $headers = array())
+  {
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("credit_notes"), $params, $env, $headers);
+  }
+
+  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);
+  }
+
+ }
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteAllocation.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteAllocation extends ChargeBee_Model
+{
+  protected $allowed = array('invoice_id', 'allocated_amount', 'allocated_at', 'invoice_date', 'invoice_status');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteDiscount.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteDiscount extends ChargeBee_Model
+{
+  protected $allowed = array('amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 16 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteEstimate.php

@@ -0,0 +1,16 @@
+<?php
+
+class ChargeBee_CreditNoteEstimate extends ChargeBee_Model
+{
+
+  protected $allowed = array('referenceInvoiceId', 'type', 'priceType', 'subTotal', 'total', 'amountAllocated',
+'amountAvailable', 'lineItems', 'discounts', 'taxes', 'lineItemTaxes');
+
+
+
+  # OPERATIONS
+  #-----------
+
+ }
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteEstimateDiscount.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteEstimateDiscount extends ChargeBee_Model
+{
+  protected $allowed = array('amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteEstimateLineItem.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteEstimateLineItem extends ChargeBee_Model
+{
+  protected $allowed = array('id', 'date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax_amount', 'tax_rate', 'amount', 'discount_amount', 'item_level_discount_amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteEstimateLineItemTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteEstimateLineItemTax extends ChargeBee_Model
+{
+  protected $allowed = array('line_item_id', 'tax_name', 'tax_rate', 'tax_amount', 'tax_juris_type', 'tax_juris_name', 'tax_juris_code');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteEstimateTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteEstimateTax extends ChargeBee_Model
+{
+  protected $allowed = array('name', 'amount', 'description');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteLineItem.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteLineItem extends ChargeBee_Model
+{
+  protected $allowed = array('id', 'date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax_amount', 'tax_rate', 'amount', 'discount_amount', 'item_level_discount_amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteLineItemTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteLineItemTax extends ChargeBee_Model
+{
+  protected $allowed = array('line_item_id', 'tax_name', 'tax_rate', 'tax_amount', 'tax_juris_type', 'tax_juris_name', 'tax_juris_code');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteLinkedRefund.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteLinkedRefund extends ChargeBee_Model
+{
+  protected $allowed = array('txn_id', 'applied_amount', 'applied_at', 'txn_status', 'txn_date', 'txn_amount');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CreditNoteTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CreditNoteTax extends ChargeBee_Model
+{
+  protected $allowed = array('name', 'amount', 'description');
+
+}
+
+?>

+ 28 - 8
plugins/chargebee/ChargeBee/Models/Customer.php

@@ -4,7 +4,7 @@ class ChargeBee_Customer extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'firstName', 'lastName', 'email', 'phone', 'company', 'vatNumber', 'autoCollection',
   protected $allowed = array('id', 'firstName', 'lastName', 'email', 'phone', 'company', 'vatNumber', 'autoCollection',
-'allowDirectDebit', 'createdAt', 'createdFromIp', 'taxability', 'cardStatus', 'billingAddress','paymentMethod', 'invoiceNotes', 'accountCredits');
+'allowDirectDebit', 'createdAt', 'createdFromIp', 'taxability', 'entityCode', 'exemptNumber','cardStatus', 'billingAddress', 'contacts', 'paymentMethod', 'invoiceNotes', 'promotionalCredits','refundableCredits', 'excessPayments', 'metaData');
 
 
 
 
 
 
@@ -18,7 +18,7 @@ class ChargeBee_Customer extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("customers"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("customers"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())
@@ -41,19 +41,39 @@ class ChargeBee_Customer extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"update_billing_info"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"update_billing_info"), $params, $env, $headers);
   }
   }
 
 
-  public static function addAccountCredits($id, $params, $env = null, $headers = array())
+  public static function addContact($id, $params, $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"add_account_credits"), $params, $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"add_contact"), $params, $env, $headers);
   }
   }
 
 
-  public static function deductAccountCredits($id, $params, $env = null, $headers = array())
+  public static function updateContact($id, $params, $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"deduct_account_credits"), $params, $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"update_contact"), $params, $env, $headers);
   }
   }
 
 
-  public static function setAccountCredits($id, $params, $env = null, $headers = array())
+  public static function deleteContact($id, $params, $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"set_account_credits"), $params, $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"delete_contact"), $params, $env, $headers);
+  }
+
+  public static function addPromotionalCredits($id, $params, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"add_promotional_credits"), $params, $env, $headers);
+  }
+
+  public static function deductPromotionalCredits($id, $params, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"deduct_promotional_credits"), $params, $env, $headers);
+  }
+
+  public static function setPromotionalCredits($id, $params, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"set_promotional_credits"), $params, $env, $headers);
+  }
+
+  public static function delete($id, $params = array(), $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("customers",$id,"delete"), $params, $env, $headers);
   }
   }
 
 
  }
  }

+ 9 - 0
plugins/chargebee/ChargeBee/Models/CustomerContact.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_CustomerContact extends ChargeBee_Model
+{
+  protected $allowed = array('id', 'first_name', 'last_name', 'email', 'phone', 'label', 'enabled', 'send_account_email', 'send_billing_email');
+
+}
+
+?>

+ 2 - 2
plugins/chargebee/ChargeBee/Models/Estimate.php

@@ -3,8 +3,8 @@
 class ChargeBee_Estimate extends ChargeBee_Model
 class ChargeBee_Estimate extends ChargeBee_Model
 {
 {
 
 
-  protected $allowed = array('createdAt', 'recurring', 'subscriptionId', 'subscriptionStatus', 'termEndsAt',
-'collectNow', 'amount', 'priceType', 'subTotal', 'lineItems', 'discounts', 'taxes');
+  protected $allowed = array('createdAt', 'subscriptionEstimate', 'invoiceEstimate', 'nextInvoiceEstimate',
+'creditNoteEstimates');
 
 
 
 
 
 

+ 0 - 9
plugins/chargebee/ChargeBee/Models/EstimateDiscount.php

@@ -1,9 +0,0 @@
-<?php
-
-class ChargeBee_EstimateDiscount extends ChargeBee_Model
-{
-  protected $allowed = array('amount', 'description', 'type', 'entity_id');
-
-}
-
-?>

+ 0 - 9
plugins/chargebee/ChargeBee/Models/EstimateLineItem.php

@@ -1,9 +0,0 @@
-<?php
-
-class ChargeBee_EstimateLineItem extends ChargeBee_Model
-{
-  protected $allowed = array('date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax', 'tax_rate', 'amount', 'description', 'type', 'entity_type', 'entity_id');
-
-}
-
-?>

+ 0 - 9
plugins/chargebee/ChargeBee/Models/EstimateTax.php

@@ -1,9 +0,0 @@
-<?php
-
-class ChargeBee_EstimateTax extends ChargeBee_Model
-{
-  protected $allowed = array('amount', 'description');
-
-}
-
-?>

+ 9 - 2
plugins/chargebee/ChargeBee/Models/Event.php

@@ -4,7 +4,7 @@ class ChargeBee_Event extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'occurredAt', 'source', 'user', 'webhookStatus', 'webhookFailureReason',
   protected $allowed = array('id', 'occurredAt', 'source', 'user', 'webhookStatus', 'webhookFailureReason',
-'webhooks', 'eventType');
+'webhooks', 'eventType', 'apiVersion');
 
 
     public function content()
     public function content()
     {
     {
@@ -19,6 +19,13 @@ class ChargeBee_Event extends ChargeBee_Model
         }
         }
         if($webhookData != null)
         if($webhookData != null)
         {
         {
+            if( isset($webhookData['api_version']) ) {
+                $apiVersion = strtoupper($webhookData['api_version']);
+                if($apiVersion != null && strcasecmp($apiVersion, ChargeBee_Environment::API_VERSION) != 0){
+                    throw new RuntimeException("API version [".$apiVersion."] in response does not match "
+                        ."with client library API version [".strtoupper(ChargeBee_Environment::API_VERSION)."]");
+                }
+            }
             return new ChargeBee_Event($webhookData);
             return new ChargeBee_Event($webhookData);
         }
         }
         return null;
         return null;
@@ -30,7 +37,7 @@ class ChargeBee_Event extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("events"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("events"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())

+ 0 - 10
plugins/chargebee/ChargeBee/Models/HostedPage.php

@@ -38,16 +38,6 @@ class ChargeBee_HostedPage extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("hosted_pages","update_payment_method"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("hosted_pages","update_payment_method"), $params, $env, $headers);
   }
   }
 
 
-  public static function checkoutOnetimeCharge($params, $env = null, $headers = array())
-  {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("hosted_pages","checkout_onetime_charge"), $params, $env, $headers);
-  }
-
-  public static function checkoutOnetimeAddons($params, $env = null, $headers = array())
-  {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("hosted_pages","checkout_onetime_addons"), $params, $env, $headers);
-  }
-
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())
   {
   {
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("hosted_pages",$id), array(), $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("hosted_pages",$id), array(), $env, $headers);

+ 11 - 6
plugins/chargebee/ChargeBee/Models/Invoice.php

@@ -4,7 +4,7 @@ class ChargeBee_Invoice extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'poNumber', 'customerId', 'subscriptionId', 'recurring', 'status', 'vatNumber',
   protected $allowed = array('id', 'poNumber', 'customerId', 'subscriptionId', 'recurring', 'status', 'vatNumber',
-'priceType', 'startDate', 'endDate', 'amount', 'amountDue', 'paidOn', 'dunningStatus', 'nextRetry','subTotal', 'tax', 'firstInvoice', 'currencyCode', 'lineItems', 'discounts', 'taxes', 'linkedTransactions','linkedOrders', 'notes', 'shippingAddress', 'billingAddress');
+'priceType', 'date', 'total', 'amountPaid', 'amountAdjusted', 'writeOffAmount', 'creditsApplied','amountDue', 'paidAt', 'dunningStatus', 'nextRetryAt', 'subTotal', 'tax', 'firstInvoice', 'currencyCode','lineItems', 'discounts', 'taxes', 'lineItemTaxes', 'linkedPayments', 'appliedCredits', 'adjustmentCreditNotes','issuedCreditNotes', 'linkedOrders', 'notes', 'shippingAddress', 'billingAddress');
 
 
 
 
 
 
@@ -33,7 +33,7 @@ class ChargeBee_Invoice extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("invoices"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("invoices"), $params, $env, $headers);
   }
   }
 
 
   public static function invoicesForCustomer($id, $params = array(), $env = null, $headers = array())
   public static function invoicesForCustomer($id, $params = array(), $env = null, $headers = array())
@@ -66,14 +66,19 @@ class ChargeBee_Invoice extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"add_addon_charge"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"add_addon_charge"), $params, $env, $headers);
   }
   }
 
 
-  public static function collect($id, $env = null, $headers = array())
+  public static function close($id, $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"collect"), array(), $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"close"), array(), $env, $headers);
   }
   }
 
 
-  public static function collectPayment($id, $env = null, $headers = array())
+  public static function collectPayment($id, $params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"collect_payment"), array(), $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("invoices",$id,"collect_payment"), $params, $env, $headers);
+  }
+
+  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 refund($id, $params = array(), $env = null, $headers = array())
   public static function refund($id, $params = array(), $env = null, $headers = array())

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceAdjustmentCreditNote.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceAdjustmentCreditNote extends ChargeBee_Model
+{
+  protected $allowed = array('cn_id', 'cn_reason_code', 'cn_date', 'cn_total', 'cn_status');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceAppliedCredit.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceAppliedCredit extends ChargeBee_Model
+{
+  protected $allowed = array('cn_id', 'applied_amount', 'applied_at', 'cn_reason_code', 'cn_date', 'cn_status');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceCreatedCreditNote.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceCreatedCreditNote extends ChargeBee_Model
+{
+  protected $allowed = array('cn_id', 'cn_type', 'cn_reason_code', 'cn_date', 'cn_total', 'cn_status');
+
+}
+
+?>

+ 1 - 1
plugins/chargebee/ChargeBee/Models/InvoiceDiscount.php

@@ -2,7 +2,7 @@
 
 
 class ChargeBee_InvoiceDiscount extends ChargeBee_Model
 class ChargeBee_InvoiceDiscount extends ChargeBee_Model
 {
 {
-  protected $allowed = array('amount', 'description', 'type', 'entity_id');
+  protected $allowed = array('amount', 'description', 'entity_type', 'entity_id');
 
 
 }
 }
 
 

+ 16 - 0
plugins/chargebee/ChargeBee/Models/InvoiceEstimate.php

@@ -0,0 +1,16 @@
+<?php
+
+class ChargeBee_InvoiceEstimate extends ChargeBee_Model
+{
+
+  protected $allowed = array('recurring', 'priceType', 'subTotal', 'total', 'creditsApplied', 'amountPaid',
+'amountDue', 'lineItems', 'discounts', 'taxes', 'lineItemTaxes');
+
+
+
+  # OPERATIONS
+  #-----------
+
+ }
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceEstimateDiscount.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceEstimateDiscount extends ChargeBee_Model
+{
+  protected $allowed = array('amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceEstimateLineItem.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceEstimateLineItem extends ChargeBee_Model
+{
+  protected $allowed = array('id', 'date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax_amount', 'tax_rate', 'amount', 'discount_amount', 'item_level_discount_amount', 'description', 'entity_type', 'entity_id');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceEstimateLineItemTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceEstimateLineItemTax extends ChargeBee_Model
+{
+  protected $allowed = array('line_item_id', 'tax_name', 'tax_rate', 'tax_amount', 'tax_juris_type', 'tax_juris_name', 'tax_juris_code');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceEstimateTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceEstimateTax extends ChargeBee_Model
+{
+  protected $allowed = array('name', 'amount', 'description');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceIssuedCreditNote.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceIssuedCreditNote extends ChargeBee_Model
+{
+  protected $allowed = array('cn_id', 'cn_reason_code', 'cn_date', 'cn_total', 'cn_status');
+
+}
+
+?>

+ 1 - 1
plugins/chargebee/ChargeBee/Models/InvoiceLineItem.php

@@ -2,7 +2,7 @@
 
 
 class ChargeBee_InvoiceLineItem extends ChargeBee_Model
 class ChargeBee_InvoiceLineItem extends ChargeBee_Model
 {
 {
-  protected $allowed = array('date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax', 'tax_rate', 'amount', 'description', 'type', 'entity_type', 'entity_id');
+  protected $allowed = array('id', 'date_from', 'date_to', 'unit_amount', 'quantity', 'is_taxed', 'tax_amount', 'tax_rate', 'amount', 'discount_amount', 'item_level_discount_amount', 'description', 'entity_type', 'entity_id');
 
 
 }
 }
 
 

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceLineItemTax.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceLineItemTax extends ChargeBee_Model
+{
+  protected $allowed = array('line_item_id', 'tax_name', 'tax_rate', 'tax_amount', 'tax_juris_type', 'tax_juris_name', 'tax_juris_code');
+
+}
+
+?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/InvoiceLinkedPayment.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_InvoiceLinkedPayment extends ChargeBee_Model
+{
+  protected $allowed = array('txn_id', 'applied_amount', 'applied_at', 'txn_status', 'txn_date', 'txn_amount');
+
+}
+
+?>

+ 0 - 9
plugins/chargebee/ChargeBee/Models/InvoiceLinkedTransaction.php

@@ -1,9 +0,0 @@
-<?php
-
-class ChargeBee_InvoiceLinkedTransaction extends ChargeBee_Model
-{
-  protected $allowed = array('txn_id', 'applied_amount', 'txn_type', 'txn_status', 'txn_date', 'txn_amount');
-
-}
-
-?>

+ 1 - 1
plugins/chargebee/ChargeBee/Models/InvoiceTax.php

@@ -2,7 +2,7 @@
 
 
 class ChargeBee_InvoiceTax extends ChargeBee_Model
 class ChargeBee_InvoiceTax extends ChargeBee_Model
 {
 {
-  protected $allowed = array('amount', 'description');
+  protected $allowed = array('name', 'amount', 'description');
 
 
 }
 }
 
 

+ 1 - 1
plugins/chargebee/ChargeBee/Models/Order.php

@@ -28,7 +28,7 @@ class ChargeBee_Order extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("orders"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("orders"), $params, $env, $headers);
   }
   }
 
 
   public static function ordersForInvoice($id, $params = array(), $env = null, $headers = array())
   public static function ordersForInvoice($id, $params = array(), $env = null, $headers = array())

+ 2 - 2
plugins/chargebee/ChargeBee/Models/Plan.php

@@ -4,7 +4,7 @@ class ChargeBee_Plan extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'name', 'invoiceName', 'description', 'price', 'period', 'periodUnit', 'trialPeriod',
   protected $allowed = array('id', 'name', 'invoiceName', 'description', 'price', 'period', 'periodUnit', 'trialPeriod',
-'trialPeriodUnit', 'chargeModel', 'freeQuantity', 'setupCost', 'downgradePenalty', 'status','archivedAt', 'billingCycles', 'redirectUrl', 'enabledInHostedPages', 'invoiceNotes', 'taxable');
+'trialPeriodUnit', 'chargeModel', 'freeQuantity', 'setupCost', 'downgradePenalty', 'status','archivedAt', 'billingCycles', 'redirectUrl', 'enabledInHostedPages', 'enabledInPortal', 'taxCode','invoiceNotes', 'taxable', 'metaData');
 
 
 
 
 
 
@@ -23,7 +23,7 @@ class ChargeBee_Plan extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("plans"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("plans"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())

+ 8 - 3
plugins/chargebee/ChargeBee/Models/Subscription.php

@@ -3,8 +3,8 @@
 class ChargeBee_Subscription extends ChargeBee_Model
 class ChargeBee_Subscription extends ChargeBee_Model
 {
 {
 
 
-  protected $allowed = array('id', 'planId', 'planQuantity', 'status', 'startDate', 'trialStart', 'trialEnd',
-'currentTermStart', 'currentTermEnd', 'remainingBillingCycles', 'poNumber', 'createdAt', 'startedAt','activatedAt', 'cancelledAt', 'cancelReason', 'affiliateToken', 'createdFromIp', 'dueInvoicesCount','dueSince', 'totalDues', 'addons', 'coupon', 'coupons', 'shippingAddress', 'hasScheduledChanges','invoiceNotes');
+  protected $allowed = array('id', 'customerId', 'planId', 'planQuantity', 'status', 'startDate', 'trialStart',
+'trialEnd', 'currentTermStart', 'currentTermEnd', 'remainingBillingCycles', 'poNumber', 'createdAt','startedAt', 'activatedAt', 'cancelledAt', 'cancelReason', 'affiliateToken', 'createdFromIp','hasScheduledChanges', 'dueInvoicesCount', 'dueSince', 'totalDues', 'addons', 'coupon', 'coupons','shippingAddress', 'invoiceNotes', 'metaData');
 
 
 
 
 
 
@@ -23,7 +23,7 @@ class ChargeBee_Subscription extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("subscriptions"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("subscriptions"), $params, $env, $headers);
   }
   }
 
 
   public static function subscriptionsForCustomer($id, $params = array(), $env = null, $headers = array())
   public static function subscriptionsForCustomer($id, $params = array(), $env = null, $headers = array())
@@ -81,6 +81,11 @@ class ChargeBee_Subscription extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("subscriptions",$id,"charge_addon_at_term_end"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("subscriptions",$id,"charge_addon_at_term_end"), $params, $env, $headers);
   }
   }
 
 
+  public static function delete($id, $env = null, $headers = array())
+  {
+    return ChargeBee_Request::send(ChargeBee_Request::POST, ChargeBee_Util::encodeURIPath("subscriptions",$id,"delete"), array(), $env, $headers);
+  }
+
  }
  }
 
 
 ?>
 ?>

+ 16 - 0
plugins/chargebee/ChargeBee/Models/SubscriptionEstimate.php

@@ -0,0 +1,16 @@
+<?php
+
+class ChargeBee_SubscriptionEstimate extends ChargeBee_Model
+{
+
+  protected $allowed = array('id', 'status', 'nextBillingAt'
+);
+
+
+
+  # OPERATIONS
+  #-----------
+
+ }
+
+?>

+ 4 - 9
plugins/chargebee/ChargeBee/Models/Transaction.php

@@ -4,7 +4,7 @@ class ChargeBee_Transaction extends ChargeBee_Model
 {
 {
 
 
   protected $allowed = array('id', 'customerId', 'subscriptionId', 'paymentMethod', 'referenceNumber', 'gateway',
   protected $allowed = array('id', 'customerId', 'subscriptionId', 'paymentMethod', 'referenceNumber', 'gateway',
-'description', 'type', 'date', 'amount', 'idAtGateway', 'status', 'errorCode', 'errorText','voidedAt', 'voidDescription', 'maskedCardNumber', 'refundedTxnId', 'linkedInvoices', 'currencyCode');
+'type', 'date', 'amount', 'idAtGateway', 'status', 'errorCode', 'errorText', 'voidedAt', 'amountUnused','maskedCardNumber', 'referenceTransactionId', 'refundedTxnId', 'reversalTransactionId', 'linkedInvoices','linkedCreditNotes', 'linkedRefunds', 'currencyCode');
 
 
 
 
 
 
@@ -13,7 +13,7 @@ class ChargeBee_Transaction extends ChargeBee_Model
 
 
   public static function all($params = array(), $env = null, $headers = array())
   public static function all($params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("transactions"), $params, $env, $headers);
+    return ChargeBee_Request::sendListRequest(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("transactions"), $params, $env, $headers);
   }
   }
 
 
   public static function transactionsForCustomer($id, $params = array(), $env = null, $headers = array())
   public static function transactionsForCustomer($id, $params = array(), $env = null, $headers = array())
@@ -26,9 +26,9 @@ class ChargeBee_Transaction extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("subscriptions",$id,"transactions"), $params, $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("subscriptions",$id,"transactions"), $params, $env, $headers);
   }
   }
 
 
-  public static function transactionsForInvoice($id, $params = array(), $env = null, $headers = array())
+  public static function paymentsForInvoice($id, $params = array(), $env = null, $headers = array())
   {
   {
-    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("invoices",$id,"transactions"), $params, $env, $headers);
+    return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("invoices",$id,"payments"), $params, $env, $headers);
   }
   }
 
 
   public static function retrieve($id, $env = null, $headers = array())
   public static function retrieve($id, $env = null, $headers = array())
@@ -36,11 +36,6 @@ class ChargeBee_Transaction extends ChargeBee_Model
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("transactions",$id), array(), $env, $headers);
     return ChargeBee_Request::send(ChargeBee_Request::GET, ChargeBee_Util::encodeURIPath("transactions",$id), array(), $env, $headers);
   }
   }
 
 
-  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);
-  }
-
  }
  }
 
 
 ?>
 ?>

+ 9 - 0
plugins/chargebee/ChargeBee/Models/TransactionLinkedCreditNote.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_TransactionLinkedCreditNote extends ChargeBee_Model
+{
+  protected $allowed = array('cn_id', 'applied_amount', 'applied_at', 'cn_reason_code', 'cn_date', 'cn_total', 'cn_status', 'cn_reference_invoice_id');
+
+}
+
+?>

+ 1 - 1
plugins/chargebee/ChargeBee/Models/TransactionLinkedInvoice.php

@@ -2,7 +2,7 @@
 
 
 class ChargeBee_TransactionLinkedInvoice extends ChargeBee_Model
 class ChargeBee_TransactionLinkedInvoice extends ChargeBee_Model
 {
 {
-  protected $allowed = array('invoice_id', 'applied_amount', 'invoice_date', 'invoice_amount');
+  protected $allowed = array('invoice_id', 'applied_amount', 'applied_at', 'invoice_date', 'invoice_total', 'invoice_status');
 
 
 }
 }
 
 

+ 9 - 0
plugins/chargebee/ChargeBee/Models/TransactionLinkedRefund.php

@@ -0,0 +1,9 @@
+<?php
+
+class ChargeBee_TransactionLinkedRefund extends ChargeBee_Model
+{
+  protected $allowed = array('txn_id', 'txn_status', 'txn_date', 'txn_amount');
+
+}
+
+?>

+ 13 - 0
plugins/chargebee/ChargeBee/Request.php

@@ -6,6 +6,19 @@ class ChargeBee_Request
 	const GET = "get";
 	const GET = "get";
 	
 	
 	const POST = "post";
 	const POST = "post";
+
+	public static function sendListRequest($method, $url, $params = array(), $env = null, $headers = array())
+	{
+		$serialized = array();
+		foreach ($params as $k => $v)
+		{
+			if(is_array($v)){
+				$v = json_encode($v);
+			}
+		    $serialized[$k] = $v;
+		}
+		return self::send($method,$url,$serialized,$env,$headers);
+	}
 	
 	
 	public static function send($method, $url, $params = array(), $env = null, $headers = array())
 	public static function send($method, $url, $params = array(), $env = null, $headers = array())
 	{
 	{

+ 86 - 23
plugins/chargebee/ChargeBee/Result.php

@@ -14,98 +14,161 @@ class ChargeBee_Result
 
 
     function subscription() 
     function subscription() 
     {
     {
-        return $this->_get('subscription', 'ChargeBee_Subscription', 
+        $subscription = $this->_get('subscription', 'ChargeBee_Subscription', 
         array('addons' => 'ChargeBee_SubscriptionAddon', 'coupons' => 'ChargeBee_SubscriptionCoupon', 'shipping_address' => 'ChargeBee_SubscriptionShippingAddress'));
         array('addons' => 'ChargeBee_SubscriptionAddon', 'coupons' => 'ChargeBee_SubscriptionCoupon', 'shipping_address' => 'ChargeBee_SubscriptionShippingAddress'));
+        return $subscription;
     }
     }
 
 
     function customer() 
     function customer() 
     {
     {
-        return $this->_get('customer', 'ChargeBee_Customer', 
-        array('billing_address' => 'ChargeBee_CustomerBillingAddress', 'payment_method' => 'ChargeBee_CustomerPaymentMethod'));
+        $customer = $this->_get('customer', 'ChargeBee_Customer', 
+        array('billing_address' => 'ChargeBee_CustomerBillingAddress', 'contacts' => 'ChargeBee_CustomerContact', 'payment_method' => 'ChargeBee_CustomerPaymentMethod'));
+        return $customer;
     }
     }
 
 
     function card() 
     function card() 
     {
     {
-        return $this->_get('card', 'ChargeBee_Card');
+        $card = $this->_get('card', 'ChargeBee_Card');
+        return $card;
     }
     }
 
 
     function invoice() 
     function invoice() 
     {
     {
-        return $this->_get('invoice', 'ChargeBee_Invoice', 
-        array('line_items' => 'ChargeBee_InvoiceLineItem', 'discounts' => 'ChargeBee_InvoiceDiscount', 'taxes' => 'ChargeBee_InvoiceTax', 'invoice_transactions' => 'ChargeBee_InvoiceLinkedTransaction', 'orders' => 'ChargeBee_InvoiceLinkedOrder', 'invoice_notes' => 'ChargeBee_InvoiceNote', 'shipping_address' => 'ChargeBee_InvoiceShippingAddress', 'billing_address' => 'ChargeBee_InvoiceBillingAddress'));
+        $invoice = $this->_get('invoice', 'ChargeBee_Invoice', 
+        array('line_items' => 'ChargeBee_InvoiceLineItem', 'discounts' => 'ChargeBee_InvoiceDiscount', 'taxes' => 'ChargeBee_InvoiceTax', 'line_item_taxes' => 'ChargeBee_InvoiceLineItemTax', 'linked_payments' => 'ChargeBee_InvoiceLinkedPayment', 'applied_credits' => 'ChargeBee_InvoiceAppliedCredit', 'adjustment_credit_notes' => 'ChargeBee_InvoiceAdjustmentCreditNote', 'issued_credit_notes' => 'ChargeBee_InvoiceIssuedCreditNote', 'linked_orders' => 'ChargeBee_InvoiceLinkedOrder', 'notes' => 'ChargeBee_InvoiceNote', 'shipping_address' => 'ChargeBee_InvoiceShippingAddress', 'billing_address' => 'ChargeBee_InvoiceBillingAddress'));
+        return $invoice;
+    }
+
+    function creditNote() 
+    {
+        $credit_note = $this->_get('credit_note', 'ChargeBee_CreditNote', 
+        array('line_items' => 'ChargeBee_CreditNoteLineItem', 'discounts' => 'ChargeBee_CreditNoteDiscount', 'taxes' => 'ChargeBee_CreditNoteTax', 'line_item_taxes' => 'ChargeBee_CreditNoteLineItemTax', 'linked_refunds' => 'ChargeBee_CreditNoteLinkedRefund', 'allocations' => 'ChargeBee_CreditNoteAllocation'));
+        return $credit_note;
     }
     }
 
 
     function order() 
     function order() 
     {
     {
-        return $this->_get('order', 'ChargeBee_Order');
+        $order = $this->_get('order', 'ChargeBee_Order');
+        return $order;
     }
     }
 
 
     function transaction() 
     function transaction() 
     {
     {
-        return $this->_get('transaction', 'ChargeBee_Transaction', 
-        array('invoice_transactions' => 'ChargeBee_TransactionLinkedInvoice'));
+        $transaction = $this->_get('transaction', 'ChargeBee_Transaction', 
+        array('linked_invoices' => 'ChargeBee_TransactionLinkedInvoice', 'linked_credit_notes' => 'ChargeBee_TransactionLinkedCreditNote', 'linked_refunds' => 'ChargeBee_TransactionLinkedRefund'));
+        return $transaction;
     }
     }
 
 
     function hostedPage() 
     function hostedPage() 
     {
     {
-        return $this->_get('hosted_page', 'ChargeBee_HostedPage');
+        $hosted_page = $this->_get('hosted_page', 'ChargeBee_HostedPage');
+        return $hosted_page;
     }
     }
 
 
     function estimate() 
     function estimate() 
     {
     {
-        return $this->_get('estimate', 'ChargeBee_Estimate', 
-        array('line_items' => 'ChargeBee_EstimateLineItem', 'discounts' => 'ChargeBee_EstimateDiscount', 'taxes' => 'ChargeBee_EstimateTax'));
+        $estimate = $this->_get('estimate', 'ChargeBee_Estimate', array(),
+        array('subscription_estimate' => 'ChargeBee_SubscriptionEstimate', 'invoice_estimate' => 'ChargeBee_InvoiceEstimate', 'next_invoice_estimate' => 'ChargeBee_InvoiceEstimate', 'credit_note_estimates' => 'ChargeBee_CreditNoteEstimate'));
+        $estimate->_initDependant($this->_response['estimate'], 'subscription_estimate', 
+        array());
+        $estimate->_initDependant($this->_response['estimate'], 'invoice_estimate', 
+        array('line_items' => 'ChargeBee_InvoiceEstimateLineItem', 'discounts' => 'ChargeBee_InvoiceEstimateDiscount', 'taxes' => 'ChargeBee_InvoiceEstimateTax', 'line_item_taxes' => 'ChargeBee_InvoiceEstimateLineItemTax'));
+        $estimate->_initDependant($this->_response['estimate'], 'next_invoice_estimate', 
+        array('line_items' => 'ChargeBee_InvoiceEstimateLineItem', 'discounts' => 'ChargeBee_InvoiceEstimateDiscount', 'taxes' => 'ChargeBee_InvoiceEstimateTax', 'line_item_taxes' => 'ChargeBee_InvoiceEstimateLineItemTax'));
+        $estimate->_initDependantList($this->_response['estimate'], 'credit_note_estimates', 
+        array('line_items' => 'ChargeBee_CreditNoteEstimateLineItem', 'discounts' => 'ChargeBee_CreditNoteEstimateDiscount', 'taxes' => 'ChargeBee_CreditNoteEstimateTax', 'line_item_taxes' => 'ChargeBee_CreditNoteEstimateLineItemTax'));
+        return $estimate;
     }
     }
 
 
     function plan() 
     function plan() 
     {
     {
-        return $this->_get('plan', 'ChargeBee_Plan');
+        $plan = $this->_get('plan', 'ChargeBee_Plan');
+        return $plan;
     }
     }
 
 
     function addon() 
     function addon() 
     {
     {
-        return $this->_get('addon', 'ChargeBee_Addon');
+        $addon = $this->_get('addon', 'ChargeBee_Addon');
+        return $addon;
     }
     }
 
 
     function coupon() 
     function coupon() 
     {
     {
-        return $this->_get('coupon', 'ChargeBee_Coupon');
+        $coupon = $this->_get('coupon', 'ChargeBee_Coupon');
+        return $coupon;
     }
     }
 
 
     function couponCode() 
     function couponCode() 
     {
     {
-        return $this->_get('coupon_code', 'ChargeBee_CouponCode');
+        $coupon_code = $this->_get('coupon_code', 'ChargeBee_CouponCode');
+        return $coupon_code;
     }
     }
 
 
     function address() 
     function address() 
     {
     {
-        return $this->_get('address', 'ChargeBee_Address');
+        $address = $this->_get('address', 'ChargeBee_Address');
+        return $address;
     }
     }
 
 
     function event() 
     function event() 
     {
     {
-        return $this->_get('event', 'ChargeBee_Event', 
+        $event = $this->_get('event', 'ChargeBee_Event', 
         array('webhooks' => 'ChargeBee_EventWebhook'));
         array('webhooks' => 'ChargeBee_EventWebhook'));
+        return $event;
     }
     }
 
 
     function comment() 
     function comment() 
     {
     {
-        return $this->_get('comment', 'ChargeBee_Comment');
+        $comment = $this->_get('comment', 'ChargeBee_Comment');
+        return $comment;
     }
     }
 
 
     function download() 
     function download() 
     {
     {
-        return $this->_get('download', 'ChargeBee_Download');
+        $download = $this->_get('download', 'ChargeBee_Download');
+        return $download;
     }
     }
 
 
     function portalSession() 
     function portalSession() 
     {
     {
-        return $this->_get('portal_session', 'ChargeBee_PortalSession', 
+        $portal_session = $this->_get('portal_session', 'ChargeBee_PortalSession', 
         array('linked_customers' => 'ChargeBee_PortalSessionLinkedCustomer'));
         array('linked_customers' => 'ChargeBee_PortalSessionLinkedCustomer'));
+        return $portal_session;
     }
     }
 
 
 
 
-    private function _get($type, $class, $subTypes = array())
+    function creditNotes() 
+    {
+        $credit_notes = $this->_getList('credit_notes', 'ChargeBee_CreditNote',
+        array('line_items' => 'ChargeBee_CreditNoteLineItem', 'discounts' => 'ChargeBee_CreditNoteDiscount', 'taxes' => 'ChargeBee_CreditNoteTax', 'line_item_taxes' => 'ChargeBee_CreditNoteLineItemTax', 'linked_refunds' => 'ChargeBee_CreditNoteLinkedRefund', 'allocations' => 'ChargeBee_CreditNoteAllocation'));
+        return $credit_notes;
+    }
+    
+    
+    private function _getList($type, $class, $subTypes = array(), $dependantTypes = array(),  $dependantSubTypes = array())
+    {
+        if(!array_key_exists($type, $this->_response))
+        {
+            return null;
+        }
+        if(!array_key_exists($type, $this->_responseObj))
+        {
+            $setVal = array();
+            foreach($this->_response[$type] as $stV)
+            {
+                $obj = new $class($stV, $subTypes, $dependantTypes);
+                foreach($dependantSubTypes as $k => $v)
+                {
+                    $obj->_initDependant($stV, $k, $v);
+                }
+                array_push($setVal, $obj);
+            }
+            $this->_responseObj[$type] = $setVal;
+        }
+        return $this->_responseObj[$type];        
+    }
+    
+    private function _get($type, $class, $subTypes = array(), $dependantTypes = array())
     {
     {
         if(!array_key_exists($type, $this->_response))
         if(!array_key_exists($type, $this->_response))
         {
         {
@@ -113,7 +176,7 @@ class ChargeBee_Result
         }
         }
         if(!array_key_exists($type, $this->_responseObj))
         if(!array_key_exists($type, $this->_responseObj))
         {
         {
-                $this->_responseObj[$type] = new $class($this->_response[$type], $subTypes);
+                $this->_responseObj[$type] = new $class($this->_response[$type], $subTypes, $dependantTypes);
         }
         }
         return $this->_responseObj[$type];
         return $this->_responseObj[$type];
     }
     }

+ 4 - 0
plugins/chargebee/ChargeBee/Util.php

@@ -60,6 +60,10 @@ class ChargeBee_Util
     {
     {
       $uriPaths = "";
       $uriPaths = "";
       foreach(func_get_args() as $arg) {
       foreach(func_get_args() as $arg) {
+            $arg=trim($arg);
+            if( $arg == null || strlen($arg) < 1 ) {
+                 throw new Exception("Id cannot be null or empty");
+            }
             $uriPaths .= "/" . rawurlencode($arg);
             $uriPaths .= "/" . rawurlencode($arg);
       }
       }
       return $uriPaths;
       return $uriPaths;

+ 1 - 1
plugins/chargebee/ChargeBee/Version.php

@@ -2,7 +2,7 @@
 
 
 final class ChargeBee_Version
 final class ChargeBee_Version
 {
 {
-	  const VERSION = '1.6.4';
+	  const VERSION = '2.0.5';
 }
 }
 
 
 ?>
 ?>