Introducing StripeClient.rawRequest, a new way to request Stripe APIs. Previously available only in beta, StripeClient.rawRequest now has general availability.
If you
would like to send a request to an undocumented API (for example you are in a private beta)
prefer to bypass the method definitions in the library and specify your request details directly
used the method _request on \Stripe\ApiOperation\Request trait to specify your own requests.
you can use the rawRequest method on the StripeClient.
Changelog
Adds the ability to make raw requests to the Stripe API, by providing an HTTP method and url. This is an alternative to using the trait \Stripe\ApiOperation\Request to make custom requests, which is discouraged and will be broken in a future major version.
$stripe = new \Stripe\StripeClient('sk_test_xyz');
$response = $stripe->rawRequest('post', '/v1/undocumented_endpoint', [
"caveat": "emptor"
], [
"stripe_version" => "2024-06-20",
]);
// $response->body is a string, you can call $stripe->deserialize to get a \Stripe\StripeObject.
$obj = $stripe->deserialize($response->body);
// For GET requests, the params argument must be null, and you should write the query string explicitly.
$get_response = $stripe->rawRequest('get', '/v1/beta_endpoint?caveat=emptor', null, [
"stripe_version" => "2022-11_15",
]);
Introducing
StripeClient.rawRequest
, a new way to request Stripe APIs. Previously available only in beta,StripeClient.rawRequest
now has general availability.If you
_request
on\Stripe\ApiOperation\Request
trait to specify your own requests.you can use the
rawRequest
method on the StripeClient.Changelog
\Stripe\ApiOperation\Request
to make custom requests, which is discouraged and will be broken in a future major version.// For GET requests, the params argument must be null, and you should write the query string explicitly. $get_response = $stripe->rawRequest('get', '/v1/beta_endpoint?caveat=emptor', null, [ "stripe_version" => "2022-11_15", ]);