PaymentMethod.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 $alipay
  19. * @property \Stripe\StripeObject $au_becs_debit
  20. * @property \Stripe\StripeObject $bacs_debit
  21. * @property \Stripe\StripeObject $bancontact
  22. * @property \Stripe\StripeObject $billing_details
  23. * @property \Stripe\StripeObject $card
  24. * @property \Stripe\StripeObject $card_present
  25. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  26. * @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.
  27. * @property \Stripe\StripeObject $eps
  28. * @property \Stripe\StripeObject $fpx
  29. * @property \Stripe\StripeObject $giropay
  30. * @property \Stripe\StripeObject $grabpay
  31. * @property \Stripe\StripeObject $ideal
  32. * @property \Stripe\StripeObject $interac_present
  33. * @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.
  34. * @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.
  35. * @property \Stripe\StripeObject $oxxo
  36. * @property \Stripe\StripeObject $p24
  37. * @property \Stripe\StripeObject $sepa_debit
  38. * @property \Stripe\StripeObject $sofort
  39. * @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.
  40. */
  41. class PaymentMethod extends ApiResource
  42. {
  43. const OBJECT_NAME = 'payment_method';
  44. use ApiOperations\All;
  45. use ApiOperations\Create;
  46. use ApiOperations\Retrieve;
  47. use ApiOperations\Update;
  48. /**
  49. * @param null|array $params
  50. * @param null|array|string $opts
  51. *
  52. * @throws \Stripe\Exception\ApiErrorException if the request fails
  53. *
  54. * @return PaymentMethod the attached payment method
  55. */
  56. public function attach($params = null, $opts = null)
  57. {
  58. $url = $this->instanceUrl() . '/attach';
  59. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  60. $this->refreshFrom($response, $opts);
  61. return $this;
  62. }
  63. /**
  64. * @param null|array $params
  65. * @param null|array|string $opts
  66. *
  67. * @throws \Stripe\Exception\ApiErrorException if the request fails
  68. *
  69. * @return PaymentMethod the detached payment method
  70. */
  71. public function detach($params = null, $opts = null)
  72. {
  73. $url = $this->instanceUrl() . '/detach';
  74. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  75. $this->refreshFrom($response, $opts);
  76. return $this;
  77. }
  78. }