Authorization.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Issuing;
  4. /**
  5. * When an <a href="https://stripe.com/docs/issuing">issued card</a> is used to make a purchase, an Issuing <code>Authorization</code>
  6. * object is created. <a href="https://stripe.com/docs/issuing/purchases/authorizations">Authorizations</a> must be approved for the
  7. * purchase to be completed successfully.
  8. *
  9. * Related guide: <a href="https://stripe.com/docs/issuing/purchases/authorizations">Issued card authorizations</a>
  10. *
  11. * @property string $id Unique identifier for the object.
  12. * @property string $object String representing the object's type. Objects of the same type share the same value.
  13. * @property int $amount The total amount that was authorized or rejected. This amount is in <code>currency</code> and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. <code>amount</code> should be the same as <code>merchant_amount</code>, unless <code>currency</code> and <code>merchant_currency</code> are different.
  14. * @property null|\Stripe\StripeObject $amount_details Detailed breakdown of amount components. These amounts are denominated in <code>currency</code> and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>.
  15. * @property bool $approved Whether the authorization has been approved.
  16. * @property string $authorization_method How the card details were provided.
  17. * @property \Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with this authorization.
  18. * @property \Stripe\Issuing\Card $card You can <a href="https://stripe.com/docs/issuing/cards">create physical or virtual cards</a> that are issued to cardholders.
  19. * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this authorization belongs.
  20. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  21. * @property string $currency The currency of the cardholder. This currency can be different from the currency presented at authorization and the <code>merchant_currency</code> field on this authorization. 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>.
  22. * @property null|\Stripe\StripeObject $fleet Fleet-specific information for authorizations using Fleet cards.
  23. * @property null|\Stripe\StripeObject $fuel Information about fuel that was purchased with this transaction. Typically this information is received from the merchant after the authorization has been approved and the fuel dispensed.
  24. * @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.
  25. * @property int $merchant_amount The total amount that was authorized or rejected. This amount is in the <code>merchant_currency</code> and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. <code>merchant_amount</code> should be the same as <code>amount</code>, unless <code>merchant_currency</code> and <code>currency</code> are different.
  26. * @property string $merchant_currency The local currency that was presented to the cardholder for the authorization. This currency can be different from the cardholder currency and the <code>currency</code> field on this authorization. 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>.
  27. * @property \Stripe\StripeObject $merchant_data
  28. * @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.
  29. * @property null|\Stripe\StripeObject $network_data Details about the authorization, such as identifiers, set by the card network.
  30. * @property null|\Stripe\StripeObject $pending_request The pending authorization request. This field will only be non-null during an <code>issuing_authorization.request</code> webhook.
  31. * @property \Stripe\StripeObject[] $request_history History of every time a <code>pending_request</code> authorization was approved/declined, either by you directly or by Stripe (e.g. based on your spending_controls). If the merchant changes the authorization by performing an incremental authorization, you can look at this field to see the previous requests for the authorization. This field can be helpful in determining why a given authorization was approved/declined.
  32. * @property string $status The current status of the authorization in its lifecycle.
  33. * @property null|string|\Stripe\Issuing\Token $token <a href="https://stripe.com/docs/api/issuing/tokens/object">Token</a> object used for this authorization. If a network token was not used for this authorization, this field will be null.
  34. * @property \Stripe\Issuing\Transaction[] $transactions List of <a href="https://stripe.com/docs/api/issuing/transactions">transactions</a> associated with this authorization.
  35. * @property null|\Stripe\StripeObject $treasury <a href="https://stripe.com/docs/api/treasury">Treasury</a> details related to this authorization if it was created on a <a href="https://stripe.com/docs/api/treasury/financial_accounts">FinancialAccount</a>.
  36. * @property \Stripe\StripeObject $verification_data
  37. * @property null|string $wallet The digital wallet used for this transaction. One of <code>apple_pay</code>, <code>google_pay</code>, or <code>samsung_pay</code>. Will populate as <code>null</code> when no digital wallet was utilized.
  38. */
  39. class Authorization extends \Stripe\ApiResource
  40. {
  41. const OBJECT_NAME = 'issuing.authorization';
  42. use \Stripe\ApiOperations\Update;
  43. const AUTHORIZATION_METHOD_CHIP = 'chip';
  44. const AUTHORIZATION_METHOD_CONTACTLESS = 'contactless';
  45. const AUTHORIZATION_METHOD_KEYED_IN = 'keyed_in';
  46. const AUTHORIZATION_METHOD_ONLINE = 'online';
  47. const AUTHORIZATION_METHOD_SWIPE = 'swipe';
  48. const STATUS_CLOSED = 'closed';
  49. const STATUS_PENDING = 'pending';
  50. const STATUS_REVERSED = 'reversed';
  51. /**
  52. * Returns a list of Issuing <code>Authorization</code> objects. The objects are
  53. * sorted in descending order by creation date, with the most recently created
  54. * object appearing first.
  55. *
  56. * @param null|array $params
  57. * @param null|array|string $opts
  58. *
  59. * @throws \Stripe\Exception\ApiErrorException if the request fails
  60. *
  61. * @return \Stripe\Collection<\Stripe\Issuing\Authorization> of ApiResources
  62. */
  63. public static function all($params = null, $opts = null)
  64. {
  65. $url = static::classUrl();
  66. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  67. }
  68. /**
  69. * Retrieves an Issuing <code>Authorization</code> object.
  70. *
  71. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  72. * @param null|array|string $opts
  73. *
  74. * @throws \Stripe\Exception\ApiErrorException if the request fails
  75. *
  76. * @return \Stripe\Issuing\Authorization
  77. */
  78. public static function retrieve($id, $opts = null)
  79. {
  80. $opts = \Stripe\Util\RequestOptions::parse($opts);
  81. $instance = new static($id, $opts);
  82. $instance->refresh();
  83. return $instance;
  84. }
  85. /**
  86. * Updates the specified Issuing <code>Authorization</code> object by setting the
  87. * values of the parameters passed. Any parameters not provided will be left
  88. * unchanged.
  89. *
  90. * @param string $id the ID of the resource to update
  91. * @param null|array $params
  92. * @param null|array|string $opts
  93. *
  94. * @throws \Stripe\Exception\ApiErrorException if the request fails
  95. *
  96. * @return \Stripe\Issuing\Authorization the updated resource
  97. */
  98. public static function update($id, $params = null, $opts = null)
  99. {
  100. self::_validateParams($params);
  101. $url = static::resourceUrl($id);
  102. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  103. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  104. $obj->setLastResponse($response);
  105. return $obj;
  106. }
  107. /**
  108. * @param null|array $params
  109. * @param null|array|string $opts
  110. *
  111. * @throws \Stripe\Exception\ApiErrorException if the request fails
  112. *
  113. * @return \Stripe\Issuing\Authorization the approved authorization
  114. */
  115. public function approve($params = null, $opts = null)
  116. {
  117. $url = $this->instanceUrl() . '/approve';
  118. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  119. $this->refreshFrom($response, $opts);
  120. return $this;
  121. }
  122. /**
  123. * @param null|array $params
  124. * @param null|array|string $opts
  125. *
  126. * @throws \Stripe\Exception\ApiErrorException if the request fails
  127. *
  128. * @return \Stripe\Issuing\Authorization the declined authorization
  129. */
  130. public function decline($params = null, $opts = null)
  131. {
  132. $url = $this->instanceUrl() . '/decline';
  133. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  134. $this->refreshFrom($response, $opts);
  135. return $this;
  136. }
  137. }