Invoice.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Stripe;
  3. /**
  4. * Class Invoice
  5. *
  6. * @package Stripe
  7. */
  8. class Invoice extends ApiResource
  9. {
  10. /**
  11. * @param array|null $params
  12. * @param array|string|null $opts
  13. *
  14. * @return Invoice The created invoice.
  15. */
  16. public static function create($params = null, $opts = null)
  17. {
  18. return self::_create($params, $opts);
  19. }
  20. /**
  21. * @param string $id The ID of the invoice to retrieve.
  22. * @param array|string|null $opts
  23. *
  24. * @return Invoice
  25. */
  26. public static function retrieve($id, $opts = null)
  27. {
  28. return self::_retrieve($id, $opts);
  29. }
  30. /**
  31. * @param array|null $params
  32. * @param array|string|null $opts
  33. *
  34. * @return Collection of Invoices
  35. */
  36. public static function all($params = null, $opts = null)
  37. {
  38. return self::_all($params, $opts);
  39. }
  40. /**
  41. * @param string $id The ID of the invoice to update.
  42. * @param array|null $params
  43. * @param array|string|null $options
  44. *
  45. * @return Invoice The updated invoice.
  46. */
  47. public static function update($id, $params = null, $options = null)
  48. {
  49. return self::_update($id, $params, $options);
  50. }
  51. /**
  52. * @param array|null $params
  53. * @param array|string|null $opts
  54. *
  55. * @return Invoice The upcoming invoice.
  56. */
  57. public static function upcoming($params = null, $opts = null)
  58. {
  59. $url = static::classUrl() . '/upcoming';
  60. list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
  61. $obj = Util\Util::convertToStripeObject($response->json, $opts);
  62. $obj->setLastResponse($response);
  63. return $obj;
  64. }
  65. /**
  66. * @param array|string|null $opts
  67. *
  68. * @return Invoice The saved invoice.
  69. */
  70. public function save($opts = null)
  71. {
  72. return $this->_save($opts);
  73. }
  74. /**
  75. * @return Invoice The paid invoice.
  76. */
  77. public function pay($opts = null)
  78. {
  79. $url = $this->instanceUrl() . '/pay';
  80. list($response, $opts) = $this->_request('post', $url, null, $opts);
  81. $this->refreshFrom($response, $opts);
  82. return $this;
  83. }
  84. }