Hello,

I'm using MoneySuite to handle recurring subscription payments. Initially I'm using only Paypal WPS as a Gateway. I have hit a brick wall trying to troubleshoot an IPN issue. I've enabled the most debug I can find, which results in two watchdog messages:
1. "Failed IPN validation. Response: Error: IPN Validation Error: Bad Request Vars: "
2. "Error: An IPN has Failed Validation. This may be from a spoofed IPN or an attempt to hack. Here are the details: Data: "

The output for these messages is as below:

Failed IPN Validation. Response: Error: IPN Validation Error: Bad Request Vars:

Array
(
[txn_type] => subscr_signup
[subscr_id] => I-E5SARW9C9H40
[last_name] => er
[residence_country] => GB
[mc_currency] => GBP
[item_name] => somename
[business] => someaddress@somedomain.com
[recurring] => 1
[verify_sign] => AqBqA1nSf.CEBj1d5rbDP.LO-woKAVgmx7RW1vxZGgWe955vj6OLIZFv
[payer_status] => verified
[test_ipn] => 1
[payer_email] => somebuyer@somedomain.com
[first_name] => buy
[receiver_email] => someone@somewhere.com
[payer_id] => K5LVGFLDVJL7S
[reattempt] => 1
[subscr_date] => 08:03:08 May 20, 2016 PDT
[custom] => 12
[charset] => utf-8
[notify_version] => 3.8
[period1] => 3 D
[mc_amount1] => 0.00
[period3] => 1 M
[mc_amount3] => 3.99
[ipn_track_id] => e64cd704e722d
[charset_original] => windows-1252
)

Error: An IPN has Failed Validation. This may be from a spoofed IPN or an attempt to hack. Here are the details: Data:

Array
(
[q] => paypal/backend
[txn_type] => subscr_signup
[subscr_id] => I-E5SARW9C9H40
[last_name] => er
[residence_country] => GB
[mc_currency] => GBP
[item_name] => somename
[business] => someaddress@somewhere.com
[recurring] => 1
[verify_sign] => AqBqA1nSf.CEBj1d5rbDP.LO-woKAVgmx7RW1vxZGgWe955vj6OLIZFv
[payer_status] => verified
[test_ipn] => 1
[payer_email] => address@something.com
[first_name] => buy
[receiver_email] => address@somewhere.com
[payer_id] => K5LVGFLDVJL7S
[reattempt] => 1
[subscr_date] => 08:03:08 May 20, 2016 PDT
[custom] => 12
[charset] => windows-1252
[notify_version] => 3.8
[period1] => 3 D
[mc_amount1] => 0.00
[period3] => 1 M
[mc_amount3] => 3.99
[ipn_track_id] => e64cd704e722d
)

Note that I've changed email addresses and subscription names above in a vague attempt to protect information; however please note that the real addresses are properly formed in the debug output and are consistent with the values specified in my configuration.

I'm looking for advice on how I can troubleshoot this further and perhaps if there is anything that I might have missed at the Paypal end? I am using PayPal sandbox accounts for now.

Thanks,
Dan

Comments

goldtopdon created an issue. See original summary.

Andrew Jamieson’s picture

I can confirm that I also had issues trying to get the paypal WPS to work. Paypal received the recurring order and the payment went though and setup a recurring profile on paypal but when I was directed back to my site it got to a page with a loader and just hung. ie My site never got the payment success info from Paypal. How do I check the watchdog messages to make this more useful?

I have just realised I was testing locally, maybe this is the problem. I will test on my server and see If that helps.

Thanks
Andy

Farreres’s picture

I am not using the paypal gateway, someone with knowledge should try to solve this bug.

Farreres’s picture

Andrew, as you say, the payment is successfully being processed and the problem is with the information getting back to the site. I would like to help solving this issue, but I need your collaboration. I would need you to go to paypal documents and check whether there has been some change in the past times on the kind of information paypal is returning to sites after payments are processed. I imagine the problem should come from some change in the paypal API return values. If you can do this, I will try to check if the module needs to be updated.

Andrew Jamieson’s picture

Thanks Farreres. Is it not that I was testing locally? Should I not test on my production server first and then get back to you?

Farreres’s picture

Well, you should of course test in some environment where your install can contact paypal engine. Otherwise the errors are meaningless.

Jeff Burnz’s picture

Component: Miscellaneous » ms_core
Category: Support request » Bug report

I have been getting this error on my sandbox as well, I pulled my hair out all afternoon trying to get it work with Drupal and in the end I rewrote function verify() in ms_paypal_wps_class to use Curl following the example code Paypal provides (https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php) and...

It worked. No more Bad Request 400 etc, finally I have a successful IPN verification.

I think the error is coming from drupal_http_request(), but debugging the result is horrible and I just can't see where things are going wrong.

Not sure if the other maintainers see an issue with this (using curl), but I can do some more testing and post a patch for discussion.

Farreres’s picture

Yes, usually when you follow the instructions given by processors surprisingly you find that they work! Please, do the tests you consider appropriate and post here the patch, I will apply to dev and include it in the next stable release.

Jeff Burnz’s picture

Assigned: Unassigned » Jeff Burnz
Status: Active » Needs review
StatusFileSize
new5.51 KB

Heres the patch using curl, I have tested this:

  • PayPal Sandbox with File Download and Membership Suite
  • PayPal Live with File Download.

I would love to see this issue fixed, it's a very long standing issue with this gateway, I've been plagued by IPN issues over the years :/

I'm not sure about my watchdog messages etc, thats one area that might need some eyes specifically.

