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