Whenever I try to create a Stripe subscription in PHP with the ‘id’ parameter, it gives an error of invalid parameter, and when I remove the id parameter, it works. Does anyone know how to manually set the subscription id instead of getting an error like this?
What I tried:
$stripe->subscriptions->create([
'id' => $id,
'customer' => $id,
'items' => [
['price' => 'price_'],
],
]);
What I got:
Fatal error: Uncaught Error sending request to Stripe: (Status 400) (Request req_no) Received unknown parameter: id StripeExceptionInvalidRequestException: Received unknown parameter: id in public_html/stripe-php-13.0.0/lib/Exception/ApiErrorException.php:38
2
Answers
There really is no id key in the api. Perhaps you need to use metadata for your own keys, for example:
Here’s how you should create a subscription in Stripe using PHP:
Here’s an example of how you might capture the subscription ID after creation: