首页 > 解决方案 > 为什么我的支付墙 pingback 没有更新数据库,并且我在 pingback 测试中收到错误?

问题描述

我试图找出我用于 Paymentwall 系统的 pingback.php 代码有什么问题,但我无法弄清楚。我根本不是 php 专家,我正在寻求帮助。

pingback 测试的错误:

签名基串uid=1currency=1type=0ref=99917bc736b9199ed98e8548d787cd57f5c7

签名 = MD5(签名基本字符串) 3c97f449ef1456685f21bad0863a4196

要求

GET http://MYWANIP:80/paymentwall_process.php?uid=1¤cy=1&type=0&ref=9991&is_test=1&sig=3c97f449ef1456685f21bad0863a4196 HTTP/1.1 Host: 95.143.228.254 Accept: / Proxy-Connection: Keep-Alive Connection: close Accept-encoding : gzip, deflate User-Agent: Paymentwall API

回复

HTTP/1.1 200 OK 日期:2018 年 12 月 22 日星期六 20:48:30 GMT 服务器:Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/ v5.10.1 X-powered-by: PHP/5.3.8 Content-length: 8 Content-type: text/html X-cache-lookup: MISS from proxy6.paymentwall.com:3128 Connection: keep-alive

错误

我的 Pingback.php 文件

<?php
    // CONFIG
    $mssql_host = '127.0.0.1';
    $mssql_user = 'sa';
    $mssql_pw = 'MYPASS';
    $mssql_db = 'MyDB';

    $secret_key = 'MYSECRETKEY';
    $app_key = 'MYAPPKEY';


    // DO NOT EDIT BELOW THIS LINE
    $link = mssql_connect($mssql_host, $mssql_user, $mssql_pw);
    $db = mssql_select_db($mssql_db);

    if (!$link) {
        die('Something went wrong while connecting to MSSQL');
    }

    if (!$db) {
        die('Something went wrong while connecting to MSSQL');
    }

    $userId = isset($_GET['uid']) ? $_GET['uid'] : null;
    $credits = isset($_GET['currency']) ? $_GET['currency'] : null;
    $type = isset($_GET['type']) ? $_GET['type'] : null;
    $refId = isset($_GET['ref']) ? $_GET['ref'] : null;
    $signature = isset($_GET['sig']) ? $_GET['sig'] : null;
    $result = false;

    function SignatureGenerator($params, $secret) {
        $str = '';
        foreach ($params as $k=>$v) {
                $str .= "$k=$v";
        }
        $str .= $secret;
        return md5($str);
    }

    if (!empty($userId) && !empty($credits) && isset($type) && !empty($refId) && !empty($signature)) {

        $signatureParams = array('uid' => $userId, 'currency' => $credits, 'type' => $type, 'ref' => $refId);
        $signatureCalculated = SignatureGenerator($signatureParams, $secret_key);
        $query = mssql_query("SELECT memb___id FROM MEMB_CREDITS WHERE memb___id = '$userId'");
        $check  = mssql_fetch_row($query);

        // check if account is exists
        if($check[0])   
        {
            // check if IP is in whitelist and if signature matches
            if (in_array($_SERVER['REMOTE_ADDR'], array('174.36.92.186', '174.36.96.66', '174.36.92.187', '174.36.92.192', '174.37.14.28')) && ($signature == $signatureCalculated)) {
                $result = true;     
                if ($type == 2) {
                    // Deduct credits from user
                    mssql_query("INSERT INTO Donate (memb___id, currency, type, date) VALUES ('".$userId."', '".$credits."', 'Chargeback', '".date("d-m-Y H:i:s")."')");
                    mssql_query("UPDATE MEMB_CREDITS SET credits = credits - ".$credits." WHERE memb___id = '".$userId."'");                
                    echo 'OK';
                }
                elseif ($type == 0 || $type == 1) {
                    // Give credits to user
                    mssql_query("INSERT INTO Donate (memb___id, currency, type, date) VALUES ('".$userId."', '".$credits."', 'Payment', '".date("d-m-Y H:i:s")."')");
                    mssql_query("UPDATE MEMB_CREDITS SET credits = credits + ".$credits." WHERE memb___id = '".$userId."'");
                    echo 'OK';
                }
            }
        }
        else
        {
            $result = false;
            echo 'ERROR';
        }
    }

?>

为什么我的支付墙 pingback 没有更新数据库,并且我在 pingback 测试中收到错误?

标签: phpsql-server

解决方案


哦,我可以处理一些这样的脚本并修改它,但我不知道这个脚本看起来是否正常...... memb__id 它是 USERNAME 而 memb_guid 它是不能重复的帐户 ID(主号码)它是唯一的东西在那个数据库上,据我从其他研究中了解到,这可能是一个问题,因为 paymentwall 不接受字母作为唯一的 UID 数字,这是一个我不确定的理论,这是我的问题,使脚本在 memb_guid 下工作而不是 memb___id。在 MEMB_CREDITS 表中,我只有 2 列(memb___id 和 credits),memb___id 是用户名,而 memb_guid 可以在 MEMB_INFO 表中找到,它是该帐户的 ID。我希望你能理解我在这里想要做什么。


推荐阅读