Module currently produces invalid notify_url based on $payment_method['instance_id'], e.g. example.com/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps

Which results in 404 when returning from PayPal.

Files: 
CommentFileSizeAuthor
#36 mk-fix-for-paypal.patch1.03 KBmikecar

Comments

The problem isn't in the URL encoding or the "return" from PayPal; it's actually that the PayPal WPS form specifies a notify URL containing a payment method instance_id while the menu item in the PayPal module expects a payment method method_id. I'm looking into it to see if the instance_id is necessary, and if so we can just update that menu item accordingly.

Status:Active» Fixed

Ok, I just changed the menu item to accept an instance_id instead of a method_id... meaning it'll load the payment method indicated in the URL along with its settings from the Rules action that enables it. This seems to be closer to the heart of what the IPN processing function is intending to do anyways. Go ahead and update and report back if you still have problems.

Note: I also just committed a bunch of fixes for this module to work with the latest dev version of the Commerce modules. You may need to rebuild your test site if you aren't already running dev.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

I am having hard time finding documentation on what url to use on Paypal side for IPN.
Do I define this via WPS rule or is there a predefined url?

Nope, you shouldn't put anything in at PayPal for the IPN URL. This data is included automatically in the form used to redirect to PayPal.

Great, thanks. I take it that order status will only change upon completion of an order on a publicly accessible server.

Sorry to open this again but in PayPal the two options are Receive IPN messages (Enabled) or Do not receive IPN messages (Disabled). The enabled option requires a properly formatted URL.

Just to make sure, the redirect to PayPal form uses different method (API most likely) to communicate with PayPal and receive the proper notification upon order completion and trigger order status change from pending to complete.

Subscribe

Having same problem. This has become a showstopper.

Perform order
Go through paypal (sandbox) correctly
return to site
No payment details displayed in order

Reports of 404 page not found when paypal returns information back to the following address:

/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps

Server is publicly contactable and all modules are upto date

still broken - getting complaints from paypal

notify_url value sent from drupal commerce is preposterous bogus garbageo

Can you post the notify_url that's getting posted here? I don't see any reason in the code for it to be anything other than a URL to your site.

Same problem. The email from PayPal is:

Please check your server that handles PayPal Instant Payment Notifications (IPN). IPNs sent to the following URL(s) are failing:

http://www.mysite.com/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps

Status:Closed (fixed)» Active

Additional info, watchdog errors:

Type page not found
Date Monday, August 6, 2012 - 15:41
User Anonymous (not verified)
Location http://www.mysite.com/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps
Referrer
Message commerce_paypal/ipn/paypal_wps|commerce_payment_paypal_wps
Severity warning

and (note the time difference - I only placed one order and was redirected by PayPal back to my site within a few seconds.)

Type commerce_paypal_wps
Date Sunday, August 5, 2012 - 16:55
User admin
Location http://www.mysite.com/checkout/1/payment/return/9PUQtXEcH4eoYdZU4KasspsFEWWfOEDYVPZT2EobtZM?tx=7A043351DY559160G&st=Completed&amt=1.03&cc=USD&cm=&item_number=
Referrer
Message Customer returned from PayPal with the following POST data:
Array
(
)
Severity notice

Status:Active» Postponed (maintainer needs more info)

Are you able to load [your site]/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps in a browser or do you get a 404?

Have you tried clearing the menu cache?

All caches cleared, that URL causes a 404.

Subject: PayPal Instant Payment Notification Warning

Dear ...,

Please check your server that handles PayPal Instant Payment Notifications
(IPN). Instant Payment Notifications sent to the following URL(s) are
failing:

http://sitename.com/paypal/ipn

If you do not recognize this URL, you may be using a service provider that
is using IPN on your behalf.

Just received the above from Paypal, 2 days after the site went live. What have I not configured correctly?

Literally nothing, as it should be completely automatic. I'm beginning to wonder if something didn't change in Drupal core that's making this URL inaccessible. I've never had a problem with IPN delivery on my site, but I may be a version behind.

Thanks, Ryan

