Request.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Forwarding;
  4. /**
  5. * Instructs Stripe to make a request on your behalf using the destination URL. The destination URL
  6. * is activated by Stripe at the time of onboarding. Stripe verifies requests with your credentials
  7. * provided during onboarding, and injects card details from the payment_method into the request.
  8. *
  9. * Stripe redacts all sensitive fields and headers, including authentication credentials and card numbers,
  10. * before storing the request and response data in the forwarding Request object, which are subject to a
  11. * 30-day retention period.
  12. *
  13. * You can provide a Stripe idempotency key to make sure that requests with the same key result in only one
  14. * outbound request. The Stripe idempotency key provided should be unique and different from any idempotency
  15. * keys provided on the underlying third-party request.
  16. *
  17. * Forwarding Requests are synchronous requests that return a response or time out according to
  18. * Stripe’s limits.
  19. *
  20. * Related guide: <a href="https://docs.stripe.com/payments/forwarding">Forward card details to third-party API endpoints</a>.
  21. *
  22. * @property string $id Unique identifier for the object.
  23. * @property string $object String representing the object's type. Objects of the same type share the same value.
  24. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  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 string $payment_method The PaymentMethod to insert into the forwarded request. Forwarding previously consumed PaymentMethods is allowed.
  27. * @property string[] $replacements The field kinds to be replaced in the forwarded request.
  28. * @property null|\Stripe\StripeObject $request_context Context about the request from Stripe's servers to the destination endpoint.
  29. * @property null|\Stripe\StripeObject $request_details The request that was sent to the destination endpoint. We redact any sensitive fields.
  30. * @property null|\Stripe\StripeObject $response_details The response that the destination endpoint returned to us. We redact any sensitive fields.
  31. * @property null|string $url The destination URL for the forwarded request. Must be supported by the config.
  32. */
  33. class Request extends \Stripe\ApiResource
  34. {
  35. const OBJECT_NAME = 'forwarding.request';
  36. /**
  37. * Creates a ForwardingRequest object.
  38. *
  39. * @param null|array $params
  40. * @param null|array|string $options
  41. *
  42. * @throws \Stripe\Exception\ApiErrorException if the request fails
  43. *
  44. * @return \Stripe\Forwarding\Request the created resource
  45. */
  46. public static function create($params = null, $options = null)
  47. {
  48. self::_validateParams($params);
  49. $url = static::classUrl();
  50. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  51. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  52. $obj->setLastResponse($response);
  53. return $obj;
  54. }
  55. /**
  56. * Lists all ForwardingRequest objects.
  57. *
  58. * @param null|array $params
  59. * @param null|array|string $opts
  60. *
  61. * @throws \Stripe\Exception\ApiErrorException if the request fails
  62. *
  63. * @return \Stripe\Collection<\Stripe\Forwarding\Request> of ApiResources
  64. */
  65. public static function all($params = null, $opts = null)
  66. {
  67. $url = static::classUrl();
  68. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  69. }
  70. /**
  71. * Retrieves a ForwardingRequest object.
  72. *
  73. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  74. * @param null|array|string $opts
  75. *
  76. * @throws \Stripe\Exception\ApiErrorException if the request fails
  77. *
  78. * @return \Stripe\Forwarding\Request
  79. */
  80. public static function retrieve($id, $opts = null)
  81. {
  82. $opts = \Stripe\Util\RequestOptions::parse($opts);
  83. $instance = new static($id, $opts);
  84. $instance->refresh();
  85. return $instance;
  86. }
  87. }