stripe / stripe-php

PHP library for the Stripe API.
https://stripe.com
MIT License
3.75k stars 849 forks source link

[Bug] update "Prices" error #1644

Closed medram closed 9 months ago

medram commented 9 months ago

Describe the bug

There is a critical bug that prevents updating "Prices" price.

$stripe = new \Stripe\StripeClient('sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxx');
$stripe->prices->update("price_xxxxxxx", [
  "active" => true // this is working
  "unit_amount" => 1000, // this param isn't allowed (But this is the right way based on the docs)
]);
# Result Output:
Error sending request to Stripe: (Status 400) (Request req_JfcmxfBEtOibh1) Received unknown parameters: unit_amount
Stripe\Exception\InvalidRequestException: Received unknown parameters: unit_amount in /var/www/html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php:38
Stack trace:
#0 /var/www/html/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php(35): Stripe\Exception\ApiErrorException::factory('Received unknow...', 400, '{\n  "error": {\n...', Array, Object(Stripe\

To Reproduce

Update the "Prices".

Expected behavior

The "Prices" should be updated, and the params should be accepted.

Code snippets

No response

OS

Linux Mint

PHP version

PHP 8.2.8

Library version

"stripe/stripe-php": "^13.10"

API version

2023-10-16

Additional context

No response

remi-stripe commented 9 months ago

@medram Github issues are limited to bugs or feature requests with the stripe-php SDK itself. Your ask is an integration support question better directed at our support team instead: https://support.stripe.com/contact

To unblock you though, this error is totally expected. The Update Price API doesnot support the unit_amount parameter. You can not change a Price's amount. The right approach is to create a new Price with the new amount and use that one moving forward. If you have follow up questions, please contact our support team for help!

medram commented 9 months ago

That what I did actually to work around it, archiving the Price and creating a new one.

Thanks for your reply @remi-stripe