PHP代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Yb extends CI_Controller {
//	public function __construct(){
//		parent::__construct();
//		$this->load->model('mfun');
//	}
	
	function index(){
		$this->load->view('ybindex');
	}
	
	function queren(){
		$data['p0_Cmd'] = "Buy";
		$data['p1_MerId'] = "10001126856";
		$data['p2_Order'] = $_POST['p2_Order'];
		$data['p3_Amt'] = $_POST['p3_Amt'];
		$data['p4_Cur'] = "CNY";
		$data['p5_Pid'] = "";
		$data['p6_Pcat'] = "";
		$data['p7_Pdesc'] = "";
		$data['p8_Url'] = "http://xxx.com/yb/chenggong";
		$data['p9_SAF'] = "0";
		$data['pa_MP'] = "";
		$data['pd_FrpId'] = $_POST['pd_FrpId'];
		$data['pr_NeedResponse'] = "1";
		
		
		
		$str = "";
		$str .= $data['p0_Cmd'];
		$str .= $data['p1_MerId'];
		$str .= $data['p2_Order'];
		$str .= $data['p3_Amt'];
		$str .= $data['p4_Cur'];
		$str .= $data['p5_Pid'];
		$str .= $data['p6_Pcat'];
		$str .= $data['p7_Pdesc'];
		$str .= $data['p8_Url'];
		$str .= $data['p9_SAF'];
		$str .= $data['pa_MP'];
		$str .= $data['pd_FrpId'];
		$str .= $data['pr_NeedResponse'];
		
		$key = "69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl";
		
		$data['hmac'] = $this->HmacMd5($str,$key);
		$this->load->view('ybqueren',$data);
	}
	
	function chenggong(){
		$data['p1_MerId'] = "10001126856";
		$data['r0_Cmd'] = $_REQUEST['r0_Cmd'];
		$data['r1_Code'] = $_REQUEST['r1_Code'];
		$data['r2_TrxId'] = $_REQUEST['r2_TrxId'];
		$data['r3_Amt'] = $_REQUEST['r3_Amt'];
		$data['r4_Cur'] = $_REQUEST['r4_Cur'];
		$data['r5_Pid'] = $_REQUEST['r5_Pid'];
		$data['r6_Order'] = $_REQUEST['r6_Order'];
		$data['r7_Uid'] = $_REQUEST['r7_Uid'];
		$data['r8_MP'] = $_REQUEST['r8_MP'];
		$data['r9_BType'] = $_REQUEST['r9_BType'];
		$data['hmac'] = $_REQUEST['hmac'];
		
		//不参与hmac
		$data['rb_BankId'] = $_REQUEST['rb_BankId'];
		$data['rp_PayDate'] = $_REQUEST['rp_PayDate'];
		$data['rq_CardNo'] = $_REQUEST['rq_CardNo'];
		$data['ru_Trxtime'] = $_REQUEST['ru_Trxtime'];
		
		$str="";
		$str .= $data['p1_MerId'];
		$str .= $data['r0_Cmd'];
		$str .= $data['r1_Code'];
		$str .= $data['r2_TrxId'];
		$str .= $data['r3_Amt'];
		$str .= $data['r4_Cur'];
		$str .= $data['r5_Pid'];
		$str .= $data['r6_Order'];
		$str .= $data['r7_Uid'];
		$str .= $data['r8_MP'];
		$str .= $data['r9_BType'];
		$key = "69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl";
		$hmac = $this->HmacMd5($str,$key);
		if($data['hmac'] == $hmac){
			if($data['r1_Code'] == 1){
				if($data['r9_BType'] == 1){
					echo "交易成功!"."
";
					echo "点单编号:".$data['r6_Order']."
";
					echo "所付金额:".$data['r3_Amt']."
";
					echo "易宝支付订单号:".$data['r2_TrxId']."
";
					echo "浏览器重定向"."
";
				}elseif($data['r9_BType'] == 2){
					echo "success";
					echo "交易成功!"."
";
					echo "点单编号:".$data['r6_Order']."
";
					echo "所付金额:".$data['r3_Amt']."
";
					echo "易宝支付订单号:".$data['r2_TrxId']."
";
					echo "服务器点对点通讯"."
";
				}
				
			}else{
				echo "交易失败";
			}
		}else{
			echo "签名被篡改";
		}
		
		
		
	}
	
	function HmacMd5($data,$key){
		// RFC 2104 HMAC implementation for php.
		// Creates an md5 HMAC.
		// Eliminates the need to install mhash to compute a HMAC
		// Hacked by Lance Rushing(NOTE: Hacked means written)
		
		//需要配置环境支持iconv,否则中文参数不能正常处理
		$key = iconv("GB2312","UTF-8",$key);
		$data = iconv("GB2312","UTF-8",$data);
		
		$b = 64; // byte length for md5
		if (strlen($key) > $b) {
		$key = pack("H*",md5($key));
		}
		$key = str_pad($key, $b, chr(0x00));
		$ipad = str_pad('', $b, chr(0x36));
		$opad = str_pad('', $b, chr(0x5c));
		$k_ipad = $key ^ $ipad ;
		$k_opad = $key ^ $opad;
		
		return md5($k_opad . pack("H*",md5($k_ipad . $data)));
	}
}

 

 

 

