本文整理汇总了Java中com.alipay.util.AlipaySubmit类的典型用法代码示例。如果您正苦于以下问题:Java AlipaySubmit类的具体用法?Java AlipaySubmit怎么用?Java AlipaySubmit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlipaySubmit类属于com.alipay.util包,在下文中一共展示了AlipaySubmit类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alipayHandler
import com.alipay.util.AlipaySubmit; //导入依赖的package包/类
/**
* 进入支付宝界面
*
* @return
*/
@Action(value = "alipayHandler", results = { @Result(name = "alipayUI", location = ViewLocation.View_ROOT
+ "alipay.jsp") })
public String alipayHandler() throws Exception {
System.out.println("PayAction.alipayHandler()");
//获取需要的参数
int orderId = getIntParameter("id", -1);
if(orderId == -1){
throw new Exception("alipayHandler get parameters error!");
}
Mrcodeorder order = mrcodeorderService.getById(orderId);
//商户订单号,商户网站订单系统中唯一订单号,必填
String out_trade_no = order.getOrderCode();
//订单名称,必填
String subject = "OrderNumber-"+out_trade_no;
//付款金额,必填
String total_fee = order.getDepositPrice().toString();
//商品描述,可空,含有中文会导致校验失败
/*StringBuilder builder = new StringBuilder();
for (OrderDish orderDish : order.getOrderDishes()) {
builder.append("orderId:"+orderDish.getId()+"-DISHNAME-"+orderDish.getDishName()+"-PRICE-"+orderDish.getDishPrice()+"-COUNT-"+orderDish.getDishCount());
}
String body = builder.toString();*/
//String body = "对商品的描述";
String body = order.getOrderCode();
//把请求参数打包成数组
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("service", AlipayConfig.service);
paramMap.put("partner", AlipayConfig.partner);
paramMap.put("seller_id", AlipayConfig.seller_id);
paramMap.put("_input_charset", AlipayConfig.input_charset);
paramMap.put("payment_type", AlipayConfig.payment_type);
paramMap.put("notify_url", AlipayConfig.notify_url);
paramMap.put("return_url", AlipayConfig.return_url);
paramMap.put("anti_phishing_key", AlipayConfig.anti_phishing_key);
paramMap.put("exter_invoke_ip", AlipayConfig.exter_invoke_ip);
paramMap.put("out_trade_no", out_trade_no);
paramMap.put("subject", subject);
paramMap.put("total_fee", total_fee);
paramMap.put("body", body);
//建立请求
String sHtmlText = AlipaySubmit.buildRequest(paramMap,"get","确认");
//System.out.println(sHtmlText);
request.setAttribute("sHtmlText", sHtmlText);
return "alipayUI";
}