网上银行支付接口-环讯ips

网址:http://www.ips.com.cn/

 

<?php
 /**
  * 环讯ips
  */
 class Alipay{
  
  /**
  * 输出环讯ips代码
  *    
  * @param  array $product 订单信息
  * @param  array $pay  支付信息
  * @return string
  */
  function OutCode($product,$pay) {
   /**'
   '订单交易日期(YYYYMMDD),建议商户取系统当前日期作为订单交易日期**/
   //$datestr=date(YYYY-MM-)year(now())&right("0"&month(now()),2)&right("0"&day(now()),2)
   $datestr=date("Ymd",time());
   /**'订单号后6位,订单号为12位:6位商户号+6位随机号,一天内不能重复
   '此例子给了一个订单号生成算法,取系统当前时间做为订单号
   '但我们建议商户自己建立一个sequence序列号来作为6位随机号**/
   $billstr=date("His",time());
   $mer_code=$pay['user_num'];  
   $amount=$product['order_amount'];   /**测试金额默认为0.01**/
   $billno=$mer_code.$billstr;  /**测试订单号**/
   $strcert=$pay['md5'];   /**测试证书**/
   $strcontent=$billno.$amount.$datestr."RMB".$strcert;  /**签名验证串**/
   $serverurl = $INFO['site_url'].'/autocart/cart_payfourthly.php?pay_id='.intval($pay['pay_id']);
   $signmd5=MD5($strcontent);
   $button = '<div style="text-align:center">
    <form action="http://pay.ips.com.cn/ipayment.aspx" METHOD=POST name="frm1">
     <input type="hidden" name="Mer_code"         value="'.$mer_code.'">
     <input type="hidden" name="Billno"         value="'.$billno.'">
     <input type="hidden" name="Gateway_type"      value="04">
     <input type="hidden" name="Currency_Type"   value="RMB">
     <input type="hidden" name="Lang"         value="">
     <input type="hidden" name="Amount"     value="'.$amount.'">
     <input type="hidden" name="Date"     value="'.$datestr.'">
     <input type="hidden" name="Attach"     value="">
     <input type="hidden" name="DispAmount"     value="">
     <input type="hidden" name="OrderEncodeType"     value="2">
     <input type="hidden" name="RetEncodeType"     value="12">
     <input type="hidden" name="RetType"     value="1">
     <input type="hidden" name="serverurl"     value="'.$serverurl.'">
     <input type="hidden" name="SignMD5"     value="'.$signmd5.'">
     <input type="submit" value="马上使用环迅支付"/>
    </form>
    </div>'; 
   return $button;
  }
  /**
  * 相应操作
  *    
  * @return bool
  */
  function GetDo($pay="") {
   /**
   '适用对象:Window2000/NT用户
   
   '验证方式:
   ' 交易返回接口采用Md5摘要验证(RetEncodeType=12)
   
   '参考对象:交易返回接口采用Md5摘要验证(RetEncodeType=12)
   '明文信息:Md5摘要原文=订单编号+订单金额+订单日期+成功标志+IPS订单编号+RMB+IPS证书
   '验证结果:将下列函数的结果signature1转成小写字符与IPS返回的signature字段比较
   '   若相等,则表示验证成功
   '   若不等,则表示验证失败
   **/
   //----------------------------------------------------
   //  接收数据
   //  Receive the data
   //----------------------------------------------------
   $billno=$_GET['billno'];
   $amount=$_GET['amount'];
   $mydate=$_GET['date'];
   $succ=$_GET['succ'];
   $msg=$_GET['msg'];
   $attach=$_GET['attach'];
   $ipsbillno=$_GET['ipsbillno'];
   $retEncodeType=$_GET['retencodetype'];
   $currency_type=$_GET['Currency_type'];
   $signature=$_GET['signature'];
   //----------------------------------------------------
   //  判断交易是否成功
   //  See the successful flag of this transaction
   //----------------------------------------------------
   if ($succ=="Y"){
    //'----------------------------------------------------
    //'   Md5摘要认证
    //'   verify  md5
    //'----------------------------------------------------
    $content=$billno . $amount . $mydate . $succ . $ipsbillno .$currency_type;
    /**请在该字段中放置商户登陆merchant.ips.com.cn的网站中的证书 假设为**/
    $cert=$pay['md5'];
   
    //Md5摘要认证
    if ($content=="" || $cert=="")
     $signature1="";
    else
     $signature_1ocal=md5($content.$cert); 
   
    if ($signature_1ocal==$signature){
       return true;
       /**'----------------------------------------------------
       '比较返回的订单号和金额与您数据库中的金额是否相符
       'compare the billno and amount from ips with the data recorded in your datebase
       '----------------------------------------------------
       
       'if 不等 then
         'echo "从IPS返回的数据和本地记录的不符合,失败!"
         'exit
       'else
         '----------------------------------------------------
         '交易成功,处理您的数据库
         'The transaction is successful. update your database.
         '----------------------------------------------------
         '..............................
         '..............................
       'end if
       **/
    }
    else{
     return false;
     exit; 
    }
   }
   else{
    return false;
    exit;
   }
  }
 }
?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值