PayPal Payment Data Transfer (PDT) "Invalid host header" in PayPal sandbox mode.
Payment Data Transfer (PDT) does not work in sandbox mode. When I expect data from a transaction, hereunder the email of the customer's paypal account, I instead receive the message "Invalid host header."I understand PDT to work this way: When a customer has made a payment to my paypal account paypal sends me a token that I must return together with the auth_token from the account. Paypal then sends me the data from the transaction.
In the program I receive, in both modes, the token correctly, for example 2W04538282383663P. Then I open a connection successfully with
"$fp = fsockopen ($fsock, 443, $errno, $errstr, 30);"
$fsock is ssl://www.sandbox.paypal.com i sandbox mode and ssl://www.paypal.com in live mode.
Then follows
"fputs ($fp, $header . $req);"
The values for $req contains the token I have received and for each of the two modes the auth_token (that I have checked and double checked). For the rest $req is identical for the two modes. For example for sandbox $req=
cmd=_notify-synch&tx=2W04538282383663P&at=skNPZNT1DR3rR8sJKm6CytFp0VNGa0J0aXH-QWZ6eFofoc3yu8Zo-WIjeqG
$header is identical for the two modes:
POST /cgi-bin/webscr HTTP/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 101
Then the programme continues:
while (!feof($fp)) {
$line = fgets ($fp, 1024);
......
}
In sandbox mode the lines received are:
HTTP/1.0 400 Bad Request
Server: BigIP
Connection: close
Content-Length: 19
" "
Invalid Host header
In live mode the first lines received are:
HTTP/1.1 200 OK
Date: Sun, 09 Sep 2012 17:54:00 GMT
......