Skip to content

Commit 6822547

Browse files
committed
Add warning on concurrent updates
See: jazzband/django-payments#309
1 parent 838324c commit 6822547

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/install.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ Prepare a template that displays the form using its ``action`` and ``method``:
136136
<p><input type="submit" value="Proceed" /></p>
137137
</form>
138138

139+
Mutating a `Payment` instance
140+
-----------------------------
141+
142+
When operating `BasePayment` instances, care should be take to only save
143+
changes atomically. If you were to load an instance into memory, mutate, and
144+
then save it, you might overwrite fields that have been updated due to handling
145+
a notification from the processor. Keep in mind that some processors implement
146+
"at least once" notification delivery.
147+
148+
In general, you should either:
149+
150+
- Use atomic updates only specifying the relevant fields. For example, if the
151+
application-local ``Payment`` class has a custom field named
152+
``discount_card_code``, use
153+
``BasePayment.objects.filter(pk=payment_id).update(discount_card_code="123XYZ")``.
154+
This is the recommended approach.
155+
- Lock the database row while mutating a python instance of ``BasePayment`` (may
156+
negatively affect performance at scale).
157+
139158
.. _settings:
140159

141160
Additional Django settings

0 commit comments

Comments
 (0)