dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.
https://dj-stripe.dev
MIT License
1.56k stars 476 forks source link

Added DjStripeHTTPClient to handle all Stripe API calls. #1913

Open arnav13081994 opened 1 year ago

arnav13081994 commented 1 year ago

PR #1909 and PR #1910 need to be merged before this PR can be merged.

This PR adds support for DjStripeHTTPClient that provides out of the box the following capabilities:

  1. Built-in retires for rate_limit errors
  2. Built-in retires for lock_timeout errors
  3. Built-in support for using or creating Idempotency keys as the case may be.
samamorgan commented 2 months ago

My two cents: I'm not fond of adding an additional layer of abstraction to the Stripe Python client. These are already features that exist in that client, and adding this layer of abstraction absolutely will introduce confusion, as well as increasing maintenance costs.

Additionally, adding test flags is a code smell. If you need flags to test the code, then the code should be refactored to be more appropriately testable.

If having default retries/rate limit handling is desired, a more appropriate approach would be to configure a central stripe-python client instance and force all dj-stripe API call methods to use that client instance.