Validate that IPN call is from PayPal?

前端 未结 6 1982
南方客
南方客 2020-12-09 21:58

How can I validate that a PayPal IPN POST request to my specified notifyURL is indeed coming from PayPal?

I don\'t mean comparing the data to what I sent earlier, bu

6条回答
  •  感情败类
    2020-12-09 22:18

    HTTP header User-Agent required now!

    $vrf = file_get_contents('https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate', false, stream_context_create(array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\nUser-Agent: MyAPP 1.0\r\n",
            'method'  => 'POST',
            'content' => http_build_query($_POST)
        )
    )));
    
    if ( $vrf == 'VERIFIED' ) {
        // Check that the payment_status is Completed
        // Check that txn_id has not been previously processed
        // Check that receiver_email is your Primary PayPal email
        // Check that payment_amount/payment_currency are correct
        // process payment
    }
    

提交回复
热议问题