send.php

<?php
date_default_timezone_set('PRC');
include_once("icbc.php");
if(!empty($_POST['hide'])) {
$fdir = $_SERVER['DOCUMENT_ROOT']."/key/"; //商户证书所放路径
$target = "http://localhost/test.php";
$payAPI['interfaceName'] = "ICBC_PERBANK_B2C"; //接口方式
$payAPI['interfaceVersion'] = "1.0.0.1"; //接口版本
$payAPI['merID'] = "0200EC20000012"; //商户ID
$payAPI['merAcct'] = "0200029109000030106"; //商户银行帐号
$payAPI['merURL'] = "http://localhost/get.php"; //接收银行通知路径
$payAPI['notifyType'] = "HS"; //接口通知方式
$payAPI['orderid'] = $_POST['orderid'];
$payAPI['amount'] = $_POST['amount'];
$payAPI['curType'] = "001"; //货币类型 001为人民币
$payAPI['resultType'] = "0";
$payAPI['orderDate'] = date("YmdHis");
$payAPI['verifyJoinFlag'] = "0";

$icbc = new icbcpay();
$icbc->init($payAPI,$fdir);
$icbc->Send();
}
?>
<html>
<head>
<title>模拟B2C交易</title>
</head>
<body leftmargin="0" topmargin="0">
<table cellpadding="1" cellspacing="1" bgcolor="#E5E5E5" width="800" align="center">
<tr bgcolor="#F5F5F5">
<td height="50" align="center">交易平台</td>
</tr>
<form action="b2c.php" method="post">
<tr bgcolor="#FFFFFF">
<td height="440" align="center">
<table cellpadding="1" cellspacing="1" bgcolor="#E5E5E5" width="600">
<tr bgcolor="#F5F5F5">
   <td height="30" align="center" width="120">订 单 号</td>
   <td bgcolor="#FDFDFD" width="580">&nbsp;
   <input type="text" name="orderid" value="000000001" style="width:300px" />
   </td>
</tr>
<tr bgcolor="#F5F5F5">
   <td height="30" align="center" width="120">商品金额</td>
   <td bgcolor="#FDFDFD" width="580">&nbsp;
   <input type="text" name="amount" value="100" style="width:300px" />
   </td>
</tr>
<tr bgcolor="#FAFAFA">
   <td colspan="2" height="30">
   <input type="hidden" name="hide" value="1" />
   <input type="submit" value="提交" />
   </td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>

icbc.php

<?php
class icbcpay
{
private $payAPI = Array();
private $fdir;
private $LongString;
private $POSTString;
private $target;
public function init($api,$fdir)
{
   $this->payAPI = $api;
   $this->fdir = $fdir;
   $this->target = $target;
   $this->getCOMAPI();
}

private function getCOMAPI()
{
   $icbc = new COM("ICBCEBANKUTIL.B2CUtil");
   $crt = $this->fdir."user.crt";
   $key = $this->fdir."user.key";
   $rc = $icbc->init($crt, $crt, $key, '11111111');
   $this->setString();
   if($rc == 0) {
    $this->payAPI['merSignMsg'] = $icbc->signC($this->LongString, strlen($this->LongString));
    $this->payAPI['merCert'] = $icbc->getCert(1);
   }
}

private function setString()
{
   $payAPI = $this->payAPI;
   $this->LongString.= "";
   foreach ($payAPI as $key => $value) {
    $this->LongString.= $value;
   }
}

private function setPOSTString()
{
   $payAPI=$this->payAPI;
   $this->POSTString = "";
   foreach ($payAPI as $key => $value) {
    if($key == "interfaceName") {
     $this->POSTString.=$key."=".$value;
    } else {
     $this->POSTString.="&".$key."=".$value;
    }
   }
}

private function setFromTxt()
{
   $payAPI = $this->payAPI;
  
   foreach ($payAPI as $key => $value) {
    $header.= '<input type="hidden" readonly="readonly" name="'.$key.'" value="'.$value.'">';
   }
   $header.= '</form>';
   return $header;
}

public function Send()
{
  
   $url = "http://localhost/test.php";
   $header = '<form action="'.$url.'" ;');
   //printf('</script>');
}
}
?>

 

转自:http://hi.baidu.com/linuxapplication/blog/item/15d986c2138d681d0ef47783.html

相关文章:

  • 2022-12-23
  • 2022-01-23
  • 2021-10-28
  • 2021-06-27
  • 2022-03-06
  • 2021-11-20
  • 2022-02-02
猜你喜欢
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-12-02
  • 2021-05-19
  • 2021-04-06
相关资源
相似解决方案