InboundTransfer.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Treasury;
  4. /**
  5. * Use <a href="https://stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers">InboundTransfers</a> to add funds to your <a href="https://stripe.com/docs/api#financial_accounts">FinancialAccount</a> via a PaymentMethod that is owned by you. The funds will be transferred via an ACH debit.
  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 bool $cancelable Returns <code>true</code> if the InboundTransfer is able to be canceled.
  11. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  12. * @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>.
  13. * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
  14. * @property null|\Stripe\StripeObject $failure_details Details about this InboundTransfer's failure. Only set when status is <code>failed</code>.
  15. * @property string $financial_account The FinancialAccount that received the funds.
  16. * @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.
  17. * @property \Stripe\StripeObject $linked_flows
  18. * @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.
  19. * @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.
  20. * @property string $origin_payment_method The origin payment method to be debited for an InboundTransfer.
  21. * @property null|\Stripe\StripeObject $origin_payment_method_details Details about the PaymentMethod for an InboundTransfer.
  22. * @property null|bool $returned Returns <code>true</code> if the funds for an InboundTransfer were returned after the InboundTransfer went to the <code>succeeded</code> state.
  23. * @property string $statement_descriptor Statement descriptor shown when funds are debited from the source. Not all payment networks support <code>statement_descriptor</code>.
  24. * @property string $status Status of the InboundTransfer: <code>processing</code>, <code>succeeded</code>, <code>failed</code>, and <code>canceled</code>. An InboundTransfer is <code>processing</code> if it is created and pending. The status changes to <code>succeeded</code> once the funds have been &quot;confirmed&quot; and a <code>transaction</code> is created and posted. The status changes to <code>failed</code> if the transfer fails.
  25. * @property \Stripe\StripeObject $status_transitions
  26. * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object.
  27. */
  28. class InboundTransfer extends \Stripe\ApiResource
  29. {
  30. const OBJECT_NAME = 'treasury.inbound_transfer';
  31. const STATUS_CANCELED = 'canceled';
  32. const STATUS_FAILED = 'failed';
  33. const STATUS_PROCESSING = 'processing';
  34. const STATUS_SUCCEEDED = 'succeeded';
  35. /**
  36. * Creates an InboundTransfer.
  37. *
  38. * @param null|array $params
  39. * @param null|array|string $options
  40. *
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return \Stripe\Treasury\InboundTransfer the created resource
  44. */
  45. public static function create($params = null, $options = null)
  46. {
  47. self::_validateParams($params);
  48. $url = static::classUrl();
  49. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  50. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  51. $obj->setLastResponse($response);
  52. return $obj;
  53. }
  54. /**
  55. * Returns a list of InboundTransfers sent from the specified FinancialAccount.
  56. *
  57. * @param null|array $params
  58. * @param null|array|string $opts
  59. *
  60. * @throws \Stripe\Exception\ApiErrorException if the request fails
  61. *
  62. * @return \Stripe\Collection<\Stripe\Treasury\InboundTransfer> of ApiResources
  63. */
  64. public static function all($params = null, $opts = null)
  65. {
  66. $url = static::classUrl();
  67. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  68. }
  69. /**
  70. * Retrieves the details of an existing InboundTransfer.
  71. *
  72. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  73. * @param null|array|string $opts
  74. *
  75. * @throws \Stripe\Exception\ApiErrorException if the request fails
  76. *
  77. * @return \Stripe\Treasury\InboundTransfer
  78. */
  79. public static function retrieve($id, $opts = null)
  80. {
  81. $opts = \Stripe\Util\RequestOptions::parse($opts);
  82. $instance = new static($id, $opts);
  83. $instance->refresh();
  84. return $instance;
  85. }
  86. /**
  87. * @param null|array $params
  88. * @param null|array|string $opts
  89. *
  90. * @throws \Stripe\Exception\ApiErrorException if the request fails
  91. *
  92. * @return \Stripe\Treasury\InboundTransfer the canceled inbound transfer
  93. */
  94. public function cancel($params = null, $opts = null)
  95. {
  96. $url = $this->instanceUrl() . '/cancel';
  97. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  98. $this->refreshFrom($response, $opts);
  99. return $this;
  100. }
  101. }