Migration guide for v2 (original) (raw)
If you're migrating from v1.x of stripe-python to v2.x, here's what you need to keep in mind to ensure your Stripe integration will still work after updating:
Minimum Python versions
stripe-python v2.0 requires Python 2.7 or 3.4 (or higher). Python 2.6 and 3.3 are no longer supported. If you're using Python 2.6 or 3.3, consider upgrading to a more recent version as soon as possible as these versions are no longer supported and do not receive any updates (including security updates).
Exceptions namespace
Stripe exception classes (InvalidRequestError, etc.) are no longer available in the global stripe namespace. Instead, they should now be accessed via the stripe.error module.
Deprecated methods
Some older deprecated methods have been removed:
| Removed method | Replacement |
|---|---|
| .all() | .list() |
| Customer.add_invoice_item() | InvoiceItem.create(customer=...) |
| Customer.invoices() | Invoice.list(customer=...) |
| Customer.invoice_items() | InvoiceItem.list(customer=...) |
| Customer.charges() | Charge.list(customer=...) |
| Customer.update_subscription() | Subscription.update() |
| Customer.cancel_subscription() | Subscription.cancel() |
| Recipient.transfers() | Transfer.list(recipient=...) |
Deprecated arguments
EphemeralKey.create() no longer supports the api_version argument, use stripe_version instead.
Source detachment exception
In v1.x, trying to detach a source that is not currently attached to a customer would raise a NotImplementedError exception. In v2.x, a stripe.error.InvalidRequestError exception is raised instead.