-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow client code to use the Adyen merchantReturnData field. #25
base: master
Are you sure you want to change the base?
Allow client code to use the Adyen merchantReturnData field. #25
Conversation
Hi @willharris and first, thank you for your interest and your work on that. I apologise for the lack of follow-up from us. We struggle to maintain this project, and I didn't have time to get into this project before this week. I think I see your concern about the That is to say, we need to address:
Instead of adding ad-hoc code inside the plugin, I would rather keep the current behavior, but allow a hook that would:
It would work with a simple contract: the plugin gives input data to the method, the method must return the submission data (ie. the form fields that will be sent to Adyen). Some fields are required (say, the amount, the order number, etc.). On the other end, a method will get the Adyen response with all the fields, and it must return a python dict with values. Some of these values must be "amount", and for example "merchant_return_data". I know, you did a lot of work with this PR, and you may not appreciate that I don't merge it "like that". However, I would like to find a trade-off between:
Do not hesitate to get in touch with me at [email protected] which is my professional email, or here on github, through issues and PR. Again, thanks for the PR and your interest. |
Hey @Exirel, no worries about the delay! It's not clear to me whether you are interested in a larger refactoring of the handling of A quick statement about terminology: for me, "the plugin" refers to django-oscar-adyen, i.e. a plugin for django-oscar. Am I understanding you correctly? In any case, I would argue the following: currently, there is simply no way for a plugin user (i.e. someone using django-oscar-adyen in their code) to provide any kind of value for What I have implemented provides that functionality for the plugin user while:
In this way, the actual implementation details of how the plugin is using this field for its own purposes remain shielded from the developer, and supplying a value for What do you think? |
Yes! I'm sorry I didn't make it clear, because I knew it could be confusing - that's something I would like to write in the doc!
It is yes. It makes sense that you tried to only modify as few code as possible of
I make sure it's backward compatible, and I think it'll help you implement your own version of both Of course, since there is no documentation, it's not clear how one can do that safely. I know that point and I want to write documentation to clarify all these points.
Exactly yes! And I don't like that too. After reading carefully, it looks like we wanted to always record the result of the transaction from Adyen:
But that's another story. Please, have a look at my latest commits on |
Hi @Exirel, Thanks for continuing the dialog! A few comments about the commits you mentioned:
In general, I think using both I also think it's important that whatever the implementation does, it should not require plugin users to write code in two different places to achieve their effect. As it is now written, I will have to override both I think to goal of the plugin should be to provide the best compatibility with the existing Adyen interface for the largest part of the userbase, while making it possible for those with special needs to do what they want with minimal fuss. |
Sure it is. That's not an easy refactoring indeed, and I think it is only the first step. That being said, the |
I'm not sure why you think it's a difficult topic - it is simply a user-provided string that needs to safely handled in a URL context. There are no semantics to it. |
The
merchantReturnData
field was blocked for use in client code, as the module used it for its own purpose in storing the transaction amount value (see the TODO atfacade.py:85
). This PR allows client code to also use this field by providing amerchant_return_data
value in the order details, while preserving the internal use.If any client data is provided for this field, it is appended to the amount value (now converted to a string) and separated by a tilde (~) character, which is valid in a URL without encoding, and highly unlikely to appear in any client data (e.g. it normally wouldn't appear in a Django session ID, which is what I need it for, and also what Adyen says is the typical usage for the field). Any provided data is first encoded as UTF-8 and then urlencoded for safe transmission as a URL param.
During the postback detail unpacking, the
merchantReturnData
field is split on the tilde character (if it is present), and the decoded data is returned to the client code asdetails['merchant_return_data']
.As with the other PR, this one is based on the current master, and will require a minor fix to work with my other Python 2 PR - which I also hope you merge! Happy to rebase after...