Пример #1
0
$reqHandler->setParameter("out_refund_no", "2011032400002");
$reqHandler->setParameter("total_fee", "2");
$reqHandler->setParameter("refund_fee", "1");
$reqHandler->setParameter("op_user_id", "1900000109");
//操作员密码,MD5处理
$reqHandler->setParameter("op_user_passwd", md5("111111"));
//接口版本号,取值1.1
$reqHandler->setParameter("service_version", "1.1");
//-----------------------------
//设置通信参数
//-----------------------------
//设置PEM证书,pfx证书转pem方法:openssl pkcs12 -in 2000000501.pfx  -out 2000000501.pem
//证书必须放在用户下载不到的目录,避免证书被盗取
$httpClient->setCertInfo("C:\\key\\1900000109.pem", "1900000109");
//设置CA
$httpClient->setCaInfo("C:\\key\\cacert.pem");
$httpClient->setTimeOut(5);
//设置请求内容
$httpClient->setReqContent($reqHandler->getRequestURL());
//后台调用
if ($httpClient->call()) {
    //设置结果参数
    $resHandler->setContent($httpClient->getResContent());
    $resHandler->setKey($key);
    //判断签名及结果
    //只有签名正确并且retcode为0才是请求成功
    if ($resHandler->isTenpaySign() && $resHandler->getParameter("retcode") == "0") {
        //取结果参数做业务处理
        //商户订单号
        $out_trade_no = $resHandler->getParameter("out_trade_no");
        //财付通订单号