0

I have created my payza IPN handler but I am not getting any messages or any changes into my db, and its even not redirecting me to my site.

I have setup my IPN in my payza account to V2 and also enable EPD but that's also not sending any response.

this is my ipn handler sample

<?php
/**
 * 
 * Sample IPN V2 Handler for Item Payments
 * 
 * The purpose of this code is to help you to understand how to process the Instant Payment Notification 
 * variables for a payment received through Payza's buttons and integrate it in your PHP site. The following
 * code will ONLY handle ITEM payments. For handling IPNs for SUBSCRIPTIONS, please refer to the appropriate
 * sample code file.
 *  
 * Put this code into the page which you have specified as Alert URL.
 * The conditional blocks provide you the logical placeholders to process the IPN variables. It is your responsibility
 * to write appropriate code as per your requirements.
 *  
 * If you have any questions about this script or any suggestions, please visit us at: dev.payza.com
 * 
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY
 * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 * LIMITED TO THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE.
 * 
 * @author Payza
 * @copyright 2011
 */

    //The value is the url address of IPN V2 handler and the identifier of the token string 
    define("IPN_V2_HANDLER", "https://secure.payza.com/ipn2.ashx");
    define("TOKEN_IDENTIFIER", "token=");

    // get the token from Payza
    $token = urlencode($_POST['token']);

    //preappend the identifier string "token=" 
    $token = TOKEN_IDENTIFIER.$token;

    /**
     * 
     * Sends the URL encoded TOKEN string to the Payza's IPN handler
     * using cURL and retrieves the response.
     * 
     * variable $response holds the response string from the Payza's IPN V2.
     */

    $response = '';

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, IPN_V2_HANDLER);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $token);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $response = curl_exec($ch);

    curl_close($ch);

    if(strlen($response) > 0)
    {
        if(urldecode($response) == "INVALID TOKEN")
        {
            //the token is not valid
        }
        else
        {
            //urldecode the received response from Payza's IPN V2
            $response = urldecode($response);

            //split the response string by the delimeter "&"
            $aps = explode("&", $response);

            //create a file to save the response information from Payza's IPN V2    
            $myFile = "IPNRes.txt";
            $fh = fopen($myFile,'a') or die("can't open the file");

            //define an array to put the IPN information
            $info = array();

            foreach ($aps as $ap)
            {
                //put the IPN information into an associative array $info
                $ele = explode("=", $ap);
                $info[$ele[0]] = $ele[1];

                //write the information to the file IPNRes.txt
                fwrite($fh, "$ele[0] \t");
                fwrite($fh, "=\t");
                fwrite($fh, "$ele[1]\r\n");
            }

            fclose($fh);

            //setting information about the transaction from the IPN information array
            $receivedMerchantEmailAddress = $info['ap_merchant'];
            $transactionStatus = $info['ap_status'];
            $testModeStatus = $info['ap_test'];
            $purchaseType = $info['ap_purchasetype'];
            $totalAmountReceived = $info['ap_totalamount'];
            $feeAmount = $info['ap_feeamount'];
            $netAmount = $info['ap_netamount'];
            $transactionReferenceNumber = $info['ap_referencenumber'];
            $currency = $info['ap_currency'];
            $transactionDate = $info['ap_transactiondate'];
            $transactionType = $info['ap_transactiontype'];

            //setting the customer's information from the IPN information array
            $customerFirstName = $info['ap_custfirstname'];
            $customerLastName = $info['ap_custlastname'];
            $customerAddress = $info['ap_custaddress'];
            $customerCity = $info['ap_custcity'];
            $customerState = $info['ap_custstate'];
            $customerCountry = $info['ap_custcountry'];
            $customerZipCode = $info['ap_custzip'];
            $customerEmailAddress = $info['ap_custemailaddress'];

            //setting information about the purchased item from the IPN information array
            $myItemName = $info['ap_itemname'];
            $myItemCode = $info['ap_itemcode'];
            $myItemDescription = $info['ap_description'];
            $myItemQuantity = $info['ap_quantity'];
            $myItemAmount = $info['ap_amount'];

            //setting extra information about the purchased item from the IPN information array
            $additionalCharges = $info['ap_additionalcharges'];
            $shippingCharges = $info['ap_shippingcharges'];
            $taxAmount = $info['ap_taxamount'];
            $discountAmount = $info['ap_discountamount'];

            //setting your customs fields received from the IPN information array
            $myCustomField_1 = $info['apc_1'];
            $myCustomField_2 = $info['apc_2'];
            $myCustomField_3 = $info['apc_3'];
            $myCustomField_4 = $info['apc_4'];
            $myCustomField_5 = $info['apc_5'];
            $myCustomField_6 = $info['apc_6'];

            mysqli_query($con, "UPDATE domains SET status='Active' WHERE id=$myCustomField_1");
        }
    }
    else
    {
        //something is wrong, no response is received from Payza
    }

?>

I also tried it on sandbox but that is also not sending any ipn response but that works with EPD.

I also defined my return url in my buy button form and alert url too.

and alert url is also setup in my payza account ipn setup.

so please tell me whats the wrong ??

any help would be appreciated.

3
Contributors
5
Replies
118
Views
3 Years
Discussion Span
Last Post by veedeoo
0

try var_dumping the response from payza. In this case it should be the $info. Also, try var_dumping the $response just below the cURL's curl_close() call.

Edited by veedeoo: more info added

0

how can I know any reponses from payza? even after payment from payza it doesn't redirect to my site, and return url is different from alert_url.

in their codex page said that the return_url should not the same as alert_url.
the return_url is where user is redirect to merchants site after payment.
and alert_url is where payza send IPN info.

so I cant see any response on my return url. so how can I know whats the problem?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.