donglei7152 2012-09-11 14:18
浏览 72
已采纳

Paypal - 保护未加密的按钮

I implemented a dynamic button "buy now" (not saved in my PayPal account) with IPN and it works fine (yeah!).

Now I have a doubt about his security, because if someone change with firebug (for example) the amount value, the transaction is valid for paypal also if my IPN listener says there is a problem with amount.

My question is "Can I encrypt the form with a php / codeigniter library?"

Because I tried to check amount in the IPN listener, but the transaction on paypal continue correctly and It isn't blocked from IPN.

Here, you find a part of my listener code:

private function isVerifiedIPN(){

    $req = 'cmd=_notify-validate';
    $posts = $this->input->post();
    foreach ($posts as $key => $value){
        $value = urlencode(stripslashes($value));
        $req .= "&$key=$value";
    }

    if($this->config->item('SIMULATION'))
        $url = $this->config->item('SIMULATION_URL');
    else
        $url = $this->config->item('PRODUCTION_URL');


    if(!$this->isVerifiedAmmount() ||
    !$this->isPrimaryPayPalEmail() ||
    !$this->isNotProcessed()){
        $req = '';
    }

    $header = "POST /cgi-bin/webscr HTTP/1.0
";
    $header .= "Host: $url
"; //443
    $header .= "Content-type: application/x-www-form-urlencoded
";
    $header .= "Content-length: " . strlen($req) . "

";

    $fp = fsockopen ("ssl://$url", 443, $errno, $errstr, 30);

    if (!$fp)
    {
        $this->sendReport("Errore connessione socket");
        return FALSE;
    }
    else
    {
        fputs ($fp, $header . $req);
        while (!feof($fp))
        {
            $res = fgets ($fp, 1024);
            if (strcmp($res, "VERIFIED") == 0)
            {
                // transizione valida
                fclose ($fp);
                return TRUE;
            }
            else if (strcmp ($res, "INVALID") == 0)
            {
                $this->sendReport('Transizione non valida');
                fclose ($fp);
                return FALSE;
            }
        }
    }

}
  • 写回答

2条回答 默认 最新

  • douya2433 2012-09-11 14:43
    关注

    You can dynamically encrypt buttons so that people with Firebug (or similar software) can't edit them. The PayPal API library has an example of this you can use, but I can't find it again right now.

    This PayPal help file explains how to get the various keys you need using your server command line.

    I also found a tutorial and a certificate builder (I didn't use, so can't confirm how secure it is...)

    Once you've generated your key and certificate, you need to put them on your server and set DEFAULT_EWP_PRIVATE_KEY_PATH and DEFAULT_EWP_CERT_PATH to the relevant files.

    Upload the public certificate to PayPal (instructions in linked tutorials), and set DEFAULT_CERT_ID to the Cert ID it gives you for that file. It'll also give you a file you can download - add that to your server and set PAYPAL_CERT_PATH to the path for that file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败