PaymentMethod.php 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * PaymentMethod objects represent your customer's payment instruments. They can be
  6. * used with <a
  7. * href="https://stripe.com/docs/payments/payment-intents">PaymentIntents</a> to
  8. * collect payments or saved to Customer objects to store instrument details for
  9. * future payments.
  10. *
  11. * Related guides: <a
  12. * href="https://stripe.com/docs/payments/payment-methods">Payment Methods</a> and
  13. * <a href="https://stripe.com/docs/payments/more-payment-scenarios">More Payment
  14. * Scenarios</a>.
  15. *
  16. * @property string $id Unique identifier for the object.
  17. * @property string $object String representing the object's type. Objects of the same type share the same value.
  18. * @property \Stripe\StripeObject $acss_debit
  19. * @property \Stripe\StripeObject $afterpay_clearpay
  20. * @property \Stripe\StripeObject $alipay
  21. * @property \Stripe\StripeObject $au_becs_debit
  22. * @property \Stripe\StripeObject $bacs_debit
  23. * @property \Stripe\StripeObject $bancontact
  24. * @property \Stripe\StripeObject $billing_details
  25. * @property \Stripe\StripeObject $boleto
  26. * @property \Stripe\StripeObject $card
  27. * @property \Stripe\StripeObject $card_present
  28. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  29. * @property null|string|\Stripe\Customer $customer The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer.
  30. * @property \Stripe\StripeObject $eps
  31. * @property \Stripe\StripeObject $fpx
  32. * @property \Stripe\StripeObject $giropay
  33. * @property \Stripe\StripeObject $grabpay
  34. * @property \Stripe\StripeObject $ideal
  35. * @property \Stripe\StripeObject $interac_present
  36. * @property \Stripe\StripeObject $klarna
  37. * @property \Stripe\StripeObject $konbini
  38. * @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.
  39. * @property null|\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.
  40. * @property \Stripe\StripeObject $oxxo
  41. * @property \Stripe\StripeObject $p24
  42. * @property \Stripe\StripeObject $sepa_debit
  43. * @property \Stripe\StripeObject $sofort
  44. * @property string $type The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.
  45. * @property \Stripe\StripeObject $wechat_pay
  46. */
  47. class PaymentMethod extends ApiResource
  48. {
  49. const OBJECT_NAME = 'payment_method';
  50. use ApiOperations\All;
  51. use ApiOperations\Create;
  52. use ApiOperations\Retrieve;
  53. use ApiOperations\Update;
  54. /**
  55. * @param null|array $params
  56. * @param null|array|string $opts
  57. *
  58. * @throws \Stripe\Exception\ApiErrorException if the request fails
  59. *
  60. * @return \Stripe\PaymentMethod the attached payment method
  61. */
  62. public function attach($params = null, $opts = null)
  63. {
  64. $url = $this->instanceUrl() . '/attach';
  65. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  66. $this->refreshFrom($response, $opts);
  67. return $this;
  68. }
  69. /**
  70. * @param null|array $params
  71. * @param null|array|string $opts
  72. *
  73. * @throws \Stripe\Exception\ApiErrorException if the request fails
  74. *
  75. * @return \Stripe\PaymentMethod the detached payment method
  76. */
  77. public function detach($params = null, $opts = null)
  78. {
  79. $url = $this->instanceUrl() . '/detach';
  80. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  81. $this->refreshFrom($response, $opts);
  82. return $this;
  83. }
  84. }