资源简介
package cn.itcast.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itcast.utils.ConfigInfo;
import cn.itcast.utils.PanymentUtil;
代码片段和文件信息
package cn.itcast.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itcast.utils.ConfigInfo;
import cn.itcast.utils.PanymentUtil;
/**
* 发起支付请求
* @author 传智播客
*
*/
public class PaymentRequest extends HttpServlet {
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
this.doPost(request response);
}
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
request.setCharacterEncoding(“GBK“);
String orderid = request.getParameter(“orderid“);//订单号
String amount = request.getParameter(“amount“);//支付金额
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“; // 请求命令在线支付固定为Buy
String currency = “CNY“; // 货币单位
String productDesc = ““; // 商品描述
String productCat = ““; // 商品种类
String productId = ““; // 商品ID
String 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(“/WEB-INF/page/connection.jsp“).forward(request response);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 478 2008-12-14 09:51 payment\.classpath
文件 294 2009-02-02 13:06 payment\.myme
文件 1225 2008-12-14 10:55 payment\.project
文件 330 2008-12-14 09:52 payment\.settings\org.eclipse.jdt.core.prefs
文件 2549 2009-02-02 13:24 payment\src\cn\itcast\servlet\PaymentRequest.java
文件 2882 2009-02-02 13:25 payment\src\cn\itcast\servlet\PaymentResutlResponse.java
文件 496 2009-02-02 13:19 payment\src\cn\itcast\utils\ConfigInfo.java
文件 2736 2008-12-14 10:15 payment\src\cn\itcast\utils\DigestUtil.java
文件 2948 2008-12-14 11:39 payment\src\cn\itcast\utils\PanymentUtil.java
文件 168 2009-02-02 13:15 payment\src\merchantInfo.properties
文件 3313 2008-12-14 10:57 payment\WebRoot\index.jsp
文件 39 2008-12-14 09:51 payment\WebRoot\me
文件 2573 2009-02-02 13:24 payment\WebRoot\WEB-INF\classes\cn\itcast\servlet\PaymentRequest.class
文件 3297 2009-02-02 13:25 payment\WebRoot\WEB-INF\classes\cn\itcast\servlet\PaymentResutlResponse.class
文件 995 2009-02-02 13:19 payment\WebRoot\WEB-INF\classes\cn\itcast\utils\ConfigInfo.class
文件 2691 2008-12-14 10:15 payment\WebRoot\WEB-INF\classes\cn\itcast\utils\DigestUtil.class
文件 2240 2008-12-14 11:39 payment\WebRoot\WEB-INF\classes\cn\itcast\utils\PanymentUtil.class
文件 168 2009-02-02 13:15 payment\WebRoot\WEB-INF\classes\merchantInfo.properties
文件 20682 2008-12-14 09:51 payment\WebRoot\WEB-INF\lib\jstl.jar
文件 393259 2008-12-14 09:51 payment\WebRoot\WEB-INF\lib\standard.jar
文件 1806 2008-12-14 12:14 payment\WebRoot\WEB-INF\page\connection.jsp
文件 431 2008-12-14 12:09 payment\WebRoot\WEB-INF\page\paymentResult.jsp
文件 1214 2008-12-14 11:41 payment\WebRoot\WEB-INF\web.xm
目录 0 2008-12-14 11:41 payment\WebRoot\WEB-INF\classes\cn\itcast\servlet
目录 0 2008-12-14 10:29 payment\WebRoot\WEB-INF\classes\cn\itcast\utils
目录 0 2008-12-14 10:21 payment\WebRoot\WEB-INF\classes\cn\itcast
目录 0 2008-12-14 11:41 payment\src\cn\itcast\servlet
目录 0 2008-12-14 10:29 payment\src\cn\itcast\utils
目录 0 2008-12-14 10:15 payment\WebRoot\WEB-INF\classes\cn
目录 0 2008-12-14 10:21 payment\src\cn\itcast
............此处省略14个文件信息
- 上一篇:SpryAssets.rar(附件)
- 下一篇:java基础程序设计
评论
共有 条评论