Closed (fixed)
Project:
Commerce DPS
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Mar 2012 at 12:59 UTC
Updated:
22 Jan 2015 at 03:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
garethhallnz commentedI really needed FPRN functionality for a project so I jumped in and added this feature. There are also a few currency handling improvements.
I have emailed the maintainer to get this merged into the main branch but have not heard back yet.
In the mean time I have loaded this to my github account so feel free to pull a copy if you need one.
https://github.com/garethhallnz/commerce_dps (Use the failProof..... branch)
Comment #2
xurizaemonThanks for the contribution, and also for posting this here. I was wondering why you weren't answering my replies, having emailed you at both your @gmail and @communica addresses last weekend and this week - but now I understand my emails weren't getting through :D
Ideally, please post issue-specific patches here for review, and feel free to create as many issues as you like to do so.
I'm a Github fan too (evidenced by the fact that I mirror most of my Drupal projects there) but for Drupal contributions the issue queues here are the best place for review, even if the experience isn't quite as whiz-bang.
I'll look over your changes now - thanks again.
Comment #3
xurizaemonthis is
git diff origin/7.x-1.x..garethhallnz/failproofresultnotificationloading this up to review in Dreditor, there are changes here unrelated to this issue which will be split out.
Comment #4
xurizaemonthis is
1354aa 9c2698 2abe89 38f720 bb6aa5 52472b 6eb963The above is too big to review all in one gulp, so split the changes into this patch (basically everything that looks like FPRN commits, ie 7.x-1.x-1496254).
nyurgh it's still 22KB ... let's test!
Comment #5
xurizaemonAbove patch needs
(1) closing
}(2) hook_update_N() to clear menu cache to register new /commerce_dps_pxpay_pxpay/fprn/5 path
Has a couple of warnings too -
* Notice: Undefined index: commerce_payment_transaction in commerce_dps_pxpay_get_transaction_ids() (line 235 of /var/aegir/platforms/commerce_kickstart-7.20-2.4/sites/commerce.example.org/modules/commerce_dps/commerce_dps_pxpay.inc).
* Warning: Invalid argument supplied for foreach() in commerce_dps_pxpay_get_transaction_ids() (line 235 of /var/aegir/platforms/commerce_kickstart-7.20-2.4/sites/commerce.example.org/modules/commerce_dps/commerce_dps_pxpay.inc).
Comment #6
garethhallnz commentedI will have to install kickstart and give it a go I simply don't have that error on my side.
Comment #7
garethhallnz commentedRe #4
1) Something must have gone wrong when the patch was created - fixed
2) Added the update hook
3) Resolved Undefined index notices
Comment #8
xurizaemonThis patch cleans up some coding standards nags, and accounts for commits in #1928460: Correctly encode XML data for communication with DPS and #1928454: Orders containing + sign may fail transaction validation which I spotted while testing. I put those in beforehand because I wanted to be sure that those issues hadn;t come in through this patch, but that required a re-roll. Sorry!
Also, I removed several @author lines from function docs - I promise I will use
git commit --authorto credit you Gareth. That waygit blamewill speak the truth, long after the docs are gone ...Comment #9
garethhallnz commentedPatch looks good at first glance but Ill check it out later this afternoon
After thinking about things I want to change one function's conditional statement
To
I feel this is more robust and specific.
I see you have changed the doc block style of documenting, should we not be using PSR as much as we can?
I will create a new patch with the above (conditional) later. Or if you have the time when you get this feel free to do so.
Comment #10
xurizaemonI changed the comment style based on feedback from Coder module's coder_sniffer package. I'm really not fussy there. http://drupal.org/node/1354 looks like the authoritative reference. (If I've misunderstood your question, please paste an example of the specific change I've made. I think you're referring to the insertion of a linebreak and then two space indentation for function argument descriptions?)
Agreed on your change to the transactions lookup, that seems right.
Comment #11
xurizaemonPS. I left some coding standards complaints from coder module in, either because they were outside of the lines changed by this patch, or because trying to make everything fit in 80 columns drives me batty sometimes.
Comment #12
garethhallnz commentedI have been unable to apply the patch in #8, I keep on getting a white space error. I have tried setting the appropriate config options but with no luck.
I have created a new patch with the fix mentioned in #9 I also removed the @author for the doc blocks.
As for the documentation style ... I am more of a framework developer as apposed to a Drupal one, so I don't always keep up with Drupal's best practices.
So the documentation format I apply on all my code is PSR-2 and it lines up with phpDocumentor and for this the format should be
I am not to fussed with the format we use it's simply habit on my side.
Comment #13
garethhallnz commentedAe we just waiting for the community to test this?
Comment #14
xurizaemonYep. I haven't had a chance to test your latest version myself, sorry. Are you using this patch in production?
Comment #15
garethhallnz commentedYes I am
Comment #16
xurizaemonPatch needs re-rolling as it doesn't apply currently - will take another look at it when I get a chance, but I wasn't able to successfully test it this evening. May be easier to commit this at 0f12c0 and roll forward from there?
Comment #17
garethhallnz commentedOk it took some time but I finally figured out what it issue was. I some how got my branches mixed up. I have rerolled the patch please test.
Comment #18
garethhallnz commentedOops forgot one bit in patch 11 here is version 12, please test.
Comment #19
garethhallnz commentedI tested the patch in production to night and seems to work fine for me, can anyone else confirm?
Comment #20
garethhallnz commented@grobot Any chance you can test the patch?
Comment #21
xurizaemonSure, just spotted this. Testing it now.
Comment #22
xurizaemonPatch in #21 will land customers on a 404 post checkout due to the changed callback path (here
commerce_dps_pxpay_pxpay/fprn). What was the reason for modifying that? Ideally, let's have the return URL consistent with other commerce processors - if we do change it, we need a hook_update_N() to clear the menu cache.To maximise your chances of getting committed, try to keep patches minimal. There are ~150 lines of patch here which are whitespace only - they should be in a separate issue (if at all).
git diff -wwill output meaningful changes for you to submit, which would reduce from 545 lines to 393 lines.Maintainer time is a finite resource, so bigger changes = smaller chances of getting a commit in available time.
Feels like a lot of changed code for FRPN. I'll keep this testing on a current project.
EDIT: I didn't say thanks. Thanks for working on this!
EDIT2:
Don't think this is required?
Comment #23
garethhallnz commentedIn order to make FPRN work I needed a uri to handle the request (From my understanding if FPRN is updating the order you do not have the POST request anymore as it could be an hour or 2 later). Even if you did have the POST I suspect Drupal security will reject the POST (sessions / cookies might have changed).
The above being the case I thought it silly to have 2 functions doing the same job (I like DRY). One the POST method and the other the menu callback method so I refactored the module to use one method.
I am not sure what you mean about the hook_update .... my patch already contains this? Search for commerce_dps_pxpay_update_7100()
I know its a lot of code that changed but it's a pretty major refactor and I am not sure how I could have avoided this? I know in some cases I have mixed formatting changes in .... my apologies. Next time around I'll do a separate commit / patch.
Loading the files in the info file. I guess it's not required but thought it's best practice? From Drupals module development documentation.
I rerolled the patch to remove white space. This time I did it from the command line as I think the GUI software was messing it up.
Comment #24
xurizaemon.install commences with "+<?php" so produces a random "+" at the top of the page after certain operations (cache clear etc).
Comment #25
garethhallnz commentedOk I know it's been ages ... I have been bogged down with other work. I'm doing another commerce job with DPS so I'll commit the time to getting this patch sorted this time.
I have gone through my changes and removed all formatting changes so that should cut things down.
I hear what you are saying about the white space but no matter how I roll the patch if I strip the whitespace the patch fails to apply.
To be truthful I have not idea how to fix it.
The above said here is a new patch to test thats is smaller
Comment #26
garethhallnz commentedJust realised that when FPRN updates the order and related transactions it doesn't set the uid correctly.
Now for the most part it's not an issue as the order state is set correctly.
I have attached 2 screenshot with the issue.
Thats said the 2 issues I found are:
1. When using kickstart 2 and messages module the related products are not attached to the end user email.
2. When you are redirected back to the site after payment the page title is a 404 but the correct message is being displayed.
I guess I'll send the uid with the generated request using TxnData1 field and then load the user object when I process FPRN callback.
I am not sure this is the best way but it will work.
Do you have any other suggestions?
Comment #27
xurizaemonI think Order has a UID on it, and that Commerce handles the move from anonymous to real user already when a user was created during the order completion?
Haven't checked, but that would be better. Certainly there's already a way to connect orders to users. Guessing the issue may be because FPRN adjusts the order from an anonymous connection and lacks the session which the ordering user has?
Comment #28
garethhallnz commentedYes that's what I thought FPRN does have the session and it think that is the cause. Great idea looking at the order to get the uid much better than my idea!
Will look at updating the patch on Monday.
Comment #29
xurizaemon$order->uid as it turns out, yeah :)
also note order revisions (and comments?) have uids - if FPRN updates the order, you may need to handle the fact that the revision is being updated by anonymous (if that matters - for some sites you wouldn't care about assigning users to customers anyway)
Comment #30
garethhallnz commentedSo did some more work on this.
First I added the uid of the order to the transaction with
It sort of worked. The uid did get set but you were right in that revisions didn't get this value.
It also didn't fix the email notification issue.
Next I thought loading the user and setting a session will do the trick.
I added to the FPRN callback
Now the uid is set on both transaction tables and email notification is working correctly. Yay
However the second issue still exists.
Any ideas why that is?
Maybe? https://drupal.org/node/1344012
Comment #31
xurizaemonGareth, I think I discussed the above approach with you directly regarding why it's not the best approach - it was open to abuse and account hijacking.
Keen to update your patch on this issue to incorporate that fix?
Comment #32
garethhallnz commentedSorry for the long wait ... been prety busy. Truth be told I am not really sure how to fix the issue. I have been in touch with Ryan form Commerce Guys. This is what he had to say.
Anyone able to help?
Comment #33
heathstannardHi Chris & Gareth,
I needed to add FPRN for a client's site recently. Found this issue and used some (well, most) of your work to create a functioning module. I am attaching a patch - my first Drupal patch so hopefully all ok. Could you please check it out.
Gareth - your issue from comment #26 above is not an issue. In the logs the user will always be set to Anonymous when FPRN is used as the request to the site has come from a DPS server, and is therefore not logged in. The fact that they get passed on to checkout/{order_number}/complete and receive a page not found does not matter - in fact it's good as they shouldn't see the completion message. The transaction still gets processed just fine.
I have actually been using PX Pay 2.0 for this client which is a new implementation from DPS so I will create a new issue and patch to allow the use of this.
Thanks for your efforts on this.
Comment #34
heathstannardMy bad, had the old currency code list in there. This patch is better.
Comment #35
garethhallnz commentedThanks for your work.
I do think #26 is an issue.
Technically everything works in the back end but it's a pretty poor enduser experience.
The problem is when the FPRN transaction is processed anonymously Drupal immediately emails out the order confirmation / status. Since this happens while the user is anonymous and anonymous does not have access to the order information; the order information is not attached to the order email. So the enduser receive a purchase receipt with no product information on it.
I had a chat to Ryan (Core Commerce Developer) and he said none issues in #26 is a problem in the PayPal module. I have been a bit busy and so I haven't had the time but I was going to look at the PayPal module and refactor to match. I know the PayPal module handles the transaction a little different.
It might me worth pursuing?
Comment #36
heathstannardAh yes, I see what you mean now. I wasn't including any order details in my notification email but a quick run through on Commerce Kickstart shows the problem.
#1895418: Table with line items not included in the e-mail sent to regular user has some discussion around it.
It is related to the commerce_cart_summary view. Not recommended but when I disabled SQL rewriting on that view the information came through on the email ok. It seems to apply to any module that uses an IPN/FPRN approach to payment notifications.
Did they solve it in the Paypal module? I'll install and take a look.
Comment #37
heathstannardJust FYI - tested the Paypal module and the problem persists. I'm almost inclined to say that the issue is outside the scope of this module. Possibly more related to Commerce Messages which is making use of that View (commerce_cart_summary).
I think it's fair to expect certain payment methods to anonymously notify Commerce on payment. Going to concentrate on implementing the other DPS methods but will keep an eye on this - it's an interesting issue.
Comment #38
xurizaemonThanks for the work here Gareth & Heath.
I tested with patch from #34, and I found I was able to use the [commerce-order:commerce-email-order-items] token to display the ordered items in the resulting email (tested with tokens in both the default Commerce commerce_checkout_order_email and Commerce Message's commerce_checkout_order_email_html rule). This is probably just a similar view to the !order_summary token mentioned in the related issue. If that's specific to one module's line item view, that's not our problem IMO.
I do have one remaining issue with this patch attached - the user isn't automatically logged in on return (most likely since we gave their auth to DPS). This is a regression so would like to resolve that (and test against Kickstart) before we commit this.
Other changes -
Comment #39
xurizaemonUpdate to above - after a bit more digging, Kickstart doesn't log the user in either - but it does offer access to user/%/orders/% by way of commerce_order_customer_order_view_access(), which this modified patch does.
Let's get reviewing :)
EDIT: Wrong commit here! See #41
Comment #40
xurizaemonComment #41
xurizaemonSo #39 was the wrong commit :D
Tested with Kickstart.
Comment #43
garethhallnz commentedHi Chris
I have gone through and retested the patch and all seem to work. I have also had my original patch in production for over a year with no issues. I think it safe to make this as tested.
Comment #44
xurizaemonFixed in #42
Comment #45
millionleaves commentedWhich version of the module should this patch be applied to? I have the -dev release from Oct 17 and when I try to apply the patch I get this message:
Reversed (or previously applied) patch detected! Assume -R?However, the version of the file being patched has no mention of FPRN, so I'm guessing the patch also includes some other changes to the releaased version of the module that were already applied in the -deve version. If that's the case, I'm guessing I should roll back to the last release and then apply the patch, but would appreciate some guidance before taking that step.
Thanks
David
Comment #46
xurizaemonComment #42 links through to this commit: http://cgit.drupalcode.org/commerce_dps/commit/?id=4c85258
That's what you'll get with 7.x-1.x-dev at the moment, and it should include FPRN.
To test: submit a transaction, and don't follow the link back from PxPay to your site. Review your server logs / order and you should see the transaction completed anyway, provided that the DPS server was able to tap your FPRN URL.
Note that activating the new menu callback requires cache clear.