BitcoinReceiver.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Stripe;
  3. /**
  4. * Class BitcoinReceiver
  5. *
  6. * @package Stripe
  7. */
  8. class BitcoinReceiver extends ExternalAccount
  9. {
  10. /**
  11. * @return string The class URL for this resource. It needs to be special
  12. * cased because it doesn't fit into the standard resource pattern.
  13. */
  14. public static function classUrl()
  15. {
  16. return "/v1/bitcoin/receivers";
  17. }
  18. /**
  19. * @return string The instance URL for this resource. It needs to be special
  20. * cased because it doesn't fit into the standard resource pattern.
  21. */
  22. public function instanceUrl()
  23. {
  24. $result = parent::instanceUrl();
  25. if ($result) {
  26. return $result;
  27. } else {
  28. $id = $this['id'];
  29. $id = Util\Util::utf8($id);
  30. $extn = urlencode($id);
  31. $base = BitcoinReceiver::classUrl();
  32. return "$base/$extn";
  33. }
  34. }
  35. /**
  36. * @param string $id The ID of the Bitcoin Receiver to retrieve.
  37. * @param array|string|null $opts
  38. *
  39. * @return BitcoinReceiver
  40. */
  41. public static function retrieve($id, $opts = null)
  42. {
  43. return self::_retrieve($id, $opts);
  44. }
  45. /**
  46. * @param array|null $params
  47. * @param array|string|null $opts
  48. *
  49. * @return Collection of BitcoinReceivers
  50. */
  51. public static function all($params = null, $opts = null)
  52. {
  53. return self::_all($params, $opts);
  54. }
  55. /**
  56. * @param array|null $params
  57. * @param array|string|null $opts
  58. *
  59. * @return BitcoinReceiver The created Bitcoin Receiver item.
  60. */
  61. public static function create($params = null, $opts = null)
  62. {
  63. return self::_create($params, $opts);
  64. }
  65. /**
  66. * @param array|null $params
  67. * @param array|string|null $options
  68. *
  69. * @return BitcoinReceiver The refunded Bitcoin Receiver item.
  70. */
  71. public function refund($params = null, $options = null)
  72. {
  73. $url = $this->instanceUrl() . '/refund';
  74. list($response, $opts) = $this->_request('post', $url, $params, $options);
  75. $this->refreshFrom($response, $opts);
  76. return $this;
  77. }
  78. }