Sandbox IPS Paypal Simulator - 502 Bad Gateway

I just finished implementing a Gateway Server platform that supports Paypal. The gateway also has an adaptive IPN server for Paypal and Skrill notifications. During implementation and testing, I used the documentation provided by the Paypal IPN Guide . During the tests, everything went "All is well." I am testing it using the example given in the documentation "Everything is good":

mc_gross=19.95&protection_eligibility=Eligible&address_status=confirmed&payer_id=LPLWNMTBWMFAY&tax=0.00&address_street=1+Main+St&payment_date=20%3A12%3A59+Jan+13%2C+2009+PST&payment_status=Completed&charset=windows-1252&address_zip=95131&first_name=Test&mc_fee=0.88&address_country_code=US&address_name=Test+User&notify_version=2.6&custom=&payer_status=verified&address_country=United+States&address_city=San+Jose&quantity=1&verify_sign=AtkOfCXbDm2hu0ZELryHFjY-Vb7PAUvS6nMXgysbElEn9v-1XcmSoGtf&payer_email=gpmac_1231902590_per%40paypal.com&txn_id=61E67681CH3238416&payment_type=instant&last_name=User&address_state=CA&receiver_email=gpmac_1231902686_biz%40paypal.com&payment_fee=0.88&receiver_id=S8XGHLYDW9T3S&txn_type=express_checkout&item_name=&mc_currency=USD&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=19.95&shipping=0.00 

The problem started when we deployed the gateway to our production server and passed the test using the simulation form provided by Paypal IPN Simulator . Well, when I clicked the Send IPN button, the message did not reach my server, and after a few seconds (more minutes) the HTTP error message appeared: enter image description here

Yes 502 Bad Gateway ! What the heck is that?!? The message did not even get to the server. A few notes, we do not use standard 80/443 ports, and we only support "POST" messages. Again, the IPN message does not reach our server, we check it with other testing tools, and the message arrives successfully.

Please, help!

→ We use Express Checkout by the way!

+6
source share
1 answer

You should avoid placing the host in your headers.
Change this:

  $header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; $header .= "Host: www.paypal.com\r\n"; *****DELETE THIS LINE***** $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 

For this:

  $header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 
-1
source

Source: https://habr.com/ru/post/989034/


All Articles