PayPal problem

717 views
Skip to first unread message

Stefan Bradl

unread,
Aug 26, 2012, 3:38:36 PM8/26/12
to lif...@googlegroups.com
Hi,

I am trying to integrate paypal into my little online shop. Payment works fine (seller and buyer can see the transaction in their paypal accounts).
However, When paypal tries to redirect to my /paypal/pdt url i can see warnings in the console and my website shows a 404. 

The url paypal tries to redirect to ends with "/paypal/pdt?tx=2TK29712T1300621U&st=Completed&amt=20.60&cc=EUR&cm=&item_number="

This is the console output:
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; c9MWDuvPtT9GIMyPc3jwol1VSlO=kQ4xoC6ciDcG38cp8pJnq-DiqmzH53nFEg8dRQfUD-NfZAxUFe4gLgIHWUTy23aJSV7NNxcMwO0Ov5mm1gW7nI-6DLsBf38mgzXtBk3C3JTwSjkQqf3rSthmK6BqFKXVL3fUam%7cL0wTE3OBHkOLkiDSRpc4ZQxaGufPsCtESNZJdxMeqAquv5MtvzKiTN6A_VsF5pmagaDOiW%7cYLWgF0hZ8CkQfqCTv9E3MGVNZrR50YlQKTNPbfBcgCGVwapQaqyvi0fV6cw5MFis5Llgq0%7c1346009543; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; -1ILhdyICORs4hS4xTUr41S8iP0=oCaBZO6ldsRavEIEZ-Gt86BlUgm9C3cU4PQAMjPMdX_JQkhp_qZRhmYsvrBfXhJV5EFQgIceTbuJgP1z; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; cookie_check=yes; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; navcmd=_notify-synch; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; navlns=0.0; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots
Aug 26, 2012 9:32:17 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders
WARNING: Cookie rejected: "$Version=0; feel_cookie=a%2013%20_notify-synch%20b%200%20%20c%206%20webscr%20d%200%20%20e%2026%20Customer%2fgeneral%2fAbort.xsl%20f%200%20%20g%205%20en_US%20h%200%20%20i%2026%20xpt%2fCustomer%2fgeneral%2fAbort%20j%200%20%20k%2041%20Online%20Payment%2c%20Merchant%20Account%20-%20PayPal%20l%200%20%20; $Path=/; $Domain=.paypal.com". Domain attribute ".paypal.com" violates RFC 2109: host minus domain may not contain any dots

The IPN handler is never called.

Anyone has an idea what could cause this problem?

Thanks in advance

--
Best regards
Stefan Bradl


Matt Farmer

unread,
Aug 28, 2012, 8:14:02 AM8/28/12
to lif...@googlegroups.com, bradl...@googlemail.com
So, it may be a good idea to build a sample project exhibiting this behavior for us to play around with. That said, it looks like it doesn't like a Cookie Domain somewhere in the mix. Without knowing more about your particular code, that's all I can tell you.

Richard Dallaway

unread,
Aug 29, 2012, 2:31:40 AM8/29/12
to lif...@googlegroups.com
At a guess, the 404 is probably a pattern match you think should succeed, but isn't; or a value you're extracting in a for-comprehension, but the value isn't there.

It'd be good to see some of the code for this to help; failing that, what I can suggest is putting more logging in and running through a few sandbox transactions.  For pattern matching in partial functions, that's probably straight forward. In the case of for-comprehensions you can include a small pass-through logging function on the right-hand side of the <-.  E.g., something like:

def logthru[T <% AnyRef](f: => T): T = {
    val r = f
    logger.debug(r)
    r
  }

Maybe you'll spot a None or Empty.

Debugging PayPal and working with the PayPal sandbox is a time suck. You have my sympathies. 

Richard


--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
 
 

Stefan Bradl

unread,
Aug 29, 2012, 2:39:04 AM8/29/12
to lif...@googlegroups.com
Sample project is already here: https://github.com/sbradl/lift-paypal-problem

It is the bare minimum I could come up with. 

2012/8/29 Richard Dallaway <ric...@dallaway.com>

Stefan Bradl

unread,
Aug 29, 2012, 2:46:49 AM8/29/12
to lif...@googlegroups.com
There are no boxes and no for comprehensions. The paypal handler just does some logging or redirecting or at least it should.

2012/8/29 Stefan Bradl <madre...@gmx.de>

Jeppe Nejsum Madsen

unread,
Aug 29, 2012, 4:39:22 AM8/29/12
to lif...@googlegroups.com
Richard Dallaway <ric...@dallaway.com> writes:

