Blog of King Software

Learn online with us in simple steps.


Created by Bhavesh Gohil & Rikita Vasava on Date: 24/08/2021

Introducing Instant Payment Notification (IPN)

Instant Payment Notification (IPN) is a message service that automatically notifies merchants of events related to PayPal transactions. Merchants can use it to automate back-office and administrative functions, including automatically fulfilling orders and providing customers with order status.

Why use Instant Payment Notification

Instant Payment Notification (IPN) notifies merchants almost instantly about transaction events, such as:

  • Payments received, including Express Checkout, and Adaptive Payments.
  • eCheck payments and related pending, completed, or denied status events.
  • Recurring payments and subscription actions.
  • Chargebacks, disputes, reversals, and refunds etc...
  • How it works

    Merchants create an Instant Payment Notification(IPN) listener page on their website and then specify the URL of the listener page in their PayPal account profile. PayPal then sends notifications of all transaction-related events to that URL. When customers pay for goods or services, PayPal sends a secure FORM POST containing payment information (IPN messages) to the URL. The Instant Payment Notification(IPN )listener detects and processes Instant Payment Notification(IPN) messages using the merchant backend processes. The Instant Payment Notification (IPN) listener page contains a custom script or program that waits for the messages, validates them with PayPal, and then passes them to various backend applications for processing.

    Referral to this link for paypal (IPN) Instant Payment Notification

    How to work ipn

    I will share with you integration of PayPal gateway payment without database in PHP. In this blog you will learn how to integrate Paypal payment gateway without database in Codeigniter. This blog will give you full example of the PayPal payment gateway integration in the PHP.

    In this example, I will show you easy and simple way to integrate paypal payment gateway in PHP . I will show you step by step to integrate paypal payment gateway in PHP as follow.

    Step 1:  Set link in paypal after IPN file is ready

    Web Development in Ilford, Essex-Kingsoftware.

    Step 2:  Create a Payment Form payment_form.php.


    <form id="contactform" action="payment_confirmation.php" method="post" class="validateform" name="send-contact" >
    <lablel>Email </lablel>
    <input type="text" name="email" id="email" data-rule="maxlen:4" data-msg="Please enter at least 4 chars" maxlength="100" class="form-control form-control-email">
    <lablel>Amount To Paid </lablel>
    <input type="text" name="amount" id="amount" data-rule="maxlen:2" data-msg="Please enter at least 2 length of Amount paid" maxlength="10" class="form-control form-control-name">
    <button class="theme-btn btn-style-one" type="submit" name="submit-form"><span class="txt">Submit now<span></button>

    Step 3:  : Take data from form to payment_confirmation.php page and store in to a Session. And Process data for Paypal.


    <lablel>Email </lablel>
    <?php if(isset($_POST['email'])){echo $_POST['email'];$_SESSION['email1'] = $_POST['email'];}?>>
    <lablel>Amount To Paid </lablel>
    <?php if(isset($_POST['amount'])){echo $_POST['amount'];$_SESSION['amt'] = $_POST['amount'];}?> >
    <form action="?php echo PAYPAL_URL; ?>" method="post" >
    <input type="hidden" name="item_name" value="<php echo $email ; ?>">
    < input type="hidden" name="amount" value="<php echo $amount; ?>">
    < input type="hidden" name="currency_code" value="GBP">
    < input type="hidden" name="txn_id" value="Transaction id">
    < input type="hidden" name="rm" value="2">
    < input type="hidden" name="cbt" value="Please Click Here to Complete Payment">
    < input type="hidden" name='cancel_return' value="?php echo cancel_return.php; ?>">
    < input type="hidden" name='return' value="?php echo success_return.php; ?>">
    < input type="hidden" name='notify_url' value="?php echo listener.php; ?>">
    <input type="image" class="imgbtn" name="submit" src="" alt="Check out with PayPal" />

    Step 4:  Create listener.php file and process data from paypal.


    <?php header('HTTP/1.1 200 OK');
    $resp = 'cmd=_notify-validate';
    foreach ($_POST as $parm => $var) {
    $var = urlencode(stripslashes($var));
    $resp .= "&$parm=$var";}
    $item_name = $_POST['item_name'];
    list( $email, $payment_amount) = explode(",", "$item_name");
    $todayis = date("l, F j, Y") ;
    $headers = "From: \r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $subject = "ABCD Payment confirmation";
    $message = "<img src='logo.jpg' >
    <hr width='50%' align='left'><h3>PAYMENT CONFIRMATION FROM ABCD/h3>
    width='50%' align='left'> Amount Paid: $payment_amountCustomer Email: $email
    $company_message = "<img src='logo.jpg' ><h3>ONLINE PAYMENT RECEIVED FROM $fname $lname</h3>
    Amount Paid: $payment_amount
    Customer Email: $email"; $to = $email; mail($to, $subject, $message, $headers);
    mail("", $subject, $company_message, $headers); ?>>

    Step 5:  Create a Success Page success_return.php where your payment success message and details will be display.

    < ?php //paypal data $paypalId = $_GET['tx'];
    $email = $_SESSION['email1'];
    $amt = $_SESSION['amt'];
    <?php if(isset($_SESSION['email1'])){echo $_SESSION['email1'];}?>
    <label>Amount To paid/label>
    <?php if(isset($_SESSION['amt'])){echo $_SESSION['amt'];}?>
    <label>Paypal Id/label>
    <?php echo $paypalId;?>
    <label>Payment Date/label>
    <?php echo date('Y-m-d');?>

    Paypal returns all transaction details in an array and verify all details and shoots the mail through IPN and this process will work in background.