The site is running Drupal 7.15 and dev version of Commerce

I just ran a fresh install of the following:

Drupal 7.15
Commerce 7.x-1.3
PayPal 7.x-1.x-dev

After enabling all of the modules including PayPal WPS, I only received the 404 before clearing caches. After caches were cleared, I see activity in watchdog that suggests IPNs are being processed whenever commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps is accessed.

The only strange thing that I can see is the url encoding of "|" to %7C, but I don't see how this would break the menu router or cause any 404's.

I'm happy to help troubleshoot this with anyone in the #drupal-commerce IRC channel. Just shoot me a ping.

Did you use the Commerce Kickstart installation profile? I did not, and I'm wondering if there's something different between the Kickstart installation and Commerce modules. I'm using:

Drupal 7.9
Commerce 7.x-1.3
PayPal 7.x-1.x-dev

I'll try upgrading Drupal to 7.15 and see if that fixes the problem.

I did not use commerce kickstart. I installed a fresh copy of D7.15 and added commerce and commerce_paypal.

Status:Postponed (maintainer needs more info)» Active

Ok, I'm receiving threatening emails from Paypal after every order with:

Instant Payment Notifications sent to the following URL(s) are
failing: http://sitename.com/paypal/ipn

Why do Paypal say the URL is "http://sitename.com/paypal/ipn" ? Isn't it supposed to be "http://sitename.com/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_pa..."? Or do they just shorten it in their emails?

Stan, what version of Drupal are you using? I just updated from D7.9 to D7.15, and it now works. (Yay!) Something in the Drupal upgrade (or upgrade process) fixed the same Paypal issue for me.

Cindy, it's 7.15 for me too. The thing is, I'm happily receiving payments from Paypal and see no errors in logs/have is no configuration to troubleshoot but they are unhappy with that URL and may disable IPN on my account. I can access "/commerce_paypal/ipn/paypal_wps%7Ccommerce_payment_paypal_wps" no problem but Paypal report "/paypal/ipn" in their emails, which 404s.

I guess the question is why are they expecting /paypal/ipn to exist? Did you add this in your PayPal profile somewhere? It isn't coming from this module.

Status:Active» Postponed (maintainer needs more info)

Thanks a lot, Ryan, you put me on the right path - spoke to Paypal technical support and they re-set IPN preferences for my account. I'm changing the status of this issue back to the way it was before - "postponed".

I do have a question about #5 though - "Nope, you shouldn't put anything in at PayPal for the IPN URL. This data is included automatically in the form used to redirect to PayPal." - does it mean that IPN should be set to "disabled" in Paypal account profile on their site?

Theoretically, it shouldn't matter, but apparently somewhere along the line PayPal started caring. What I don't know is if disabling would also disable the IPNs sent to our custom notify_urls.

From my experience, changing IPN settings to disabled in on PayPal's end (at least in sandbox) does NOT prevent IPN functionality from working properly.

Status:Postponed (maintainer needs more info)» Closed (cannot reproduce)

I also just confirmed this for my live site using this module - my PayPal account has IPN turned off, but PayPal WPS related IPNs are coming through just fine and are not generating 404 errors at the URL in question. Even in local testing, I am not able to force 404 errors. Without any way to reproduce this error, there's not much we can do. If someone gets a test environment going that consistently fails and is willing to share that for us to debug, we can reopen this.

Until then, I'm just going to mark it closed and reiterate:

You do not have to configure the IPN settings at PayPal at all. In fact, unless you know you need to receive general IPNs from PayPal beyond the IPNs generated specifically by PayPal WPS (such as for some other module using PayPal for recurring transactions), you should leave IPN off in your profile settings.

PayPal offers some troubleshooting tips here:

https://www.x.com/content/ipn-troubleshooting-steps

It could be that your web server firewall settings are blocking remote POSTs, which would result in PayPal attempting to send IPNs that show up in the Drupal logs as being empty. I can't think of any reason for it to show a 404, though, unless some other module on the site is changing the IPN URL... perhaps in a multilingual setup that could be happening if a module is altering path elements or something.

