• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

ZnoteAcc 1.5 Paypal Success But No Points Added

Thaian Citizen

Hexenjäger
Joined
Apr 5, 2013
Messages
144
Solutions
4
Reaction score
17
Location
germany
Hello,

I got everything to work except this one thing:

Steps that I did:
  1. Changed to my paypal email in config.php
  2. Enabled paypal in config.php
  3. Activated IPN in paypal and wrote https://myserv.no-ip.org/ipn.php
  4. sent myself cash, cash was received, page said Success
  5. Points are not added, the database doesnt contain the payment info
I think that it doesn't get to the VerifyPaypalIPN() in my ipn.php script,
OR that the function doesnt return the right $status value somehow.

ipn.php:
Code:
<?php

    // Require the functions to connect to database and fetch config values
    require 'config.php';
    require 'engine/database/connect.php';
  
    function VerifyPaypalIPN(array $IPN = null){
        if(empty($IPN)){
            $IPN = $_POST;
        }
        if(empty($IPN['verify_sign'])){
            return null;
        }
        $IPN['cmd'] = '_notify-validate';
        $PaypalHost = (empty($IPN['test_ipn']) ? 'www' : 'www.sandbox').'.paypal.com';
        $cURL = curl_init();
        curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($cURL, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($cURL, CURLOPT_URL, "https://{$PaypalHost}/cgi-bin/webscr");
        curl_setopt($cURL, CURLOPT_ENCODING, 'gzip');
        curl_setopt($cURL, CURLOPT_BINARYTRANSFER, true);
        curl_setopt($cURL, CURLOPT_POST, true); // POST back
        curl_setopt($cURL, CURLOPT_POSTFIELDS, $IPN); // the $IPN
        curl_setopt($cURL, CURLOPT_HEADER, false);
        curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($cURL, CURLOPT_FORBID_REUSE, true);
        curl_setopt($cURL, CURLOPT_FRESH_CONNECT, true);
        curl_setopt($cURL, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($cURL, CURLOPT_TIMEOUT, 60);
        curl_setopt($cURL, CURLINFO_HEADER_OUT, true);
        curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
            'Connection: close',
            'Expect: ',
        ));
        $Response = curl_exec($cURL);
        $Status = (int)curl_getinfo($cURL, CURLINFO_HTTP_CODE);
        curl_close($cURL);
        if(empty($Response) or !preg_match('~^(VERIFIED|INVALID)$~i', $Response = trim($Response)) or !$Status){
            return null;
        }
        if(intval($Status / 100) != 2){
            return false;
        }
        return !strcasecmp($Response, 'VERIFIED');
    }

    // Fetch paypal configurations
    $paypal = $config['paypal'];
    $prices = $config['paypal_prices'];
  
    // Send an empty HTTP 200 OK response to acknowledge receipt of the notification
    header('HTTP/1.1 200 OK');

    // Build the required acknowledgement message out of the notification just received
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req  .= "&$key=$value";
    }
    $postdata = $req;
  
    // Assign payment notification values to local variables
    $item_name        = $_POST['item_name'];
    $item_number      = $_POST['item_number'];
    $payment_status   = $_POST['payment_status'];
    $payment_amount   = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id           = $_POST['txn_id'];
    $receiver_email   = $_POST['receiver_email'];
    $payer_email      = $_POST['payer_email'];
    $custom           = (int)$_POST['custom'];

    $connectedIp = $_SERVER['REMOTE_ADDR'];
    mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'Connection from IP: $connectedIp', '0', '0', '0')");
  
    $status = VerifyPaypalIPN();
    if ($status) {
        // Check that the payment_status is Completed
        if ($payment_status == 'Completed') {
            // Check that txn_id has not been previously processed
            $txn_id_check = mysql_select_single("SELECT `txn_id` FROM `znote_paypal` WHERE `txn_id`='$txn_id'");
            if ($txn_id_check !== false) {
                // Check that receiver_email is your Primary PayPal email
                if ($receiver_email == $paypal['email']) {                  
                  
                    $status = true;
                    $paidMoney = 0;
                    $paidPoints = 0;

                    foreach ($prices as $priceValue => $pointsValue) {
                        if ($priceValue == $payment_amount) {
                            $paidMoney = $priceValue;
                            $paidPoints = $pointsValue;
                        }
                    }

                    if ($paidMoney == 0) $status = false; // Wrong ammount of money
                    if ($payment_currency != $paypal['currency']) $status = false; // Wrong currency
                  
                    // Verify that the user havent messed around with POST data
                    if ($status) {
                        if (blacklist_email($_POST['payer_email']) === true)
                        {
                            mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'BLACKLISTED, $payer_email', '$custom', '".$paidMoney."', '".$paidPoints."')");
                        }
                      
                        // transaction log
                        mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', '$payer_email', '$custom', '".$paidMoney."', '".$paidPoints."')");
                      
                        // Process payment
                        $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='$custom';");

                        // Give points to user
                        $new_points = $data['old_points'] + $paidPoints;
                        mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$custom'");
                        mysql_update("UPDATE `znote_accounts` SET `lastpurchase`='".time()."' WHERE `account_id`='$custom'");
                    }
                }  else {
                    $pmail = $paypal['email'];
                    mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'ERROR: Wrong mail. Received: $receiver_email, configured: $pmail', '0', '0', '0')");
                }
            }
        }
        elseif ($payment_status == 'Reversed') {
            // Check that txn_id has not been previously processed
            $txn_id_check = mysql_select_single("SELECT `txn_id` FROM `znote_paypal` WHERE `txn_id`='$txn_id'");
            if ($txn_id_check !== false) {
                mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'CHARGEBACK, $payer_email', '$custom', '".(-1 * $paidMoney)."', '0')");
            }
        }
    } else {
        // Something is wrong
        mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'ERROR: Invalid data. $postdata', '0', '0', '0')");
    }