I would like to commit this please (when RTBC), I am a maintainer and would prefer to commit my own patches.

Cheers.

Farreres’s picture

Go ahead, Jeff, you are maintainer of the module, you can apply the patch.

By the way, when you do, can you check why dev release is not being rebuilt?

surfkid’s picture

Has this been committed? Running some tests and would love to do the same setup. Membership, PayPal. Recurring payments.

Jeff Burnz’s picture

No, we need a proper code review and preferable someone (other than me) to test in both live and sandbox environments.

I have done this, quite extensively in a live site - the past few weeks it has worked flawlessly. I'm tempted to commit it but I feel a bit uncomfortable without at least one other person testing it - call it my natural Drupal developer reticence :)

surfkid’s picture

I will test out the patch. I would love to get this working correctly.

Jeff Burnz’s picture

@surfkid can you apply the patch, if thats an issue I can post the file, it's only one file to replace.

surfkid’s picture

Thanks Jeff.
I applied the patch.
I tested it also before I uploaded the patch file and it worked. I didn't get the IPN errors.
I will tested with the patch as well. And didn't notice a difference.

Jeff Burnz’s picture

I tested it also before I uploaded the patch file and it worked. I didn't get the IPN errors.

Was that in a live site or the sandbox? Many of us experience issues with Paypal sandbox only.

surfkid’s picture

It was a live site.

Jeff Burnz’s picture

Title: Error: An IPN has Failed Validation » Error: An IPN has Failed Validation using Paypal Sandbox

I has to be tested with PayPal sandbox, that is where everyone has encountered issues.

goldtopdon’s picture

Hi Jeff,

Thanks for your work on this; I really appreciate your help.

After applying the patch from #9 and clearing cache I can confirm that the error which I initially reported here is no longer present when using Sandbox; as far as I'm concerned the issue is resolved by your patch.

In my case I'm creating a membership site with recurring payments; I've encountered another error which may well be completely unrelated to the changes applied by your patch but I wanted to run it past you here.

I encountered the following errors in watchdog on receipt of subscr_signup messages from Paypal:

- Setting order status to pending because of payment type rec_failed
- Error: Signup payment received for incorrect amount.

My PHP isn't great but I found something going wrong at line 349 of 'ms_paypal_wps.module' by the presence of this in watchdog:
'Notice: Undefined index: amount3 in ms_paypal_wps_process_ipn() '

I can't quite work out what's wrong with this line, as far as I can tell it should work, however I can confirm that as a workaround I have been able to get past this by changing line 349 to:
'main_amount' => $ipn['mc_amount3'],

Clearly my solution isn't final, and I suspect that it may need to be logged as an issue in its own right. Please let me know what you think.

Regards,
Dan

Mrvinay99’s picture

Hi Jeff,
Does this patch work if applied to moneyscripts module without upgarding to moneysuite.
We have a client whose site has exact same issue, please let me know.

Your help would be appreciated.

Regards
vinay

Jeff Burnz’s picture

@Mrvinay99 Actually I have no idea. I should clean it up (I can see rouge whitespace) and commit it, I've been using this for ages now and no issues at all. You might want to consider upgrading or at least trying it, for me it was surprisingly painless.

Mrvinay99’s picture

First of all thanks for your reply jeff, I tried it on my live test site, I applied it without upgrading the old money scripts module because when i tried to upgrade the module on local setup of client site it wasn't functioning properly.

Jeff can u please add the patch that can work with moneyscripts module as well.

Your help would be highly appreciated.

Jeff Burnz’s picture

Jeff can u please add the patch that can work with moneyscripts module as well.

No because I don't have this project in any version control system currently.

Mrvinay99’s picture

Oh ok, jeff i hope u can fix it if i can provide you the code base of the 'Moneyscripts' module which we are using now, if yes, please let me know what all you will need from my side.

Jeff Burnz’s picture

My time is limited to supporting this module as best I can, sorry but I provided a fix for this issue in this module - why don't YOU apply this patch to our module and take the file from there? Instead you're asking me to do all the work - pretty rude don't you think?

Mrvinay99’s picture

I am sorry jeff if you felt that way, but i tried all of that what you're saying, didn't worked as i mentioned earlier, somehow i'll try to figure it out.
Thank you for your precious time.

Jeff Burnz’s picture

Assigned: Jeff Burnz » Unassigned
Status: Needs review » Reviewed & tested by the community

I'm gonna RTBC my own patch, I know this is working well in my site and others. Lets get it committed.

Mrvinay99’s picture

StatusFileSize
new29.36 KB
new10.28 KB

Hi Jeff,
The patch works fine but now user isn't created and process status remains pending for both transactions, With sandbox accounts and then again with registered buyer and merchant accounts of paypal.

I attached screenshots for reference, any help would be appreciated.

Jeff Burnz’s picture

@Mrvinay99 doesn't seem related, if you have an issue with this module better to open a new issue. This issue is about IPN failures when using the PayPal sandbox.

Farreres’s picture

@jeff my fault, I told him to post here because I thought it was related to this issue.

Jeff Burnz’s picture

We wouldn't know for sure unless an IPN failure is confirmed, since it just says payment pending, whether thats because of an IPN failure I don't know. The thank-you page is showing with "done", so that tells me surely the IPN was received (I have to check, but I think that is that is the case). When an IPN fails that page just never loads, the site hangs and never advances to done.

kebne’s picture

Seems like the patch in #9 was not committed to dev? I can't apply the patch to current version or the dev version either.

same issue: https://www.drupal.org/project/moneysuite/issues/3048379

Farreres’s picture

Ok, I'll patch as soon as I have some free time.