Simplify_Customer

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/Customer.php  
  1. class Simplify_Customer extends Simplify_Object { 
  2. /** 
  3. * Creates an Simplify_Customer object 
  4. * @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  5. * <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. <strong>required </strong></dd> 
  6. * <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. <strong>required </strong></dd> 
  7. * <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder <strong>required </strong></dd> 
  8. * <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. <strong>required </strong></dd> 
  9. * <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. <strong>required </strong></dd> 
  10. * <dt><tt>card.addressZip</tt></dt> <dd>Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. <strong>required </strong></dd> 
  11. * <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 <strong>required </strong></dd> 
  12. * <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 <strong>required </strong></dd> 
  13. * <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 <strong>required </strong></dd> 
  14. * <dt><tt>card.id</tt></dt> <dd>ID of card. Unused during customer create. </dd> 
  15. * <dt><tt>card.name</tt></dt> <dd>Name as appears on the card. <strong>required </strong></dd> 
  16. * <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] </dd> 
  17. * <dt><tt>email</tt></dt> <dd>Email address of the customer <strong>required </strong></dd> 
  18. * <dt><tt>name</tt></dt> <dd>Customer name [min length: 2] <strong>required </strong></dd> 
  19. * <dt><tt>reference</tt></dt> <dd>Reference field for external applications use. </dd> 
  20. * <dt><tt>subscriptions.amount</tt></dt> <dd>Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD </dd> 
  21. * <dt><tt>subscriptions.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> 
  22. * <dt><tt>subscriptions.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> 
  23. * <dt><tt>subscriptions.coupon</tt></dt> <dd>Coupon associated with the subscription for the customer. </dd> 
  24. * <dt><tt>subscriptions.currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [default: USD] </dd> 
  25. * <dt><tt>subscriptions.customer</tt></dt> <dd>The customer ID to create the subscription for. Do not supply this when creating a customer. </dd> 
  26. * <dt><tt>subscriptions.frequency</tt></dt> <dd>Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". </dd> 
  27. * <dt><tt>subscriptions.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> 
  28. * <dt><tt>subscriptions.name</tt></dt> <dd>Name describing subscription </dd> 
  29. * <dt><tt>subscriptions.plan</tt></dt> <dd>The plan ID that the subscription should be created from. </dd> 
  30. * <dt><tt>subscriptions.quantity</tt></dt> <dd>Quantity of the plan for the subscription. [min value: 1] </dd> 
  31. * <dt><tt>subscriptions.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> 
  32. * <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be used </dd></dl> 
  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. * @return Customer a Customer object. 
  35. */ 
  36. static public function createCustomer($hash, $authentication = null) { 
  37.  
  38. $args = func_get_args(); 
  39. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  40.  
  41. $instance = new Simplify_Customer(); 
  42. $instance->setAll($hash); 
  43.  
  44. $object = Simplify_PaymentsApi::createObject($instance, $authentication); 
  45. return $object; 
  46.  
  47.  
  48.  
  49.  
  50. /** 
  51. * Deletes an Simplify_Customer object. 
  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. */ 
  54. public function deleteCustomer($authentication = null) { 
  55.  
  56. $args = func_get_args(); 
  57. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  58.  
  59. $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); 
  60. $this->properties = null; 
  61. return true; 
  62.  
  63.  
  64. /** 
  65. * Retrieve Simplify_Customer objects. 
  66. * @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;"> 
  67. * <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd> 
  68. * <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> 
  69. * <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> 
  70. * <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> id</tt><tt> name</tt><tt> email</tt><tt> reference</tt>.</dd></dl> 
  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 ResourceList a ResourceList object that holds the list of Customer objects and the total 
  73. * number of Customer objects available for the given criteria. 
  74. * @see ResourceList 
  75. */ 
  76. static public function listCustomer($criteria = null, $authentication = null) { 
  77.  
  78. $args = func_get_args(); 
  79. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  80.  
  81. $val = new Simplify_Customer(); 
  82. $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); 
  83.  
  84. return $list; 
  85.  
  86.  
  87. /** 
  88. * Retrieve a Simplify_Customer object from the API 
  89. * @param string id the id of the Customer object to retrieve 
  90. * @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> 
  91. * @return Customer a Customer object 
  92. */ 
  93. static public function findCustomer($id, $authentication = null) { 
  94.  
  95. $args = func_get_args(); 
  96. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); 
  97.  
  98. $val = new Simplify_Customer(); 
  99. $val->id = $id; 
  100.  
  101. $obj = Simplify_PaymentsApi::findObject($val, $authentication); 
  102.  
  103. return $obj; 
  104.  
  105.  
  106. /** 
  107. * Updates an Simplify_Customer object. 
  108. * The properties that can be updated: 
  109. * <dl style="padding-left:10px;"> 
  110. * <dt><tt>card.addressCity</tt></dt> <dd>City of the cardholder. <strong>required </strong></dd> 
  111. * <dt><tt>card.addressCountry</tt></dt> <dd>Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. <strong>required </strong></dd> 
  112. * <dt><tt>card.addressLine1</tt></dt> <dd>Address of the cardholder. <strong>required </strong></dd> 
  113. * <dt><tt>card.addressLine2</tt></dt> <dd>Address of the cardholder if needed. <strong>required </strong></dd> 
  114. * <dt><tt>card.addressState</tt></dt> <dd>State of residence of the cardholder. For the US, this is a 2-digit USPS code. <strong>required </strong></dd> 
  115. * <dt><tt>card.addressZip</tt></dt> <dd>Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. <strong>required </strong></dd> 
  116. * <dt><tt>card.cvc</tt></dt> <dd>CVC security code of the card. This is the code on the back of the card. Example: 123 <strong>required </strong></dd> 
  117. * <dt><tt>card.expMonth</tt></dt> <dd>Expiration month of the card. Format is MM. Example: January = 01 <strong>required </strong></dd> 
  118. * <dt><tt>card.expYear</tt></dt> <dd>Expiration year of the card. Format is YY. Example: 2013 = 13 <strong>required </strong></dd> 
  119. * <dt><tt>card.id</tt></dt> <dd>ID of card. If present, card details for the customer will not be updated. If not present, the customer will be updated with the supplied card details. </dd> 
  120. * <dt><tt>card.name</tt></dt> <dd>Name as appears on the card. <strong>required </strong></dd> 
  121. * <dt><tt>card.number</tt></dt> <dd>Card number as it appears on the card. [max length: 19, min length: 13] </dd> 
  122. * <dt><tt>email</tt></dt> <dd>Email address of the customer <strong>required </strong></dd> 
  123. * <dt><tt>name</tt></dt> <dd>Customer name [min length: 2] <strong>required </strong></dd> 
  124. * <dt><tt>reference</tt></dt> <dd>Reference field for external applications use. </dd> 
  125. * <dt><tt>token</tt></dt> <dd>If specified, card associated with card token will be added to the customer </dd></dl> 
  126. * @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> 
  127. * @return Customer a Customer object. 
  128. */ 
  129. public function updateCustomer($authentication = null) { 
  130.  
  131. $args = func_get_args(); 
  132. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); 
  133.  
  134. $object = Simplify_PaymentsApi::updateObject($this, $authentication); 
  135. return $object; 
  136.  
  137. /** 
  138. * @ignore 
  139. */ 
  140. public function getClazz() { 
  141. return "Customer";