CreditReversal.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Treasury;
  4. /**
  5. * You can reverse some <a href="https://stripe.com/docs/api#received_credits">ReceivedCredits</a> depending on their network and source flow. Reversing a ReceivedCredit leads to the creation of a new object known as a CreditReversal.
  6. *
  7. * @property string $id Unique identifier for the object.
  8. * @property string $object String representing the object's type. Objects of the same type share the same value.
  9. * @property int $amount Amount (in cents) transferred.
  10. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  11. * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
  12. * @property string $financial_account The FinancialAccount to reverse funds from.
  13. * @property null|string $hosted_regulatory_receipt_url A <a href="https://stripe.com/docs/treasury/moving-money/regulatory-receipts">hosted transaction receipt</a> URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.
  14. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  15. * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  16. * @property string $network The rails used to reverse the funds.
  17. * @property string $received_credit The ReceivedCredit being reversed.
  18. * @property string $status Status of the CreditReversal
  19. * @property \Stripe\StripeObject $status_transitions
  20. * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object.
  21. */
  22. class CreditReversal extends \Stripe\ApiResource
  23. {
  24. const OBJECT_NAME = 'treasury.credit_reversal';
  25. const NETWORK_ACH = 'ach';
  26. const NETWORK_STRIPE = 'stripe';
  27. const STATUS_CANCELED = 'canceled';
  28. const STATUS_POSTED = 'posted';
  29. const STATUS_PROCESSING = 'processing';
  30. /**
  31. * Reverses a ReceivedCredit and creates a CreditReversal object.
  32. *
  33. * @param null|array $params
  34. * @param null|array|string $options
  35. *
  36. * @throws \Stripe\Exception\ApiErrorException if the request fails
  37. *
  38. * @return \Stripe\Treasury\CreditReversal the created resource
  39. */
  40. public static function create($params = null, $options = null)
  41. {
  42. self::_validateParams($params);
  43. $url = static::classUrl();
  44. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  45. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  46. $obj->setLastResponse($response);
  47. return $obj;
  48. }
  49. /**
  50. * Returns a list of CreditReversals.
  51. *
  52. * @param null|array $params
  53. * @param null|array|string $opts
  54. *
  55. * @throws \Stripe\Exception\ApiErrorException if the request fails
  56. *
  57. * @return \Stripe\Collection<\Stripe\Treasury\CreditReversal> of ApiResources
  58. */
  59. public static function all($params = null, $opts = null)
  60. {
  61. $url = static::classUrl();
  62. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  63. }
  64. /**
  65. * Retrieves the details of an existing CreditReversal by passing the unique
  66. * CreditReversal ID from either the CreditReversal creation request or
  67. * CreditReversal list.
  68. *
  69. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  70. * @param null|array|string $opts
  71. *
  72. * @throws \Stripe\Exception\ApiErrorException if the request fails
  73. *
  74. * @return \Stripe\Treasury\CreditReversal
  75. */
  76. public static function retrieve($id, $opts = null)
  77. {
  78. $opts = \Stripe\Util\RequestOptions::parse($opts);
  79. $instance = new static($id, $opts);
  80. $instance->refresh();
  81. return $instance;
  82. }
  83. }