> At a guess, the 404 is probably a pattern match you think should succeed,
> but isn't; or a value you're extracting in a for-comprehension, but the
> value isn't there.
>
> It'd be good to see some of the code for this to help; failing that, what I
> can suggest is putting more logging in and running through a few sandbox
> transactions. For pattern matching in partial functions, that's probably
> straight forward. In the case of for-comprehensions you can include a small
> pass-through logging function on the right-hand side of the <-. E.g.,
> something like:
>
> def logthru[T <% AnyRef](f: => T): T = {
> val r = f
> logger.debug(r)
> r
> }
>
> Maybe you'll spot a None or Empty.

Note that Lift already has a trace method that does the above:

scala> val v = logger.trace("The value is", 42)
v: Int = 42

But the added box-trace method sometimes get in the way when you need to
log Box'ed values :-(

/Jeppe

Richard Dallaway

unread,
Aug 29, 2012, 7:06:29 AM8/29/12
to lif...@googlegroups.com
On 29 August 2012 07:39, Stefan Bradl <madre...@gmx.de> wrote:
Sample project is already here: https://github.com/sbradl/lift-paypal-problem

It is the bare minimum I could come up with. 

That's useful.  I had to remove a mapper import to get it to compile.

What I'd suggest is turning on http wire debugging to see what's going back to PayPay during the PDT part. Add this to boot and see if that shows any light on what's going on with the transaction:

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog")
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true")
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug")
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug")


Richard

Richard Dallaway

unread,
Aug 29, 2012, 7:07:01 AM8/29/12
to lif...@googlegroups.com
Cool.  Thank you.  Another thing that Lift's implemented for me so I don't have to :-)

Stefan Bradl

unread,
Aug 29, 2012, 7:32:18 AM8/29/12
to lif...@googlegroups.com
Added the stuff to boot but still cannot see anything else than the cookies being rejected. I attached the log. 

2012/8/29 Richard Dallaway <ric...@dallaway.com>



--
Mit freundlichen Grüßen
Stefan Bradl


log

Stefan Bradl

unread,
Aug 29, 2012, 7:46:39 AM8/29/12
to lif...@googlegroups.com
I added System.setProperty("apache.commons.httpclient.cookiespec", "COMPATIBILITY") to boot. Now the cookies are accepted but the rest is still the same.

When paypal redirects it uses this url: /paypal/pdt?tx=41Y485830M822550G&st=Completed&amt=11.98&cc=EUR&cm=&item_number=
Then I get the 404. But why a 404?

2012/8/29 Stefan Bradl <bradl...@googlemail.com>

Richard Dallaway

unread,
Aug 29, 2012, 7:50:37 AM8/29/12
to lif...@googlegroups.com
The cookie rejection stuff is part of the HTTP request going back to PayPal to to collect details of the order as part of PDT. My current hypothesis is that the cookies are irrelevant.

The log shows the Paypal module making the request back to PayPal. E.g.,

Open connection to www.sandbox.paypal.com:443

POST /cgi-bin/webscr HTTP/1.1

"cmd=_notify-synch&tx=7WB37996G9584592L&at=G-PnY9bPHn2l4XJdMXpwC2FbnVwHaJfSD1d_F4mz28_oEidU2f67B6nl3RS"

The response back should be SUCCESS or FAILURE, but it looks like Paypal is returning you a HTML page. That's not what I'd expect -- even after checking the docs: https://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec/pdt-techview-outside

So the problem is Paypal's sandbox returning you a HTML page rather than a SUCCESS or FAIL message. The Paypal module is giving a 404 because it cannot interpret the response from PayPal.

The real question is why Paypal is returning a HTML response.  I found this:

"Usually you will get a HTML error page as a response when either the cmd value of the postback is not recognized or during maintenance periods when the site is unavailable"

You may have more luck seeing if there's currently a sabdbox issue on the paypal support forum.
Richard

Stefan Bradl

unread,
Aug 29, 2012, 8:03:28 AM8/29/12
to lif...@googlegroups.com
Ok that explanation helped a lot. The returned html is indeed an error page stating that the transaction could not be completed. Did not yet find out why this error page is returned.

But I think it would be a good idea that the paypal module should check for error pages being returned and displays them!?

2012/8/29 Richard Dallaway <ric...@dallaway.com>

Richard Dallaway

unread,
Aug 29, 2012, 10:45:27 AM8/29/12
to lif...@googlegroups.com
On 29 August 2012 13:03, Stefan Bradl <madre...@gmx.de> wrote:
Ok that explanation helped a lot.

Great!
 
The returned html is indeed an error page stating that the transaction could not be completed. Did not yet find out why this error page is returned.

Ok - do let us know when you find out the cause.
 
