Simplify_Coupon

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/Coupon.php  
  1. class Simplify_Coupon extends Simplify_Object { 
  2. /** 
  3. * Creates an Simplify_Coupon object 
  4. * @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  5. * <dt><tt>amountOff</tt></dt> <dd>Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00USD [min value: 1] </dd> 
  6. * <dt><tt>couponCode</tt></dt> <dd>Code that identifies the coupon to be used. [min length: 2] <strong>required </strong></dd> 
  7. * <dt><tt>description</tt></dt> <dd>A brief section that describes the coupon. </dd> 
  8. * <dt><tt>durationInMonths</tt></dt> <dd>DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999] </dd> 
  9. * <dt><tt>endDate</tt></dt> <dd>Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone. </dd> 
  10. * <dt><tt>maxRedemptions</tt></dt> <dd>Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1] </dd> 
  11. * <dt><tt>numTimesApplied</tt></dt> <dd>The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999] </dd> 
  12. * <dt><tt>percentOff</tt></dt> <dd>Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100] </dd> 
  13. * <dt><tt>startDate</tt></dt> <dd>First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. <strong>required </strong></dd></dl> 
  14. * @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/> 
  15. * @return Coupon a Coupon object. 
  16. */ 
  17. static public function createCoupon($hash, $authentication = null) { 
  18.  
  19. $args = func_get_args(); 
  20. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  21.  
  22. $instance = new Simplify_Coupon(); 
  23. $instance->setAll($hash); 
  24.  
  25. $object = Simplify_PaymentsApi::createObject($instance, $authentication); 
  26. return $object; 
  27.  
  28.  
  29.  
  30.  
  31. /** 
  32. * Deletes an Simplify_Coupon object. 
  33. * @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> 
  34. */ 
  35. public function deleteCoupon($authentication = null) { 
  36.  
  37. $args = func_get_args(); 
  38. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  39.  
  40. $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); 
  41. $this->properties = null; 
  42. return true; 
  43.  
  44.  
  45. /** 
  46. * Retrieve Simplify_Coupon objects. 
  47. * @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  48. * <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd> 
  49. * <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> 
  50. * <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> 
  51. * <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> dateCreated</tt><tt> maxRedemptions</tt><tt> timesRedeemed</tt><tt> id</tt><tt> startDate</tt><tt> endDate</tt><tt> percentOff</tt><tt> couponCode</tt><tt> durationInMonths</tt><tt> numTimesApplied</tt><tt> amountOff</tt>.</dd></dl> 
  52. * @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> 
  53. * @return ResourceList a ResourceList object that holds the list of Coupon objects and the total 
  54. * number of Coupon objects available for the given criteria. 
  55. * @see ResourceList 
  56. */ 
  57. static public function listCoupon($criteria = null, $authentication = null) { 
  58.  
  59. $args = func_get_args(); 
  60. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  61.  
  62. $val = new Simplify_Coupon(); 
  63. $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); 
  64.  
  65. return $list; 
  66.  
  67.  
  68. /** 
  69. * Retrieve a Simplify_Coupon object from the API 
  70. * @param string id the id of the Coupon object to retrieve 
  71. * @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> 
  72. * @return Coupon a Coupon object 
  73. */ 
  74. static public function findCoupon($id, $authentication = null) { 
  75.  
  76. $args = func_get_args(); 
  77. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  78.  
  79. $val = new Simplify_Coupon(); 
  80. $val->id = $id; 
  81.  
  82. $obj = Simplify_PaymentsApi::findObject($val, $authentication); 
  83.  
  84. return $obj; 
  85.  
  86.  
  87. /** 
  88. * Updates an Simplify_Coupon object. 
  89. * The properties that can be updated: 
  90. * <dl style="padding-left:10px;"> 
  91. * <dt><tt>endDate</tt></dt> <dd>The ending date in UTC millis for the coupon. This must be after the starting date of the coupon. </dd> 
  92. * <dt><tt>maxRedemptions</tt></dt> <dd>Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1] </dd></dl> 
  93. * @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> 
  94. * @return Coupon a Coupon object. 
  95. */ 
  96. public function updateCoupon($authentication = null) { 
  97.  
  98. $args = func_get_args(); 
  99. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  100.  
  101. $object = Simplify_PaymentsApi::updateObject($this, $authentication); 
  102. return $object; 
  103.  
  104. /** 
  105. * @ignore 
  106. */ 
  107. public function getClazz() { 
  108. return "Coupon";