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 warning on concurrent updates #318

Merged
merged 1 commit into from
May 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ Prepare a template that displays the form using its ``action`` and ``method``:
<p><input type="submit" value="Proceed" /></p>
</form>

Mutating a `Payment` instance
-----------------------------

When operating `BasePayment` instances, care should be take to only save
changes atomically. If you were to load an instance into memory, mutate, and
then save it, you might overwrite fields that have been updated due to handling
a notification from the processor. Keep in mind that some processors implement
"at least once" notification delivery.

In general, you should either:

- Use atomic updates only specifying the relevant fields. For example, if the
application-local ``Payment`` class has a custom field named
``discount_card_code``, use
``BasePayment.objects.filter(pk=payment_id).update(discount_card_code="123XYZ")``.
This is the recommended approach.
- Lock the database row while mutating a python instance of ``BasePayment`` (may
negatively affect performance at scale).

.. _settings:

Additional Django settings
Expand Down