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

Add idempotency to Stripe Create Calls #1909

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Commits on Apr 20, 2023

  1. Added SourceTransaction model.

    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    afe87b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    18f2bfe View commit details
    Browse the repository at this point in the history
  3. Added SourceTransaction.get_stripe_dashboard_url() method

    This was done because Stripe does not expose a separate url to access these objects and they can only be accessed with the Related Source Object
    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    2215029 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0a05fea View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    eae5870 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8e8e6da View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2f98077 View commit details
    Browse the repository at this point in the history
  8. Refactored Source object event handler into its own independent handler

    This was done because the "Source" event handler was receiving all events of the type source.X.Y which was causing a mismatch between the event type and the target object type. This is why the target object type was explicitly checked as done for the "Charge" event handler.
    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    8dd521a View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    869d3c4 View commit details
    Browse the repository at this point in the history
  10. Updated _handle_crud_like_event for SourceTransaction Objects

    This was done because newly created Sourcetransaction objects cannot be retrieved as Stripe doesn't allow `retrieve` operation yet. And in order to retrieve by the related "Source" object we need the source to be attached to a "Customer" instance which will not always be the case and can't be known ahead of time as the order of webhooks is unreliable. This is why retrieving the data of the SourceTransaction object was skipped.
    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    ffc3f5c View commit details
    Browse the repository at this point in the history
  11. Fix Linting Errors

    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    9372d6f View commit details
    Browse the repository at this point in the history
  12. Updated Changelog

    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    c89f6fc View commit details
    Browse the repository at this point in the history
  13. Update migration file name

    arnav13081994 authored and jleclanche committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    bab69e7 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    493dd0a View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    066d834 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    8ba678e View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    71e35ad View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    5c56dca View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    10012c7 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    9800773 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    539ed88 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    b1e176b View commit details
    Browse the repository at this point in the history
  23. Updated the get_idempotency_key function

    The function whenever called always creates a new idempotency key.
    This was done because the older implementation was only
    suitable for Customer.create() method as was not generic to
    handle all `create` or `update` calls.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    e4a8ba8 View commit details
    Browse the repository at this point in the history
  24. Updated Customer.purge() method to not delete the associated idempote…

    …ncy_key
    
    This was done because in the updated flow we ALWAYS generate a new
    idempotency_key for a request if one is not provided. The old
    flow was only applicable for Customer creation with a given user
    as a subscriber. Besides re-using these keys are pointless after
    a period of 24 hours anyway.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    94ee2dd View commit details
    Browse the repository at this point in the history
  25. Renamed get_idempotency_key to create_idempotency_key

    This was done to better reflect the functionality of the
    function create_idempotency_key.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    658df74 View commit details
    Browse the repository at this point in the history
  26. Added Idempotencykey.update_action_field staticmethod

    This is a helper method to update the action model field
    post object creation with the stripe object's id to ease
    reference of the idempotency_key used to create or update
    the stripe object.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    ba8020c View commit details
    Browse the repository at this point in the history
  27. Added StripeModel.get_or_create_idempotency_key

    This was done in order to populate the
    idempotency_key and use it to make the call on
    behalf of the user in case they do
    not provide us with one.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    67dee8d View commit details
    Browse the repository at this point in the history
  28. Updated StripeModel._api_create to use Idempotency Key object

    The _api_create method now does the following:
    
    1) Generated a new Idempotency Key object if not given one.
    2) Uses the Idempotency key (from 1)) to make the Stripe API call.
    3) Updates the action model field of the Idempotency Key object with
       the id of the so created Stripe object.
    arnav13081994 committed Apr 20, 2023
    Configuration menu
    Copy the full SHA
    56e4565 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    01d95c1 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    832fd36 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    d2a8672 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    e8e278c View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    0308c33 View commit details
    Browse the repository at this point in the history