PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php

https://gitlab.com/webkod3r/tripolis
PHP | 224 lines | 42 code | 27 blank | 155 comment | 0 complexity | 0aa50bee6bf4638e37d4b10b130fe6a7 MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright (c) 2013 - 2015 MasterCard International Incorporated
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification, are
  7. * permitted provided that the following conditions are met:
  8. *
  9. * Redistributions of source code must retain the above copyright notice, this list of
  10. * conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright notice, this list of
  12. * conditions and the following disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. * Neither the name of the MasterCard International Incorporated nor the names of its
  15. * contributors may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  20. * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  22. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  24. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  25. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. */
  28. class Simplify_Invoice extends Simplify_Object {
  29. /**
  30. * Creates an Simplify_Invoice object
  31. * @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
  32. * <dt><tt>billingAddress.city</tt></dt> <dd>Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
  33. * <dt><tt>billingAddress.country</tt></dt> <dd>Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
  34. * <dt><tt>billingAddress.line1</tt></dt> <dd>Billing address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
  35. * <dt><tt>billingAddress.line2</tt></dt> <dd>Billing address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
  36. * <dt><tt>billingAddress.name</tt></dt> <dd>Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255] </dd>
  37. * <dt><tt>billingAddress.state</tt></dt> <dd>Billing address state of the location where the goods or services were supplied. [max length: 255] </dd>
  38. * <dt><tt>billingAddress.zip</tt></dt> <dd>Billing address zip of the location where the goods or services were supplied. [max length: 32] </dd>
  39. * <dt><tt>businessAddress.city</tt></dt> <dd>Address city of the business that is sending the invoice. [max length: 255, min length: 2] </dd>
  40. * <dt><tt>businessAddress.country</tt></dt> <dd>Address country of the business that is sending the invoice. [max length: 2, min length: 2] </dd>
  41. * <dt><tt>businessAddress.line1</tt></dt> <dd>Address line 1 of the business that is sending the invoice. [max length: 255] </dd>
  42. * <dt><tt>businessAddress.line2</tt></dt> <dd>Address line 2 of the business that is sending the invoice. [max length: 255] </dd>
  43. * <dt><tt>businessAddress.name</tt></dt> <dd>The name of the business that is sending the invoice. [max length: 255] </dd>
  44. * <dt><tt>businessAddress.state</tt></dt> <dd>Address state of the business that is sending the invoice. [max length: 255] </dd>
  45. * <dt><tt>businessAddress.zip</tt></dt> <dd>Address zip of the business that is sending the invoice. [max length: 32] </dd>
  46. * <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD] </dd>
  47. * <dt><tt>customer</tt></dt> <dd>The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided </dd>
  48. * <dt><tt>customerTaxNo</tt></dt> <dd>The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] </dd>
  49. * <dt><tt>discountRate</tt></dt> <dd>The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6] </dd>
  50. * <dt><tt>dueDate</tt></dt> <dd>The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past. </dd>
  51. * <dt><tt>email</tt></dt> <dd>The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. </dd>
  52. * <dt><tt>invoiceId</tt></dt> <dd>User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] </dd>
  53. * <dt><tt>invoiceToCopy</tt></dt> <dd>The id of an existing invoice to be copied. This is optional if customer or a name and email are provided </dd>
  54. * <dt><tt>items.amount</tt></dt> <dd>Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] <strong>required </strong></dd>
  55. * <dt><tt>items.description</tt></dt> <dd>The description of the invoice item. [max length: 1024] </dd>
  56. * <dt><tt>items.invoice</tt></dt> <dd>The ID of the invoice this item belongs to. </dd>
  57. * <dt><tt>items.product</tt></dt> <dd>The product this invoice item refers to. </dd>
  58. * <dt><tt>items.quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] </dd>
  59. * <dt><tt>items.reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
  60. * <dt><tt>items.tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd>
  61. * <dt><tt>lateFee</tt></dt> <dd>The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900] </dd>
  62. * <dt><tt>memo</tt></dt> <dd>A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] </dd>
  63. * <dt><tt>name</tt></dt> <dd>The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2] </dd>
  64. * <dt><tt>note</tt></dt> <dd>This field can be used to store a note that is not displayed to the customer. [max length: 4000] </dd>
  65. * <dt><tt>reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
  66. * <dt><tt>shippingAddress.city</tt></dt> <dd>Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
  67. * <dt><tt>shippingAddress.country</tt></dt> <dd>Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
  68. * <dt><tt>shippingAddress.line1</tt></dt> <dd>Address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
  69. * <dt><tt>shippingAddress.line2</tt></dt> <dd>Address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
  70. * <dt><tt>shippingAddress.name</tt></dt> <dd>Address name of the location where the goods or services were supplied. [max length: 255] </dd>
  71. * <dt><tt>shippingAddress.state</tt></dt> <dd>Address state of the location where the goods or services were supplied. [max length: 255] </dd>
  72. * <dt><tt>shippingAddress.zip</tt></dt> <dd>Address zip of the location where the goods or services were supplied. [max length: 32] </dd>
  73. * <dt><tt>suppliedDate</tt></dt> <dd>The date on which the goods or services were supplied. </dd>
  74. * <dt><tt>taxNo</tt></dt> <dd>The tax number or VAT id of the person who supplied the goods or services. [max length: 255] </dd>
  75. * <dt><tt>type</tt></dt> <dd>The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB] </dd></dl>
  76. * @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/>
  77. * @return Invoice a Invoice object.
  78. */
  79. static public function createInvoice($hash, $authentication = null) {
  80. $args = func_get_args();
  81. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  82. $instance = new Simplify_Invoice();
  83. $instance->setAll($hash);
  84. $object = Simplify_PaymentsApi::createObject($instance, $authentication);
  85. return $object;
  86. }
  87. /**
  88. * Deletes an Simplify_Invoice object.
  89. *
  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. */
  92. public function deleteInvoice($authentication = null) {
  93. $args = func_get_args();
  94. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
  95. $obj = Simplify_PaymentsApi::deleteObject($this, $authentication);
  96. $this->properties = null;
  97. return true;
  98. }
  99. /**
  100. * Retrieve Simplify_Invoice objects.
  101. * @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
  102. * <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
  103. * <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>
  104. * <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>
  105. * <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> invoiceDate</tt><tt> dueDate</tt><tt> datePaid</tt><tt> customer</tt><tt> status</tt><tt> dateCreated</tt>.</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 ResourceList a ResourceList object that holds the list of Invoice objects and the total
  108. * number of Invoice objects available for the given criteria.
  109. * @see ResourceList
  110. */
  111. static public function listInvoice($criteria = null, $authentication = null) {
  112. $args = func_get_args();
  113. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  114. $val = new Simplify_Invoice();
  115. $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
  116. return $list;
  117. }
  118. /**
  119. * Retrieve a Simplify_Invoice object from the API
  120. *
  121. * @param string id the id of the Invoice object to retrieve
  122. * @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>
  123. * @return Invoice a Invoice object
  124. */
  125. static public function findInvoice($id, $authentication = null) {
  126. $args = func_get_args();
  127. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  128. $val = new Simplify_Invoice();
  129. $val->id = $id;
  130. $obj = Simplify_PaymentsApi::findObject($val, $authentication);
  131. return $obj;
  132. }
  133. /**
  134. * Updates an Simplify_Invoice object.
  135. *
  136. * The properties that can be updated:
  137. * <dl style="padding-left:10px;">
  138. * <dt><tt>billingAddress.city</tt></dt> <dd>Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
  139. * <dt><tt>billingAddress.country</tt></dt> <dd>Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
  140. * <dt><tt>billingAddress.line1</tt></dt> <dd>Billing address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
  141. * <dt><tt>billingAddress.line2</tt></dt> <dd>Billing address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
  142. * <dt><tt>billingAddress.name</tt></dt> <dd>Billing address name of the location where the goods or services were supplied. [max length: 255] </dd>
  143. * <dt><tt>billingAddress.state</tt></dt> <dd>Billing address state of the location where the goods or services were supplied. [max length: 255] </dd>
  144. * <dt><tt>billingAddress.zip</tt></dt> <dd>Billing address zip of the location where the goods or services were supplied. [max length: 32] </dd>
  145. * <dt><tt>businessAddress.city</tt></dt> <dd>Business address city of the business that is sending the invoice. [max length: 255, min length: 2] </dd>
  146. * <dt><tt>businessAddress.country</tt></dt> <dd>Business address country of the business that is sending the invoice. [max length: 2, min length: 2] </dd>
  147. * <dt><tt>businessAddress.line1</tt></dt> <dd>Business address line 1 of the business that is sending the invoice. [max length: 255] </dd>
  148. * <dt><tt>businessAddress.line2</tt></dt> <dd>Business address line 2 of the business that is sending the invoice. [max length: 255] </dd>
  149. * <dt><tt>businessAddress.name</tt></dt> <dd>Business address name of the business that is sending the invoice. [max length: 255] </dd>
  150. * <dt><tt>businessAddress.state</tt></dt> <dd>Business address state of the business that is sending the invoice. [max length: 255] </dd>
  151. * <dt><tt>businessAddress.zip</tt></dt> <dd>Business address zip of the business that is sending the invoice. [max length: 32] </dd>
  152. * <dt><tt>currency</tt></dt> <dd>Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3] </dd>
  153. * <dt><tt>customerTaxNo</tt></dt> <dd>The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255] </dd>
  154. * <dt><tt>datePaid</tt></dt> <dd>This is the date the invoice was PAID in UTC millis. </dd>
  155. * <dt><tt>discountRate</tt></dt> <dd>The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6] </dd>
  156. * <dt><tt>dueDate</tt></dt> <dd>The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past. </dd>
  157. * <dt><tt>email</tt></dt> <dd>The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. </dd>
  158. * <dt><tt>invoiceId</tt></dt> <dd>User defined invoice id. If not provided the system will generate a numeric id. [max length: 255] </dd>
  159. * <dt><tt>items.amount</tt></dt> <dd>Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] <strong>required </strong></dd>
  160. * <dt><tt>items.description</tt></dt> <dd>The description of the invoice item. [max length: 1024] </dd>
  161. * <dt><tt>items.invoice</tt></dt> <dd>The ID of the invoice this item belongs to. </dd>
  162. * <dt><tt>items.product</tt></dt> <dd>The Id of the product this item refers to. </dd>
  163. * <dt><tt>items.quantity</tt></dt> <dd>Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] </dd>
  164. * <dt><tt>items.reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
  165. * <dt><tt>items.tax</tt></dt> <dd>The tax ID of the tax charge in the invoice item. </dd>
  166. * <dt><tt>lateFee</tt></dt> <dd>The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900] </dd>
  167. * <dt><tt>memo</tt></dt> <dd>A memo that is displayed to the customer on the invoice payment screen. [max length: 4000] </dd>
  168. * <dt><tt>name</tt></dt> <dd>The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2] </dd>
  169. * <dt><tt>note</tt></dt> <dd>This field can be used to store a note that is not displayed to the customer. [max length: 4000] </dd>
  170. * <dt><tt>payment</tt></dt> <dd>The ID of the payment. Use this ID to query the /payment API. [max length: 255] </dd>
  171. * <dt><tt>reference</tt></dt> <dd>User defined reference field. [max length: 255] </dd>
  172. * <dt><tt>shippingAddress.city</tt></dt> <dd>Address city of the location where the goods or services were supplied. [max length: 255, min length: 2] </dd>
  173. * <dt><tt>shippingAddress.country</tt></dt> <dd>Address country of the location where the goods or services were supplied. [max length: 2, min length: 2] </dd>
  174. * <dt><tt>shippingAddress.line1</tt></dt> <dd>Address line 1 of the location where the goods or services were supplied. [max length: 255] </dd>
  175. * <dt><tt>shippingAddress.line2</tt></dt> <dd>Address line 2 of the location where the goods or services were supplied. [max length: 255] </dd>
  176. * <dt><tt>shippingAddress.name</tt></dt> <dd>Address name of the location where the goods or services were supplied. [max length: 255] </dd>
  177. * <dt><tt>shippingAddress.state</tt></dt> <dd>Address state of the location where the goods or services were supplied. [max length: 255] </dd>
  178. * <dt><tt>shippingAddress.zip</tt></dt> <dd>Address zip of the location where the goods or services were supplied. [max length: 32] </dd>
  179. * <dt><tt>status</tt></dt> <dd>New status of the invoice. </dd>
  180. * <dt><tt>suppliedDate</tt></dt> <dd>The date on which the goods or services were supplied. </dd>
  181. * <dt><tt>taxNo</tt></dt> <dd>The tax number or VAT id of the person who supplied the goods or services. [max length: 255] </dd></dl>
  182. * @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>
  183. * @return Invoice a Invoice object.
  184. */
  185. public function updateInvoice($authentication = null) {
  186. $args = func_get_args();
  187. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
  188. $object = Simplify_PaymentsApi::updateObject($this, $authentication);
  189. return $object;
  190. }
  191. /**
  192. * @ignore
  193. */
  194. public function getClazz() {
  195. return "Invoice";
  196. }
  197. }