提交代码

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>易宝测试</title>

</head>

<body>

<form action="/yb/queren/" method="post" name="form" id="form">

<table>

<tr>

<td colspan="4">

订单编号:<input type="text" name="p2_Order" />

支付金额:<input type="text" name="p3_Amt" />

</td>

</tr>

<tr><td colspan="4">请选择网站支付银行</td></tr>

<tr>

<td>

<input type="radio" name="pd_FrpId" value="ICBC-NET" />工商银行

<input type="radio" name="pd_FrpId" value="CMBCHINA-NET" />招商银行

<input type="radio" name="pd_FrpId" value="ABC-NET" />农业银行

<input type="radio" name="pd_FrpId" value="CCB-NET" />建设银行

</td>

</tr>

<tr><td colspan="4"><input type="submit" value="确认" /></td></tr>

</table>

</form>

</body>

</html>

 

 

确认代码

 

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>易宝测试</title>

</head>

<body>

<form action="https://www.yeepay.com/app-merchant-proxy/node" method="post" name="form" id="form">

<table>

<tr>

<td colspan="4">

你的订单编号是:<?php echo $p2_Order;  ?>

支付金额是:<?php echo $p3_Amt;  ?>

</td>

</tr>

<tr>

<td>

<input type="hidden" name="p0_Cmd" value="<?php echo $p0_Cmd;?>" />

<input type="hidden" name="p1_MerId" value="<?php echo $p1_MerId;?>" />

<input type="hidden" name="p2_Order" value="<?php echo $p2_Order;?>" />

<input type="hidden" name="p3_Amt" value="<?php echo $p3_Amt;?>" />

<input type="hidden" name="p4_Cur" value="<?php echo $p4_Cur;?>" />

<input type="hidden" name="p5_Pid" value="<?php echo $p5_Pid;?>" />

<input type="hidden" name="p6_Pcat" value="<?php echo $p6_Pcat;?>" />

<input type="hidden" name="p7_Pdesc" value="<?php echo $p7_Pdesc;?>" />

<input type="hidden" name="p8_Url" value="<?php echo $p8_Url;?>" />

<input type="hidden" name="p9_SAF" value="<?php echo $p9_SAF;?>" />

<input type="hidden" name="pa_MP" value="<?php echo $pa_MP;?>" />

<input type="hidden" name="pd_FrpId" value="<?php echo $pd_FrpId;?>" />

<input type="hidden" name="pr_NeedResponse" value="<?php echo $pr_NeedResponse;?>" />

<input type="hidden" name="hmac" value="<?php echo $hmac;?>" />

</td>

</tr>

<tr><td colspan="4"><input type="submit" value="确认" /></td></tr>

</table>

</form>

</body>

</html>


声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

附件下载:
相关代码.zip 2.59KB

et_highlighter