Răsfoiți Sursa

alipay电脑网站和手机网站支付

godmars 9 ani în urmă
părinte
comite
71173ec19e

+ 2 - 2
zheng-pay/zheng-pay-web/pom.xml

@@ -23,9 +23,9 @@
         <dependency>
             <groupId>com.alipay</groupId>
             <artifactId>sdk-java</artifactId>
-            <version>20170324180803</version>
+            <version>20170829142630</version>
             <scope>system</scope>
-            <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170324180803.jar</systemPath>
+            <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170829142630.jar</systemPath>
         </dependency>
         <dependency>
             <groupId>junit</groupId>

+ 24 - 9
zheng-pay/zheng-pay-web/src/main/java/com/zheng/pay/web/controller/AlipayController.java

@@ -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();
     }
 
 }

+ 10 - 2
zheng-pay/zheng-pay-web/src/main/resources/applicationContext-alipay.xml

@@ -7,7 +7,7 @@
 
     <context:property-placeholder location="classpath:config.properties"/>
 
-    <!-- 支付宝手机网站支付 -->
+    <!-- 支付客户端 -->
     <bean id="alipayClient" class="com.alipay.api.DefaultAlipayClient">
         <constructor-arg value="${alipay.gateway}"/>
         <constructor-arg value="${alipay.appid}"/>
@@ -17,7 +17,15 @@
         <constructor-arg value="${alipay.alipay_public_key}"/>
         <constructor-arg value="${alipay.sign_type}"/>
     </bean>
-    <bean id="alipayRequest" class="com.alipay.api.request.AlipayTradeWapPayRequest">
+
+    <!-- 电脑网站支付 -->
+    <bean id="alipayTradePagePayRequest" class="com.alipay.api.request.AlipayTradePagePayRequest">
+        <property name="returnUrl" value="${alipay.returnUrl}"/>
+        <property name="notifyUrl" value="${alipay.notifyUrl}"/>
+    </bean>
+
+    <!-- 手机网站支付 -->
+    <bean id="alipayTradeWapPayRequest" class="com.alipay.api.request.AlipayTradeWapPayRequest">
         <property name="returnUrl" value="${alipay.returnUrl}"/>
         <property name="notifyUrl" value="${alipay.notifyUrl}"/>
     </bean>

BIN
zheng-pay/zheng-pay-web/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170324180803.jar


BIN
zheng-pay/zheng-pay-web/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170829142630.jar