|
|
@@ -3,6 +3,7 @@ package com.zheng.pay.web.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alipay.api.AlipayClient;
|
|
|
+import com.alipay.api.request.AlipayTradePagePayRequest;
|
|
|
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
|
|
import com.zheng.common.base.BaseController;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -10,8 +11,6 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
/**
|
|
|
* 支付宝
|
|
|
* Created by ZhangShuzheng on 2017/04/04.
|
|
|
@@ -24,19 +23,35 @@ public class AlipayController extends BaseController {
|
|
|
private AlipayClient alipayClient;
|
|
|
|
|
|
@Autowired
|
|
|
- private AlipayTradeWapPayRequest alipayRequest;
|
|
|
+ private AlipayTradeWapPayRequest alipayTradeWapPayRequest;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AlipayTradePagePayRequest alipayTradePagePayRequest;
|
|
|
+
|
|
|
+ // 电脑网站支付
|
|
|
+ @RequestMapping("/pay/pc")
|
|
|
+ @ResponseBody
|
|
|
+ public Object pc() throws Exception {
|
|
|
+ JSONObject bizContent = new JSONObject();
|
|
|
+ bizContent.put("out_trade_no", "pay2017" + System.currentTimeMillis());
|
|
|
+ bizContent.put("total_amount", "0.01");
|
|
|
+ bizContent.put("subject", "Iphone6 16G");
|
|
|
+ bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
|
|
|
+ alipayTradePagePayRequest.setBizContent(bizContent.toString());
|
|
|
+ return alipayClient.pageExecute(alipayTradePagePayRequest).getBody();
|
|
|
+ }
|
|
|
|
|
|
- @RequestMapping("/pay")
|
|
|
+ // 手机网站支付
|
|
|
+ @RequestMapping("/pay/wap")
|
|
|
@ResponseBody
|
|
|
- public Object pay(HttpServletResponse response) throws Exception {
|
|
|
+ public Object wap() throws Exception {
|
|
|
JSONObject bizContent = new JSONObject();
|
|
|
- bizContent.put("out_trade_no", "pay20170404005030000000");
|
|
|
+ bizContent.put("out_trade_no", "pay2017" + System.currentTimeMillis());
|
|
|
bizContent.put("total_amount", "0.01");
|
|
|
bizContent.put("subject", "Iphone6 16G");
|
|
|
- bizContent.put("seller_id", "2088123456789012");
|
|
|
bizContent.put("product_code", "QUICK_WAP_PAY");
|
|
|
- alipayRequest.setBizContent(bizContent.toString());
|
|
|
- return alipayClient.pageExecute(alipayRequest).getBody();
|
|
|
+ alipayTradeWapPayRequest.setBizContent(bizContent.toString());
|
|
|
+ return alipayClient.pageExecute(alipayTradeWapPayRequest).getBody();
|
|
|
}
|
|
|
|
|
|
}
|