没有合适的资源?快使用搜索试试~ 我知道了~
首页javaweb在线支付功能实现代码
资源详情
资源评论
资源推荐
javaweb在线支付功能实现代码在线支付功能实现代码
主要为大家详细介绍了javaweb在线支付功能的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了javaweb在线支付功能的具体实现代码,供大家参考,具体内容如下
package com.learning.web.servlet;
import java.io.IOException;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.learning.utils.PaymentUtil;
@WebServlet("/payOnline")
public class PayOnline extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String orderid = request.getParameter("orderid");
String money = request.getParameter("money");
// 银行
String pd_FrpId = request.getParameter("pd_FrpId");
// 发给支付公司需要哪些数据
String p0_Cmd = "Buy";
String p1_MerId = ResourceBundle.getBundle("/WEB-INF/classes/merchantInfo").getString(
"p1_MerId");
String p2_Order = orderid;
String p3_Amt = money;
String p4_Cur = "CNY";
String p5_Pid = "";
String p6_Pcat = "";
String p7_Pdesc = "";
// 支付成功回调地址 ---- 第三方支付公司会访问、用户访问
// 第三方支付可以访问网址(本项目网址)
String p8_Url = "http://115.170.37.189/day19pay/callback";
String p9_SAF = "";
String pa_MP = "";
String pr_NeedResponse = "1";
// 加密hmac 需要密钥
String keyValue = ResourceBundle.getBundle("merchantInfo").getString(
"keyValue");
String hmac = PaymentUtil.buildHmac(p0_Cmd, p1_MerId, p2_Order, p3_Amt,
p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP,
pd_FrpId, pr_NeedResponse, keyValue);
// 生成url --- url?
request.setAttribute("pd_FrpId", pd_FrpId);
request.setAttribute("p0_Cmd", p0_Cmd);
request.setAttribute("p1_MerId", p1_MerId);
request.setAttribute("p2_Order", p2_Order);
request.setAttribute("p3_Amt", p3_Amt);
request.setAttribute("p4_Cur", p4_Cur);
request.setAttribute("p5_Pid", p5_Pid);
request.setAttribute("p6_Pcat", p6_Pcat);
request.setAttribute("p7_Pdesc", p7_Pdesc);
request.setAttribute("p8_Url", p8_Url);
request.setAttribute("p9_SAF", p9_SAF);
request.setAttribute("pa_MP", pa_MP);
request.setAttribute("pr_NeedResponse", pr_NeedResponse);
request.setAttribute("hmac", hmac);
request.getRequestDispatcher("/confirm.jsp").forward(request, response);
}
}
2.用户确认提交的信息(confirm.jsp)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="p" uri="http://www.itcast.cn/tag"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p:user />
<!-- 确认支付form -->
<form action="https://www.yeepay.com/app-merchant-proxy/node"
method="get">
<h3>订单号:${p2_Order},付款金额 :${p3_Amt }</h3>
<input type="hidden" name="pd_FrpId" value="${pd_FrpId }" /> <input
type="hidden" name="p0_Cmd" value="${p0_Cmd }" /> <input
type="hidden" name="p1_MerId" value="${p1_MerId }" /> <input
type="hidden" name="p2_Order" value="${p2_Order }" /> <input
type="hidden" name="p3_Amt" value="${p3_Amt }" /> <input
type="hidden" name="p4_Cur" value="${p4_Cur }" /> <input
type="hidden" name="p5_Pid" value="${p5_Pid }" /> <input
type="hidden" name="p6_Pcat" value="${p6_Pcat }" /> <input
type="hidden" name="p7_Pdesc" value="${p7_Pdesc }" /> <input
type="hidden" name="p8_Url" value="${p8_Url }" /> <input
type="hidden" name="p9_SAF" value="${p9_SAF }" /> <input
type="hidden" name="pa_MP" value="${pa_MP }" /> <input type="hidden"
name="pr_NeedResponse" value="${pr_NeedResponse }" /> <input
type="hidden" name="hmac" value="${hmac }" /> <input type="submit"
value="确认支付" />
</form>
</body>
</html>
3.网站获得第三方支付的信息
package com.learning.web.servlet;
import java.io.IOException;
import java.util.ResourceBundle;
weixin_38719475
- 粉丝: 2
- 资源: 950
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- ExcelVBA中的Range和Cells用法说明.pdf
- 基于单片机的电梯控制模型设计.doc
- 主成分分析和因子分析.pptx
- 共享笔记服务系统论文.doc
- 基于数据治理体系的数据中台实践分享.pptx
- 变压器的铭牌和额定值.pptx
- 计算机网络课程设计报告--用winsock设计Ping应用程序.doc
- 高电压技术课件:第03章 液体和固体介质的电气特性.pdf
- Oracle商务智能精华介绍.pptx
- 基于单片机的输液滴速控制系统设计文档.doc
- dw考试题 5套.pdf
- 学生档案管理系统详细设计说明书.doc
- 操作系统PPT课件.pptx
- 智慧路边停车管理系统方案.pptx
- 【企业内控系列】企业内部控制之人力资源管理控制(17页).doc
- 温度传感器分类与特点.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0