But I think it would be a good idea that the paypal module should check for error pages being returned and displays them!?

Sounds reasonable to me.  You're welcome to create a ticket for the module and reference this thread: https://github.com/liftmodules/paypal/issues

I'm unlikely to work on improving the module this year, but you (or anyone else) can get involved and work on the source for that module if you want to make it happen.

Richard

Stefan Bradl

unread,
Aug 29, 2012, 11:08:36 AM8/29/12
to lif...@googlegroups.com

Ok - do let us know when you find out the cause.
 
Of course
 
 
But I think it would be a good idea that the paypal module should check for error pages being returned and displays them!?

Sounds reasonable to me.  You're welcome to create a ticket for the module and reference this thread: https://github.com/liftmodules/paypal/issues

I'm unlikely to work on improving the module this year, but you (or anyone else) can get involved and work on the source for that module if you want to make it happen.

 Yeah I would like to work on it. I definitly need a paypal module because I am working on an online shop. 

Stefan Bradl

unread,
Aug 29, 2012, 2:19:46 PM8/29/12
to lif...@googlegroups.com
Some trying-out and searching the web I think the problem lies within the paypal sandbox. From the documentation PDT should never return any http, just SUCCESS or FAIL. I also noticed that the transaction is listed in the overview but clicking on details shows the same error page which is sent as a response to the pdt request...
 
From searching the web it seems that the sandbox has problems quite often... maybe paypal wants developers to test on the live system to make money... -.-

Stefan Bradl

unread,
Aug 29, 2012, 2:49:24 PM8/29/12
to lif...@googlegroups.com
Just created a real paypal business account and it still does not work. I don't get the error html but PDT fails with error code 4003...

2012/8/29 Stefan Bradl <madre...@gmx.de>

Tobias Daub

unread,
Mar 27, 2013, 2:47:35 PM3/27/13
to lif...@googlegroups.com
Hi Stefan,

ich habe gerade Deine Mails gelesen.

Ich habe auch (wieder) ein paar Probleme mit PayPal. Welche URL hast Du
denn bei "Einstellungen für sofortige Zahlungsbestätigungen"
eingetragen? Reicht der Hostname oder muss noch ein /paypal hinten dran?

Bei mir funktioniert aktuell weder das Zurückleiten (obwohl es bei den
PayPal Einstellungen aktiviert ist) noch die IPN/ PDT Konfiguration
seitens Lift.


Danke und viele Grüße,

Tobias

Stefan Bradl

unread,
Mar 27, 2013, 2:56:42 PM3/27/13
to lif...@googlegroups.com
If I remember correctly you have to enter the full url to your paypal handler.

I haven't done anything with paypal for a few months now (an I could not get it to work). Dunno if anyone is using the paypal module in production at the moment who can tell something more about it. 

2013/3/27 Tobias Daub <je...@tobster.org>
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Tobias Daub

unread,
Mar 27, 2013, 3:21:58 PM3/27/13
to lif...@googlegroups.com
Thanks for the very fast answer!

Can you give an example for "full URL"?

Thanks!

Stefan Bradl

unread,
Mar 27, 2013, 3:44:07 PM3/27/13
to lif...@googlegroups.com
From the code at https://github.com/liftmodules/paypal/blob/master/src/main/scala/net/liftmodules/paypal/Paypal.scala (line 457 ff.)
it should be something like http://www.yourdomain.de/paypal/pdt or ../paypal/ipn
There is a test tool in the paypal sandbox where you can test your urls

2013/3/27 Tobias Daub <je...@tobster.org>

Tobias Daub

unread,
Mar 28, 2013, 4:47:23 AM3/28/13
to lif...@googlegroups.com
That's a good point, because that's something I didn't understand!

At the moment, in my case (and as I saw its the same in your case),
there are only two files in the paypal directory: success.html and
failur.html.

How can paypal/pdt be accessed, if there's nothing with the name "pdt"
inside the paypal directory?

How does the PayPalHandler works? Does it check all incoming HTTP
traffic, to see if its from PayPal?
> +unsub...@googlegroups.com.

Richard Dallaway

unread,
Mar 28, 2013, 6:16:52 AM3/28/13
to lif...@googlegroups.com
There's a link from https://github.com/liftmodules/paypal to a free PDF from Tim's book showing how to use Paypal module.

The paypal/pdt and paypal/ipn URLs are added to the dispatch table -- I suppose if this was being written today, it'd be RestHelper, if that helps explain it.  To access them you need to make a request with a valid Paypal message (e.g., tx parameter etc).  The way to do that is via the Paypal sandbox (my sympathies).

Hope that helps
Richard
Reply all
Reply to author
Forward
0 new messages