Card.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Issuing;
  4. /**
  5. * You can <a href="https://stripe.com/docs/issuing/cards">create physical or virtual cards</a> that are issued to cardholders.
  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 string $brand The brand of the card.
  10. * @property null|string $cancellation_reason The reason why the card was canceled.
  11. * @property \Stripe\Issuing\Cardholder $cardholder <p>An Issuing <code>Cardholder</code> object represents an individual or business entity who is <a href="https://stripe.com/docs/issuing">issued</a> cards.</p><p>Related guide: <a href="https://stripe.com/docs/issuing/cards#create-cardholder">How to create a cardholder</a></p>
  12. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  13. * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Supported currencies are <code>usd</code> in the US, <code>eur</code> in the EU, and <code>gbp</code> in the UK.
  14. * @property null|string $cvc The card's CVC. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with <a href="https://stripe.com/docs/api/expanding_objects">the <code>expand</code> parameter</a>. Additionally, it's only available via the <a href="https://stripe.com/docs/api/issuing/cards/retrieve">&quot;Retrieve a card&quot; endpoint</a>, not via &quot;List all cards&quot; or any other endpoint.
  15. * @property int $exp_month The expiration month of the card.
  16. * @property int $exp_year The expiration year of the card.
  17. * @property null|string $financial_account The financial account this card is attached to.
  18. * @property string $last4 The last 4 digits of the card number.
  19. * @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.
  20. * @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.
  21. * @property null|string $number The full unredacted card number. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with <a href="https://stripe.com/docs/api/expanding_objects">the <code>expand</code> parameter</a>. Additionally, it's only available via the <a href="https://stripe.com/docs/api/issuing/cards/retrieve">&quot;Retrieve a card&quot; endpoint</a>, not via &quot;List all cards&quot; or any other endpoint.
  22. * @property null|string|\Stripe\Issuing\PersonalizationDesign $personalization_design The personalization design object belonging to this card.
  23. * @property null|string|\Stripe\Issuing\Card $replaced_by The latest card that replaces this card, if any.
  24. * @property null|string|\Stripe\Issuing\Card $replacement_for The card this card replaces, if any.
  25. * @property null|string $replacement_reason The reason why the previous card needed to be replaced.
  26. * @property null|\Stripe\StripeObject $shipping Where and how the card will be shipped.
  27. * @property \Stripe\StripeObject $spending_controls
  28. * @property string $status Whether authorizations can be approved on this card. May be blocked from activating cards depending on past-due Cardholder requirements. Defaults to <code>inactive</code>.
  29. * @property string $type The type of the card.
  30. * @property null|\Stripe\StripeObject $wallets Information relating to digital wallets (like Apple Pay and Google Pay).
  31. */
  32. class Card extends \Stripe\ApiResource
  33. {
  34. const OBJECT_NAME = 'issuing.card';
  35. use \Stripe\ApiOperations\Update;
  36. const CANCELLATION_REASON_DESIGN_REJECTED = 'design_rejected';
  37. const CANCELLATION_REASON_LOST = 'lost';
  38. const CANCELLATION_REASON_STOLEN = 'stolen';
  39. const REPLACEMENT_REASON_DAMAGED = 'damaged';
  40. const REPLACEMENT_REASON_EXPIRED = 'expired';
  41. const REPLACEMENT_REASON_LOST = 'lost';
  42. const REPLACEMENT_REASON_STOLEN = 'stolen';
  43. const STATUS_ACTIVE = 'active';
  44. const STATUS_CANCELED = 'canceled';
  45. const STATUS_INACTIVE = 'inactive';
  46. const TYPE_PHYSICAL = 'physical';
  47. const TYPE_VIRTUAL = 'virtual';
  48. /**
  49. * Creates an Issuing <code>Card</code> object.
  50. *
  51. * @param null|array $params
  52. * @param null|array|string $options
  53. *
  54. * @throws \Stripe\Exception\ApiErrorException if the request fails
  55. *
  56. * @return \Stripe\Issuing\Card the created resource
  57. */
  58. public static function create($params = null, $options = null)
  59. {
  60. self::_validateParams($params);
  61. $url = static::classUrl();
  62. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  63. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  64. $obj->setLastResponse($response);
  65. return $obj;
  66. }
  67. /**
  68. * Returns a list of Issuing <code>Card</code> objects. The objects are sorted in
  69. * descending order by creation date, with the most recently created object
  70. * appearing first.
  71. *
  72. * @param null|array $params
  73. * @param null|array|string $opts
  74. *
  75. * @throws \Stripe\Exception\ApiErrorException if the request fails
  76. *
  77. * @return \Stripe\Collection<\Stripe\Issuing\Card> of ApiResources
  78. */
  79. public static function all($params = null, $opts = null)
  80. {
  81. $url = static::classUrl();
  82. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  83. }
  84. /**
  85. * Retrieves an Issuing <code>Card</code> object.
  86. *
  87. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  88. * @param null|array|string $opts
  89. *
  90. * @throws \Stripe\Exception\ApiErrorException if the request fails
  91. *
  92. * @return \Stripe\Issuing\Card
  93. */
  94. public static function retrieve($id, $opts = null)
  95. {
  96. $opts = \Stripe\Util\RequestOptions::parse($opts);
  97. $instance = new static($id, $opts);
  98. $instance->refresh();
  99. return $instance;
  100. }
  101. /**
  102. * Updates the specified Issuing <code>Card</code> object by setting the values of
  103. * the parameters passed. Any parameters not provided will be left unchanged.
  104. *
  105. * @param string $id the ID of the resource to update
  106. * @param null|array $params
  107. * @param null|array|string $opts
  108. *
  109. * @throws \Stripe\Exception\ApiErrorException if the request fails
  110. *
  111. * @return \Stripe\Issuing\Card the updated resource
  112. */
  113. public static function update($id, $params = null, $opts = null)
  114. {
  115. self::_validateParams($params);
  116. $url = static::resourceUrl($id);
  117. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  118. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  119. $obj->setLastResponse($response);
  120. return $obj;
  121. }
  122. }