Simplify_Subscription

Copyright (c) 2013 - 2015 MasterCard International Incorporated All rights reserved.

Defined (1)

The class is defined in the following location(s).

/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php  
  1. class Simplify_Subscription extends Simplify_Object { 
  2. /** 
  3. * Creates an Simplify_Subscription object 
  4. * @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  5. * <dt><tt>amount</tt></dt> <dd>Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd> 
  6. * <dt><tt>billingCycle</tt></dt> <dd>How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] </dd> 
  7. * <dt><tt>billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd> 
  8. * <dt><tt>coupon</tt></dt> <dd>Coupon ID associated with the subscription </dd> 
  9. * <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd> 
  10. * <dt><tt>customer</tt></dt> <dd>Customer that is enrolling in the subscription. </dd> 
  11. * <dt><tt>frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd> 
  12. * <dt><tt>frequencyPeriod</tt></dt> <dd>Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. </dd> 
  13. * <dt><tt>name</tt></dt> <dd>Name describing subscription </dd> 
  14. * <dt><tt>plan</tt></dt> <dd>The ID of the plan that should be used for the subscription. </dd> 
  15. * <dt><tt>quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd> 
  16. * <dt><tt>renewalReminderLeadDays</tt></dt> <dd>If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set. </dd></dl> 
  17. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/> 
  18. * @return Subscription a Subscription object. 
  19. */ 
  20. static public function createSubscription($hash, $authentication = null) { 
  21.  
  22. $args = func_get_args(); 
  23. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  24.  
  25. $instance = new Simplify_Subscription(); 
  26. $instance->setAll($hash); 
  27.  
  28. $object = Simplify_PaymentsApi::createObject($instance, $authentication); 
  29. return $object; 
  30.  
  31.  
  32.  
  33.  
  34. /** 
  35. * Deletes an Simplify_Subscription object. 
  36. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> 
  37. */ 
  38. public function deleteSubscription($authentication = null) { 
  39.  
  40. $args = func_get_args(); 
  41. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  42.  
  43. $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); 
  44. $this->properties = null; 
  45. return true; 
  46.  
  47.  
  48. /** 
  49. * Retrieve Simplify_Subscription objects. 
  50. * @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  51. * <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd> 
  52. * <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd> 
  53. * <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd> 
  54. * <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> id</tt><tt> plan</tt>.</dd></dl> 
  55. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> 
  56. * @return ResourceList a ResourceList object that holds the list of Subscription objects and the total 
  57. * number of Subscription objects available for the given criteria. 
  58. * @see ResourceList 
  59. */ 
  60. static public function listSubscription($criteria = null, $authentication = null) { 
  61.  
  62. $args = func_get_args(); 
  63. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  64.  
  65. $val = new Simplify_Subscription(); 
  66. $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); 
  67.  
  68. return $list; 
  69.  
  70.  
  71. /** 
  72. * Retrieve a Simplify_Subscription object from the API 
  73. * @param string id the id of the Subscription object to retrieve 
  74. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> 
  75. * @return Subscription a Subscription object 
  76. */ 
  77. static public function findSubscription($id, $authentication = null) { 
  78.  
  79. $args = func_get_args(); 
  80. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  81.  
  82. $val = new Simplify_Subscription(); 
  83. $val->id = $id; 
  84.  
  85. $obj = Simplify_PaymentsApi::findObject($val, $authentication); 
  86.  
  87. return $obj; 
  88.  
  89.  
  90. /** 
  91. * Updates an Simplify_Subscription object. 
  92. * The properties that can be updated: 
  93. * <dl style="padding-left:10px;"> 
  94. * <dt><tt>amount</tt></dt> <dd>Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd> 
  95. * <dt><tt>billingCycle</tt></dt> <dd>How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO] </dd> 
  96. * <dt><tt>billingCycleLimit</tt></dt> <dd>The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4 </dd> 
  97. * <dt><tt>coupon</tt></dt> <dd>Coupon being assigned to this subscription </dd> 
  98. * <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd> 
  99. * <dt><tt>frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd> 
  100. * <dt><tt>frequencyPeriod</tt></dt> <dd>Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1] </dd> 
  101. * <dt><tt>name</tt></dt> <dd>Name describing subscription </dd> 
  102. * <dt><tt>plan</tt></dt> <dd>Plan that should be used for the subscription. </dd> 
  103. * <dt><tt>prorate</tt></dt> <dd>Whether to prorate existing subscription. [default: true] <strong>required </strong></dd> 
  104. * <dt><tt>quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd> 
  105. * <dt><tt>renewalReminderLeadDays</tt></dt> <dd>If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set. </dd></dl> 
  106. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i> 
  107. * @return Subscription a Subscription object. 
  108. */ 
  109. public function updateSubscription($authentication = null) { 
  110.  
  111. $args = func_get_args(); 
  112. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  113.  
  114. $object = Simplify_PaymentsApi::updateObject($this, $authentication); 
  115. return $object; 
  116.  
  117. /** 
  118. * @ignore 
  119. */ 
  120. public function getClazz() { 
  121. return "Subscription";