Authorization.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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
  6. * make a purchase, an Issuing <code>Authorization</code> object is created. <a
  7. * href="https://stripe.com/docs/issuing/purchases/authorizations">Authorizations</a>
  8. * must be approved for the purchase to be completed successfully.
  9. *
  10. * Related guide: <a
  11. * href="https://stripe.com/docs/issuing/purchases/authorizations">Issued Card
  12. * Authorizations</a>.
  13. *
  14. * @property string $id Unique identifier for the object.
  15. * @property string $object String representing the object's type. Objects of the same type share the same value.
  16. * @property int $amount The total amount that was authorized or rejected. This amount is in the card's currency and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>.
  17. * @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>.
  18. * @property bool $approved Whether the authorization has been approved.
  19. * @property string $authorization_method How the card details were provided.
  20. * @property \Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with this authorization.
  21. * @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.
  22. * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this authorization belongs.
  23. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  24. * @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>.
  25. * @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.
  26. * @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>.
  27. * @property string $merchant_currency The currency that was presented to the cardholder for the 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>.
  28. * @property \Stripe\StripeObject $merchant_data
  29. * @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.
  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 the authorization was approved/denied (whether approved/denied by you directly or by Stripe based on your <code>spending_controls</code>). If the merchant changes the authorization by performing an <a href="https://stripe.com/docs/issuing/purchases/authorizations">incremental authorization or partial capture</a>, you can look at this field to see the previous states of the authorization.
  32. * @property string $status The current status of the authorization in its lifecycle.
  33. * @property \Stripe\Issuing\Transaction[] $transactions List of <a href="https://stripe.com/docs/api/issuing/transactions">transactions</a> associated with this authorization.
  34. * @property \Stripe\StripeObject $verification_data
  35. * @property null|string $wallet What, if any, digital wallet was used for this authorization. One of <code>apple_pay</code>, <code>google_pay</code>, or <code>samsung_pay</code>.
  36. */
  37. class Authorization extends \Stripe\ApiResource
  38. {
  39. const OBJECT_NAME = 'issuing.authorization';
  40. use \Stripe\ApiOperations\All;
  41. use \Stripe\ApiOperations\Retrieve;
  42. use \Stripe\ApiOperations\Update;
  43. /**
  44. * @param null|array $params
  45. * @param null|array|string $opts
  46. *
  47. * @throws \Stripe\Exception\ApiErrorException if the request fails
  48. *
  49. * @return Authorization the approved authorization
  50. */
  51. public function approve($params = null, $opts = null)
  52. {
  53. $url = $this->instanceUrl() . '/approve';
  54. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  55. $this->refreshFrom($response, $opts);
  56. return $this;
  57. }
  58. /**
  59. * @param null|array $params
  60. * @param null|array|string $opts
  61. *
  62. * @throws \Stripe\Exception\ApiErrorException if the request fails
  63. *
  64. * @return Authorization the declined authorization
  65. */
  66. public function decline($params = null, $opts = null)
  67. {
  68. $url = $this->instanceUrl() . '/decline';
  69. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  70. $this->refreshFrom($response, $opts);
  71. return $this;
  72. }
  73. }