Skip to content

Treat Stripe permission errors as invalid keys - #796

Merged
s3341458 merged 1 commit into
mainfrom
fix/stripe-key-permission-error
Sep 13, 2026
Merged

s3341458 merged 1 commit into
mainfrom
fix/stripe-key-permission-error

Conversation

@Amtron

@Amtron Amtron commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • is_valid_key now treats empty keys, publishable pk_ keys, and any stripe.error.StripeError (including PermissionError) as invalid instead of letting the exception abort the company save.
  • Saving Stripe keys that Stripe will not accept for Charge.list no longer 500s; isStripeValid is set to false, or the existing 400 is returned if Stripe is already enabled.

Test plan

  • Add a publishable key (pk_…) as the secret key and confirm the company save succeeds (or returns the existing 400 if Stripe is enabled), not a 500
  • Add a restricted key without Charges read and confirm the same
  • Add a valid sk_test_ / sk_live_ key matching company test/live mode and confirm isStripeValid is true
  • Run python/tests/test_stripe_util.py

Made with Cursor


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Company payment settings crashed with 500 when Stripe returned 403 for Charge.list, instead of marking the key invalid.

Co-authored-by: Cursor <cursoragent@cursor.com>
@s3341458
s3341458 merged commit 5329264 into main Sep 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants