<?php
   // 公共函数定义
   function StrToHex($string)
   {
      $hex="";
      for ($i=0;$i<strlen($string);$i++)
          $hex.=dechex(ord($string[$i]));
      $hex=strtoupper($hex);
      return $hex;
   }
	
	// 接收订单提交信息
	$m_id       = 	$this->merid;
	$m_orderid  = 	$this->orderid;
	$m_oamount  = 	$this->amount;
	$m_ocurrency= 	"1";
	$m_url      = 	$this -> url = $SiteUrl."memberfunc_payresult.php";
	//$m_txcode   = 	"001";
	$m_language = 	"1";
	$s_name     = 	$this->rname;
	$s_addr     = 	"暂无";
	$s_postcode = 	"0000000";
	$s_tel      = 	"00000000";
	$s_eml      = 	$this->remail;
	$r_name     = 	$this->rname;
	$r_addr     = 	"暂无";
	$r_postcode = 	"000000";
	$r_tel      = 	"0000000";
	$r_eml      = 	$this->remail;
	$m_ocomment = 	"暂无备注";
	$modate		=	date("Y-m-d");
	$m_status	= 	0;
	
    //组织订单信息
	$m_info = $m_id."|".$m_orderid."|".$m_oamount."|".$m_ocurrency."|".$m_url."|".$m_language;
	$s_info = $s_name."|".$s_addr."|".$s_postcode."|".$s_tel."|".$s_eml;
	$r_info = $r_name."|".$r_addr."|".$r_postcode."|".$r_tel."|".$r_eml."|".$m_ocomment."|".$m_status."|".$modate;

	$OrderInfo = $m_info."|".$s_info."|".$r_info;
	//echo $OrderInfo;
	
	//订单信息先转换成HEX，然后再加密
	$key = $this->ikey;

	$OrderInfo = StrToHex($OrderInfo);
	$digest = strtoupper(md5($OrderInfo.$key));

    //nps https://payment.nps.cn/PHPReceiveMerchantAction.do
    $hiddenString = "<Input Type=hidden Name=\"OrderMessage\" id=OrderMessage value=\"".$OrderInfo."\">";
    $hiddenString.= "<Input Type=hidden Name=\"digest\" id=digest value=\"".$digest."\">";
	$hiddenString.= "<Input Type=hidden Name=\"M_ID\" id=M_ID value=\"".$m_id."\">";
	$this->action = "https://payment.nps.cn/PHPReceiveMerchantAction.do";
	$hiddenString = "<form Name=\"FORM\" target=_blank method=post action=".$this->action.">".$hiddenString."<input  type=submit value='立即通过".$this->pcenter."在线支付' name=submit></form>";
?>