paypal / ipn-code-samples

Other
562 stars 486 forks source link

Missing POST Data #116

Closed MESWEB closed 6 years ago

MESWEB commented 6 years ago

General information

Issue description

Always error: PHP Fatal error: Uncaught Exception: Missing POST Data in ... PaypalIPN.php:60 ... thrown in /PaypalIPN.php on line 60

overint commented 6 years ago

That would be a problem somewhere higher up that our verification class, since this exception is thrown only if the $POST superglobal is empty.
Have you ensured your web server is correct passing post data to PHP?

MESWEB commented 6 years ago

No. My server is a shared server - how to check this passing POST?. But If I use this:

<?php
/**
 * https://www.experts-exchange.com/questions/28997357/echo-paypal-data-on-screen.html
 *
 * Show how to capture PayPal IPN error messages and write them into the log
 */
error_reporting(E_ALL);

// START THE OUTPUT BUFFER RIGHT AT THE TOP
ob_start();

/**
 * DO THE IPN PROCESSING HERE
 * USE PHP ECHO TO WRITE YOUR OWN ERROR MESSAGES
 */

// CAPTURE THE OUTPUT BUFFER RIGHT AT THE END
$ob = ob_get_clean();

// IF THERE IS ANYTHING IN THE BUFFER, SAVE IT
if ($ob) error_log($ob);

I see all variables with values in error log.

overint commented 6 years ago

Have you just using the code provided here? https://github.com/paypal/ipn-code-samples/blob/master/php/example_usage.php

Do you get any errors?

MESWEB commented 6 years ago

Yes exactly if I use function verifyIPN the I get error about missing POST. This code is working fine and save all variables with values in test.txt file:

require('PaypalIPN.php');
use PaypalIPN;
$ipn = new PaypalIPN();
// Use the sandbox endpoint during testing.
$ipn->useSandbox();
$verified = $ipn->verifyIPN();
if ($verified) {
    $handle = fopen("test.txt", "w");
    foreach ($_POST as $key => $value)
        fwrite($handle, "$key => $value \r\n");
    fclose($handle);
    /*
     * Process IPN
     * A list of variables is available here:
     * https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/
     */
}

// Reply with an empty 200 response to indicate to paypal the IPN was received correctly.
header("HTTP/1.1 200 OK");

This is test.txt: payment_type => instant payment_date => Thu Dec 14 2017 10:20:11 GMT+0000 (GMT (czas standardowy)) payment_status => Completed payer_status => verified first_name => John last_name => Smith payer_email => buyer@paypalsandbox.com payer_id => TESTBUYERID01 address_name => John Smith address_country => United States address_country_code => US address_zip => 95131 address_state => CA address_city => San Jose address_street => 123 any street business => seller@paypalsandbox.com receiver_email => seller@paypalsandbox.com receiver_id => seller@paypalsandbox.com residence_country => US item_name1 => something item_number1 => AK-1234 quantity => 1 shipping => 3.04 tax => 2.02 mc_currency => USD mc_fee => 0.44 mc_gross => 12.34 mc_gross_1 => 12.34 mc_handling => 2.06 mc_handling1 => 1.67 mc_shipping => 3.02 mc_shipping1 => 1.02 txn_type => cart txn_id => 899327589 notify_version => 2.4 custom => xyz123 invoice => abc1234 test_ipn => 1 verify_sign => A3ZvRt6h92yDknX3q4opF9Gbcu.GAc9LM29Zdyhsddsafadfsew

So that's seems Your Listener is not working properly?

Ok I was check PayPal message from this link https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#id08CKFJ00JYK using POSTMAN application and everything working fine. This is look like PayPal got disabled POST messages from sandbox.

MESWEB commented 6 years ago

Problem solved.

metabinaryio commented 4 years ago

Problem solved.

How you solved this problem?