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

djstripe.exceptions.InvalidStripeAPIKey: Invalid API key: '' when attaching a payment method #2037

Open
dbartenstein opened this issue Mar 29, 2024 · 1 comment
Labels
Milestone

Comments

@dbartenstein
Copy link

Describe the bug
As described here https://dj-stripe.dev/dj-stripe/2.7/api_keys/, we got rid of STRIPE_LIVE_SECRET_KEY and STRIPE_TEST_SECRET_KEY.

However when calling Customer.add_payment_method, PaymentMethod.attach is called without explicit api_key param.

Fallback is djstripe_settings.STRIPE_SECRET_KEY, which will be "" in our case:

api_key: str = djstripe_settings.STRIPE_SECRET_KEY,

A clear and concise description of what the bug is.

To Reproduce

*** djstripe.exceptions.InvalidStripeAPIKey: Invalid API key: ''

Software versions

  • Dj-Stripe version: 2.8.3
  • Python version: 3.11.8
  • Django version: 4.2.11
  • Stripe API version: 2020-08-27
  • Database type and version: PostgreSQL 15
@dbartenstein
Copy link
Author

Possible fix:
payment_method = PaymentMethod.attach(payment_method, stripe_customer, api_key=self.default_api_key)

payment_method = PaymentMethod.attach(payment_method, stripe_customer)

@jleclanche jleclanche added this to the 2.9.0 milestone May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants