PayPal: add an extra_data_key_refund parameter to the providers #440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
in our integration with
django-payments
, we started to use PayPal refunds. Unfortunately, this has broken our previous expectations on the content ofBasePayment.extra_data
. Our code expects thatpayment.extra_data["response"]
is the response from thePaypalProvider.process_data
call (forever). However, calls toPaypalProvider.refund
overwrite this with their response.This is an attempt to solve this issue by providing a possibility to store refund responses under a different key in
payment.extra_data
while preserving the original behavior by default for backward compatibility. The new approach was inspired by a similar (not configurable) behavior ofPaypalProvider.get_access_token
which stores its responses underpayment.extra_data["auth_response"]
.This is also an attempt to fix the situation upstream although I have no idea how useful this might be for other
django-payments
users. If it turns out not being usable upstream I'd have to come up with a way to reliably customizePaypalProvider
to our needs downstream (consideringPaypalProvider
has no public API except its constructor and https://django-payments.readthedocs.io/en/latest/backends.html#create-a-provider-class AFAIK).It is also worth noting that
PaypalProvider.refund
is not the only method that overwritespayment.extra_data["response"]
. But I did not want to overengineer this and since we do not use the other methods, this is enough for us so far. But I can take a look at the rest as well if needed.I'd be happy for any feedback/opinion. Feel free to request any necessary changes 🙏