?>

image of the database entries:
3xk9hmon.png
 
Ipn won't add points with the development site from paypal here, i donated myself 1 eur and it added, it's working here.
 
And Check Ipn History And Make turn On Ipn
IPN in paypal is activated and it goes to my right address -> http://servername.no-ip.org/ipn.php

But my ipn history, which I now searched, shows this:
qj49mtqw.png

Neuer Versuch... that means New try... or Retry...

What is going wrong? I don't understand where the misstake happens so I can't correct it :/
 
Weird thing is that my ZnoteAAC IPN works.

Hast du schon unter deinen Verkäufereinstellungen die Benachrichtigungen über Soforotzahlungen aktiviert / konfiguriert? Bei mir lag das "Problem" dort.

Die Benachrichtigungs-URL muss wieder auf dein ipn.php geleitet werden. z.B. http://thaian.citiz.en/ipn.php

Nachrichtenzustellungen müssen aktiv sein.

Gruß
Okke.

Edit: once this all is done, try donating yourself 1 euro. (set config a for a 1€ amount to get a few points and just do it or ask someone else to do it for you).
Use only english in support section.
 
Okke, that is all set, doesnt work... Tried several times... :/

Why do you give him a "solution" that won't work?


OnT
Do you use latest ZnoteAAC from github?

I can take a look through teamviewer when I get home from work if you want.

I use the one that was available with OTHIRE to work with that distro...
The way I see it is that the only thing that could make this not work is if that is an outdated ipn.php / buypoints.php script
But from what I see the actual ipn.php at znote github only differs a little from mine
It has:
Code:
    // Fetch and sanitize POST and GET values
    function getValue($value) {
        return (!empty($value)) ? sanitize($value) : false;
    }
    function sanitize($data) {
        return htmlentities(strip_tags(mysql_znote_escape_string($data)));
    }

And uses these here:
Code:
    $txn_id           = getValue($_POST['txn_id']);
    $receiver_email   = getValue($_POST['receiver_email']);
    $payer_email      = getValue($_POST['payer_email']);
Where I have:
Code:
    $txn_id           = $_POST['txn_id'];
    $receiver_email   = $_POST['receiver_email'];
    $payer_email      = $_POST['payer_email'];

Could that be a reason?
 
You could change one thing in your script, just to see what the response message from paypal is:
Since it inserts the "connection from ip...." you can change it from:
PHP:
mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', 'Connection from IP: $connectedIp', '0', '0', '0')");
and use this instead to see what the response message is:
PHP:
mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', '$Response', '0', '0', '0')");
 
.....[/PHP]
and use this instead to see what the response message is:
PHP:
mysql_insert("INSERT INTO `znote_paypal` VALUES ('', '$txn_id', '$Response', '0', '0', '0')");

I added that it inserts a VERIFIED into my db

I looked for further things, in paypal, under my IPN history, I could find the ipn message that paypal sends, maybe you could see something here that I missed
Code:
transaction_subject=
&payment_date=11:49:48 Mar 21, 2016 PDT
&txn_type=web_accept
&last_name=Stake
&residence_country=DE
&item_name=10 shop points on Aceron Online
&payment_gross=
&mc_currency=EUR
&[email protected]
&payment_type=instant
&protection_eligibility=Ineligible
&verify_sign=AAJvKFvZz8HjfhMvKW1wivP4D-MRAx7qF2KJP80FDLyduUzpkXwq5aZj
&payer_status=verified
&tax=0.00
&[email protected]
&txn_id=5FG828958P699415E
&quantity=1
&[email protected]
&first_name=Hans
&payer_id=5HNCSSR7ABQJW
&receiver_id=HUW9ZQMGYUS2L
&item_number=1
&handling_amount=0.00
&payment_status=Completed
&payment_fee=
&mc_fee=0.37
&shipping=0.00
&mc_gross=1.00
&custom=245678
&charset=windows-1252
&notify_version=3.8
&ipn_track_id=ee6205e47bf33
 
Is this the latest version? If not try with a newer version. Also, I know I've seen a version of this that prints everything for debugging. Look on znote github.
 
Well, as I posted before, the version on github only has one difference in ipn.php, this:

....
But from what I see the actual ipn.php at znote github only differs a little from mine
It has:
Code:
    // Fetch and sanitize POST and GET values
    function getValue($value) {
        return (!empty($value)) ? sanitize($value) : false;
    }
    function sanitize($data) {
        return htmlentities(strip_tags(mysql_znote_escape_string($data)));
    }

And uses these here:
Code:
    $txn_id           = getValue($_POST['txn_id']);
    $receiver_email   = getValue($_POST['receiver_email']);
    $payer_email      = getValue($_POST['payer_email']);
Where I have:
Code:
    $txn_id           = $_POST['txn_id'];
    $receiver_email   = $_POST['receiver_email'];
    $payer_email      = $_POST['payer_email'];

Could that be a reason?
 
Back
Top