FYI,

On my last two sites, I have had to turn IPNs on in the Paypal account settings, with the http://example.com/commerce_paypal/ipn as the url. Neither of the them worked at all until I changed this. We simply were not getting any IPN notifications. Orders had no payment transactions.

Hmm, honestly that shouldn't matter at all, because PayPal uses whatever IPN URL gets sent with the transaction. If one gets sent with it, then it ignores whatever's in the settings form. : ?

Unless, are you using PayPal for subscription payments?

No, just regular WPS redirect.

It didn't work unless I manually turned it on in Paypal itself. That was the only change.

It's working fine for me with IPNs turned off in Paypal account settings - still get IPNs through Commerce.

Here's what happened to me: We did a site redesign for a client that was previously using a different shopping cart system. PayPal WPS transactions seemed to be going through OK and I was getting back a single POST message in my Drupal watchdog logs. I thought everything was working well until I looked at the Payment tab for an order that was placed using the PayPal WPS payment method. It didn't have any payment record.

Then I decided to switch to my PayPal sandbox URL and checked out with a PayPal sandbox account. It went through, I got 3 messages in the watchdog log, and the order's payment tab had the PayPal transaction information. Success. So, I figured it had to be a setting in my client's PayPal account.

After more investigating/research I figured I'd have a look at the IPN History. I noticed each entry said "Disabled." I figured, after reading the commerce_paypal docs, that this was OK. I also noticed the notify_url was correct. So, why wasn't it working? Well, I had a look at the IPN settings and noticed that the URL was still pointing to their old site. I changed this to be the same address as the notify_url that I was seeing in the IPN history. I also set "Message delivery" to be "Enabled" by turning on IPN. I put through a test transaction and was happy to find 3 messages in the watchdog logs. I then had a look at the payment tab and found the PayPal transaction information there. Yay! Lastly, I checked the commerce_payment_transaction table in the DB and sure enough, there was a row there for the new paypal_wps transaction.

Now, I don't know which setting made it work, or if both changes made it work, but it works. The IPN History status showing "Sent" vs. "Disabled" makes me think it was important for me to turn on IPN. I think it would've worked without fixing the IPN url given that all of the entries seemed to be using the right notification URL. Also, when I view the IPN details of an entry BEFORE the changes I notice no response code and a delivery status of "Disabled." When I view one after the changes, I see a response code of 200 and a delivery status of "Sent."

StatusFileSize
new1.03 KB

in case anybody is interested: I run across this issue, and debugged it. the *current* problem lies with paypal, not the module. it seems that sometimes paypal will call back with the wrong url encoding of the ipn url. therefore, the pipe symbol "|", required by commerce_payment, gets mangled to %7C, and the Drupal menu router gags (actually the commerce_payment loaded does). What makes this extremely hard to diagnose is that this behavior is not consistent. sometimes paypal calls with the correct url, sometimes not.
who knows why.

in any case, the attached patch fixes this issue, while not doing something bad (I hope) when the bug does not manifest. in essense, it hijacks the commerce_payment loader, and fixes the url segment. it is generated against the latest version of commerce_paypal, commerce_paypal-7.x-2.x-dev (as of 21-05-2013)

I hope this helps somebody....

I like the look of mikecar's patch, and I've applied it. Some hours later, I got another email from paypal. So, either they are sending an email because requests failed before I applied the patch. Or, the patch isn't fixing the problem. I can't tell which.

The email contains:

Please check your server that handles PayPal Instant Payment Notifications (IPN). IPNs sent to the following URL(s) are failing:
https://www.greatsunflower.org/store/commerce_paypal/ipn/paypal_ec%7Crules_paypal
https://www.greatsunflower.org/store/commerce_paypal/ipn/paypal_wpp%7Ccommerce_payment_paypal_wpp
If you do not recognize this URL, you may be using a service provider that is using IPN on your behalf. Please contact your service provider with the above information. If this problem continues, IPNs may be disabled for your account.
Thank you for your prompt attention to this issue.
Thanks,
PayPal