传智播客在线支付
来源:互联网 发布:c语言学会了有什么用 编辑:程序博客网 时间:2024/04/30 06:52
第一部分:
1.两种接入方案 a)直接与银行对接 b)通过中间公司间接与银行对接
2.中间支付的一些例子
第二部分:
1.使用yeepay支付的代码要求
第三部分:
1.创建一个前台提交订单号、金额、网上银行的前台页面
其中订单信息提交给servlet(其中用到了工具类)
request.setCharacterEncoding("GBK");String orderid = request.getParameter("orderNumber");//订单号String amount = request.getParameter("money");//支付金额String pd_FrpId = request.getParameter("pd_FrpId");//选择的支付银行String p1_MerId = ConfigInfo.getValue("p1_MerId");String keyValue = ConfigInfo.getValue("keyValue");String merchantCallbackURL = ConfigInfo.getValue("merchantCallbackURL");String messageType = "Buy"; // 请求命令,在线支付固定为BuyString currency = "CNY"; // 货币单位String productDesc = ""; // 商品描述String productCat = ""; // 商品种类String productId = ""; // 商品IDString addressFlag = "0"; // 需要填写送货信息 0:不需要 1:需要String sMctProperties = ""; // 商家扩展信息String pr_NeedResponse = "0"; // 应答机制String md5hmac = PanymentUtil.buildHmac(messageType, p1_MerId, orderid, amount, currency,productId, productCat, productDesc, merchantCallbackURL, addressFlag, sMctProperties, pd_FrpId, pr_NeedResponse, keyValue);request.setAttribute("messageType", messageType);request.setAttribute("merchantID", p1_MerId);request.setAttribute("orderId", orderid);request.setAttribute("amount", amount);request.setAttribute("currency", currency);request.setAttribute("productId", productId);request.setAttribute("productCat", productCat);request.setAttribute("productDesc", productDesc);request.setAttribute("merchantCallbackURL", merchantCallbackURL);request.setAttribute("addressFlag", addressFlag);request.setAttribute("sMctProperties", sMctProperties);request.setAttribute("frpId", pd_FrpId);request.setAttribute("pr_NeedResponse", pr_NeedResponse);request.setAttribute("hmac", md5hmac);request.getRequestDispatcher("/security/connection.jsp").forward(request, response);
注意,如上述参数不能为null,可以为为“”(空字符串)
2.请求转发页面的处理 connection.jsp
<body onload="javascript:document.forms[0].submit()"> <!-- onload="javascript:document.forms[0].submit()" --> <!-- http://tech.yeepay.com:8080/robot/debug.action --> <!-- https://www.yeepay.com/app-merchant-proxy/node --><form name="yeepay" action="https://www.yeepay.com/app-merchant-proxy/node" method='post'><input type='hidden' name='p0_Cmd' value="${messageType}"> <!-- 请求命令,在线支付固定为Buy --><input type='hidden' name='p1_MerId' value="${merchantID}"> <!-- 商家ID --><input type="hidden" name="p2_Order" value="${orderId}"> <!-- 商家的交易定单号 --><input type='hidden' name='p3_Amt' value="${amount}"> <!-- 订单金额 --><input type='hidden' name='p4_Cur' value="${currency}"> <!-- 货币单位 --><input type='hidden' name='p5_Pid' value="${productId}"> <!-- 商品ID --><input type='hidden' name='p6_Pcat' value="${productCat}"> <!-- 商品种类 --><input type='hidden' name='p7_Pdesc' value="${productDesc}"> <!-- 商品描述 --><input type='hidden' name='p8_Url' value="${merchantCallbackURL}"> <!-- 交易结果通知地址 --><input type='hidden' name='p9_SAF' value="${addressFlag}"> <!-- 需要填写送货信息 0:不需要 1:需要 --><input type='hidden' name='pa_MP' value="${sMctProperties}"> <!-- 商家扩展信息 --><input type='hidden' name='pd_FrpId' value="${frpId}"> <!-- 银行ID --><!-- 应答机制 为“1”: 需要应答机制;为“0”: 不需要应答机制 --><input type="hidden" name="pr_NeedResponse" value="0"><input type='hidden' name='hmac' value="${hmac}"><!-- MD5-hmac验证码 --><input type="submit" value="发送" style="display:none;"></form> </body>
3.用户通过网上银行进行支付
4.配置路由器,转发支付结果的响应请求,注意此地址必须是针对互联网的
5.接收到用户请求的结果后,对结果进行显示
request.setCharacterEncoding("GBK");String merchantID = ConfigInfo.getValue("p1_MerId"); // 商家IDString keyValue = ConfigInfo.getValue("keyValue"); // 商家密钥String sCmd = request.getParameter("r0_Cmd"); //业务类型String sResultCode = request.getParameter("r1_Code"); //扣款结果,该字段值为1时表示扣款成功.String sTrxId = request.getParameter("r2_TrxId"); //YeePay易宝交易订单号String amount = request.getParameter("r3_Amt");//扣款金额,交易结束后,YeePay易宝交易系统将实际扣款金额返回给商户String currency = request.getParameter("r4_Cur");//交易币种,人民币为CNYString productId = request.getParameter("r5_Pid");//商品IDString orderId = request.getParameter("r6_Order");//商户订单号String userId = request.getParameter("r7_Uid");//YeePay易宝会员IDString mp = request.getParameter("r8_MP");//商户扩展信息,可以任意填写1K 的字符串,交易返回时将原样返回String bType = request.getParameter("r9_BType");//交易结果通知类型,1: 交易成功回调(浏览器重定向)2: 交易成功主动通知(服务器点对点通讯)String rb_BankId = request.getParameter("rb_BankId");//支付银行String rp_PayDate = request.getParameter("rp_PayDate");//在银行支付时的时间String hmac = request.getParameter("hmac");//MD5交易签名boolean result = PanymentUtil.verifyCallback(hmac, merchantID, sCmd, sResultCode, sTrxId, amount,currency, productId, orderId, userId, mp, bType, keyValue);if(result){if("1".equals(sResultCode)){//你们这个地方应该把数据库中订单的支付状态设置成已经支付.String message = "订单号为:"+ orderId+ "的订单支付成功了";message += ",用户支付了"+ amount +"元";message +=",交易结果通知类型:";if("1".equals(bType)){ message += "浏览器重定向";}else if("2".equals(bType)){ message += "易宝支付网关后台程序通知";}message += ",易宝订单系统中的订单号为:"+ sTrxId;request.setAttribute("message", message);}else{request.setAttribute("message", "用户支付失败");}}else{request.setAttribute("message", "数据来源不合法");}request.getRequestDispatcher("/security/paymentResult.jsp").forward(request, response);
转到的paymentResult.jsp
<body ><center><h3><font color="red">${message }</font></h3></center> </body>
6.其中用到的工具类
ConfigInfo.java 提取用户的商家的易宝商家账号和加密字符串,还有接收用户订单支付结果响应的网址,可以写在属性文件中便于修改
DigestUtil.java 核心加密工具类
PanymentUtil.java 加密原理
- 传智播客在线支付
- 在线支付
- 在线支付
- 在线支付
- 在线支付
- 在线支付
- 在线支付
- 在线支付
- 支付宝在线支付
- 第三方支付,在线支付
- 支付宝在线支付接口
- 【在线支付】在线支付的方式
- 【在线支付】在线支付流程分析
- 【在线支付】在线支付代码详解
- paypal在线支付使用
- Paypal 在线支付接口
- java实现在线支付
- java实现在线支付
- 64整数在shell就默认按有符号处理,取模要注意
- 飞凌OK6410学习之串口的学习
- 递归 uva-620-Cellular Structure
- Ubuntu 中sendmail 的安装、配置与发送邮件的具体实现
- Html Agility Pack ── 一个分析HTML的工具
- 传智播客在线支付
- C#中string[]数组和list<string>泛型的相互转换
- 从朋友那看到的,很有哲理
- 编写OD插件将IDA中分析出来的函数名导入到OD中
- povray下载 pov-ray for amd64 on Ubuntu 12.04 POVRAY
- 用管道连接的两个命令谁先运行
- c++ 中文分词介绍
- 协同与执行力
- Gabor变换