<?php

include "inc.php";
require_once SYS_ROOT.'/cls_tab/tab.pay.type.php';
$obj_tab_type=new cls_tab_pay_type;
$base_dir=$obj_tab_type->api_dir;

$arr_config=$obj_tab_type->get_type_fields("chinabank");

$merchant_key=$arr_config["key"];

$v_oid =trim($_REQUEST['v_oid']);    ///获取订单编号
$v_pstatus = trim($_REQUEST['v_pstatus']);   ///支付状态 20:成功 30:失败
$v_pstring = trim($_REQUEST['v_pstring']); ///
$v_pmode = trim($_REQUEST['v_pmode']);   ///支付银行，如工商银行
$v_md5str = trim($_REQUEST['v_md5str']); ///md5 值 
$v_amount = trim($_REQUEST['v_amount']);   ///订单金额
$v_moneytype = trim($_REQUEST['v_moneytype']);   ///币种
$remark1 = trim($_REQUEST['remark1']);   ///备注1
$remark2 = trim($_REQUEST['remark2']);   ///备注2 


///生成加密串,注意顺序
   $ScrtStr = $v_oid.$v_pstatus.$v_amount.$v_moneytype.$merchant_key; 
   $mymac = md5($ScrtStr); 

if(strtoupper($v_md5str)==strtoupper($mymac)){
    if((int)$v_pstatus==20){   ///支付成功
     /*
     #商户网站逻辑处理#
     */
		$arr_pay_return=array(
			"number"=>$v_oid,
			"pay_money"=>$v_amount
		);
		$obj_tab_type->on_pay_ok($arr_pay_return);
		$show = $obj_tab_type->pay_ok_url;
		go_url($show);
    }else{   ///支付失败 
		echo "<br/>" . "支付失败" . "<br/>";
		set_log("chinabank","支付失败",array(),true);
    }

} else {
    //验证失败
	echo "<br/>" . "认证签名失败" . "<br/>";
	set_log("chinabank","fail",array(),true);
}
?>