php - Bank QR code payment access problem
世界只因有你
世界只因有你 2017-05-16 13:02:18
0
1
891

Recently I am working on the bank’s QR code payment access. After getting the document, there are a few things I don’t understand very well.
1. Downloaded the private key (.sm2) and public key (.cer) of the signed certificate and imported the public key directly. I don’t know how to use the private key certificate
2. Since I am using the PHP demo, PHP The code calls LAJP to call the JAVA environment for signing. The data obtained after signing in the php demo cannot pass the test signature verification. I don’t know which step is wrong
Attached is the test demo on the web page: http://wxpay.cmbc.com.cn/cmbc...< br>Provided local signature function:
<?php

require_once("php_java.php");//Quoting the PHP script provided by LAJP
   try
    {
       $signAlg = $_REQUEST['signAlg'];
       $base64SourceData = $_REQUEST['base64SourceData'];
       $base64P12Data = $_REQUEST['base64P12Data'];
       $p12Password = $_REQUEST['p12Password'];
       $ret = lajp_call("cfca.sadk.api.SignatureKit::P1SignMessage", $signAlg,$base64SourceData, $base64P12Data,$p12Password);
       echo "{$ret}<br>";
    }
catch(Exception $e)
{
  echo "Err:{$e}<br>";
}
?><a href="index.html">return</a>
世界只因有你
世界只因有你

reply all(1)
黄舟
一、第一个问题,带证书,应该使用curl
 /**
     *     作用:使用证书,以post方式提交xml到对应的接口url
     */
    function postXmlSSLCurl($xml, $url, $second = 30, $wxpay_config) {
            $ch = curl_init();
            //超时时间
            curl_setopt($ch, CURLOPT_TIMEOUT, $second);
            //这里设置代理,如果有的话
            
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            //设置header
            curl_setopt($ch, CURLOPT_HEADER, FALSE);
            //要求结果为字符串且输出到屏幕上
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            //设置证书
            //使用证书:cert 与 key 分别属于两个.pem文件
            //默认格式为PEM,可以注释
            curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
            curl_setopt($ch, CURLOPT_SSLCERT, $wxpay_config['SSLCERT_PATH']);
            //默认格式为PEM,可以注释
            curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM');
            curl_setopt($ch, CURLOPT_SSLKEY, $wxpay_config['SSLKEY_PATH']);
            //post提交方式
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
            $data = curl_exec($ch);
            //返回结果
            if ($data) {
                curl_close($ch);
                return $data;
            } else {
                $error = curl_errno($ch);
                echo "curl出错,错误码:$error" . "<br>";
                // echo "<a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>错误原因查询</a></br>";
                curl_close($ch);
                return false;
            }
    }

二、签名的话
你试着用PHP同样的参数自己生产签名跟java环境比对看看。一般来说应该是不能共用的吧。之前遇到过app里面的微信支付通过php生成的签名给过来app用,这个之前好像是行不通的。
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template