0

I have been trying for some time to get a simple PayPal IPN module working but keep getting a 400 Bad Request error from LWP::UserAgent. I am not sure why this is happening. PayPal pings me fine (I'm using the IPN simulator) and I can see the process in my app logs. I can call the PayPal validation URL via LWP::UserAgent without form content and that works fine, but once I include the request content for validation I get error 400. If anyone knows about this please let me know.

-$self->{'_req'} is of type Plack::Request

my $url     = $test ? $VERIFY_URL_DEV : $VERIFY_URL;
my $ua      = new LWP::UserAgent();
my $req     = new HTTP::Request('POST', $url);
my $query   = 'cmd=_notify-validate&' . $self->{'_req'}->raw_body;

$req->content_type('application/x-www-form-urlencoded');
$req->content( $query );

my $res = $ua->request($req);

if ($res->is_error)
{
    # HTTP error, indicate an invalid notification.
    warn "There was an error validating this IPN.";
    warn $res->message;
    warn $res->error_as_HTML;
    return 0;
}
4

1 回答 1

0

问题出在 PayPal 方面。当我在沙盒而不是 IPN 模拟器中进行测试时,它运行良好。那非常令人沮丧。

于 2013-03-14T18:29:33.087 回答