PaymentMethodDomain.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * A payment method domain represents a web domain that you have registered with Stripe.
  6. * Stripe Elements use registered payment method domains to control where certain payment methods are shown.
  7. *
  8. * Related guides: <a href="https://stripe.com/docs/payments/payment-methods/pmd-registration">Payment method domains</a>.
  9. *
  10. * @property string $id Unique identifier for the object.
  11. * @property string $object String representing the object's type. Objects of the same type share the same value.
  12. * @property \Stripe\StripeObject $apple_pay Indicates the status of a specific payment method on a payment method domain.
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @property string $domain_name The domain name that this payment method domain object represents.
  15. * @property bool $enabled Whether this payment method domain is enabled. If the domain is not enabled, payment methods that require a payment method domain will not appear in Elements.
  16. * @property \Stripe\StripeObject $google_pay Indicates the status of a specific payment method on a payment method domain.
  17. * @property \Stripe\StripeObject $link Indicates the status of a specific payment method on a payment method domain.
  18. * @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.
  19. * @property \Stripe\StripeObject $paypal Indicates the status of a specific payment method on a payment method domain.
  20. */
  21. class PaymentMethodDomain extends ApiResource
  22. {
  23. const OBJECT_NAME = 'payment_method_domain';
  24. use ApiOperations\Update;
  25. /**
  26. * Creates a payment method domain.
  27. *
  28. * @param null|array $params
  29. * @param null|array|string $options
  30. *
  31. * @throws \Stripe\Exception\ApiErrorException if the request fails
  32. *
  33. * @return \Stripe\PaymentMethodDomain the created resource
  34. */
  35. public static function create($params = null, $options = null)
  36. {
  37. self::_validateParams($params);
  38. $url = static::classUrl();
  39. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  40. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  41. $obj->setLastResponse($response);
  42. return $obj;
  43. }
  44. /**
  45. * Lists the details of existing payment method domains.
  46. *
  47. * @param null|array $params
  48. * @param null|array|string $opts
  49. *
  50. * @throws \Stripe\Exception\ApiErrorException if the request fails
  51. *
  52. * @return \Stripe\Collection<\Stripe\PaymentMethodDomain> of ApiResources
  53. */
  54. public static function all($params = null, $opts = null)
  55. {
  56. $url = static::classUrl();
  57. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  58. }
  59. /**
  60. * Retrieves the details of an existing payment method domain.
  61. *
  62. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  63. * @param null|array|string $opts
  64. *
  65. * @throws \Stripe\Exception\ApiErrorException if the request fails
  66. *
  67. * @return \Stripe\PaymentMethodDomain
  68. */
  69. public static function retrieve($id, $opts = null)
  70. {
  71. $opts = \Stripe\Util\RequestOptions::parse($opts);
  72. $instance = new static($id, $opts);
  73. $instance->refresh();
  74. return $instance;
  75. }
  76. /**
  77. * Updates an existing payment method domain.
  78. *
  79. * @param string $id the ID of the resource to update
  80. * @param null|array $params
  81. * @param null|array|string $opts
  82. *
  83. * @throws \Stripe\Exception\ApiErrorException if the request fails
  84. *
  85. * @return \Stripe\PaymentMethodDomain the updated resource
  86. */
  87. public static function update($id, $params = null, $opts = null)
  88. {
  89. self::_validateParams($params);
  90. $url = static::resourceUrl($id);
  91. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  92. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  93. $obj->setLastResponse($response);
  94. return $obj;
  95. }
  96. /**
  97. * @param null|array $params
  98. * @param null|array|string $opts
  99. *
  100. * @throws \Stripe\Exception\ApiErrorException if the request fails
  101. *
  102. * @return \Stripe\PaymentMethodDomain the validated payment method domain
  103. */
  104. public function validate($params = null, $opts = null)
  105. {
  106. $url = $this->instanceUrl() . '/validate';
  107. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  108. $this->refreshFrom($response, $opts);
  109. return $this;
  110. }
  111. }