-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Code relying on payment.change_status
to save whole payment object fails
#309
Code relying on payment.change_status
to save whole payment object fails
#309
Comments
Right, this is a real issue. Context for the change in In other words, it prevents issues with concurrent editions of the Payment object, but the approach has not been ideal. I think locking the row while processing callbacks and alike would be best. Applications should also lock the row to edit it to avoid issues too. Or maybe applications should avoid mutating |
The change to change_status also caused problems for us. We were relying on it to save the entire object so we didn't need to call save twice. Adding this backwards incompatible change in the change log file would help other people with upgrading the version. |
I'm aiming to stabilise this again for the next release. I'll revert the offending commit. I've also added some docs on good practices to avoid the issue that the original commit/change intended to address: #318 |
Partially fixes: jazzband#309
Partially fixes: jazzband#309
Partially fixes: jazzband#309
Partially fixes: jazzband#309
Partially fixes: jazzband#309
Partially fixes: jazzband#309
@PetrDlouhy, I believe this got closed accidentally by merging my PR into your PayU provider. Can you reopen this? BTW: Here, is my PR to this repo to fix one part of this issue: #412 Similar work needs to be done on multiple places though but this particular part prevents us from performing proper refunds. |
@WhyNotHugo, I believe this got closed accidentally by merging my PR. Similar work needs to be done in multiple places before this issue can be considered resolved. Can you reopen this? |
b1dc16c made
change_status
'safer' by not saving the whole payment object but just some fields.This backwards incompatible change got me a while ago and I fixed it in my own implementation, but it looks like code in this project also has not been adapted to this new behaviour.
One example is the Paypal provider:
django-payments/payments/paypal/__init__.py
Lines 252 to 258 in 38dae99
payment.attrs
andpayment.captured_amount
are NOT saved due tochange_status
only doing:self.save(update_fields=["status", "message"])
. Or am I missing something?The text was updated successfully, but these errors were encountered: