Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.x] Adding metered product to existing subscription fails due to quantity key being present #1187

Closed
hailwood opened this issue Jun 8, 2021 · 1 comment · Fixed by #1189
Labels

Comments

@hailwood
Copy link
Contributor

hailwood commented Jun 8, 2021

  • Cashier Version: 13.0.0
  • Laravel Version: 8.46.0
  • PHP Version: 8.0.3
  • Database Driver & Version: Mysql 8

Description:

Seems like stripe doesn't like us sending across quantity as null. It wants either an integer or the key missing entirely.

If we filter this array to remove null values the subscription is updated as intended.

If we do not then we get a Stripe exception Stripe\Exception\InvalidRequestException with the message

Invalid integer:

Stacktrace

/app/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php:35
--
/app/vendor/stripe/stripe-php/lib/ApiRequestor.php:189
/app/vendor/stripe/stripe-php/lib/ApiRequestor.php:151
/app/vendor/stripe/stripe-php/lib/ApiRequestor.php:489
/app/vendor/stripe/stripe-php/lib/ApiRequestor.php:120
/app/vendor/stripe/stripe-php/lib/BaseStripeClient.php:134
/app/vendor/stripe/stripe-php/lib/Service/AbstractService.php:59
/app/vendor/stripe/stripe-php/lib/Service/SubscriptionItemService.php:62
/app/vendor/laravel/cashier/src/Subscription.php:834
/app/vendor/laravel/cashier/src/Subscription.php:890

This is not an issue when creating a new subscription as we only add the quantity key if the value is not null.

Steps To Reproduce:

  1. Create a subscription with an existing product
  2. Attempt to update the subscription to add an additional metered product
$billable->subscription()->addMeteredPrice('price_ab123');
@driesvints
Copy link
Member

Urgh, should have added a test for that. Thanks @hailwood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants