完成支付宝手机网站支付接入

This commit is contained in:
shuzheng 2017-04-04 01:06:28 +08:00
parent 79a32813b2
commit 0b3806bfb8
6 changed files with 58 additions and 33 deletions

View File

@ -44,12 +44,6 @@
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- zheng-upms-client -->
<dependency>
<groupId>com.zheng</groupId>
<artifactId>zheng-upms-client</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<profiles>

View File

@ -0,0 +1,42 @@
package com.zheng.pay.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.zheng.common.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
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.
*/
@Controller
@RequestMapping("/alipay")
public class AlipayController extends BaseController {
@Autowired
private AlipayClient alipayClient;
@Autowired
private AlipayTradeWapPayRequest alipayRequest;
@RequestMapping("/pay")
@ResponseBody
public Object pay(HttpServletResponse response) throws Exception {
JSONObject bizContent = new JSONObject();
bizContent.put("out_trade_no", "pay20170404005030000000");
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();
}
}

View File

@ -1,8 +0,0 @@
package com.zheng.pay.web.controller;
public class AppController {
}

View File

@ -8,7 +8,7 @@
<context:property-placeholder location="classpath:config.properties"/>
<!-- 支付宝手机网站支付 -->
<bean id="alipayWebClient" class="com.alipay.api.DefaultAlipayClient">
<bean id="alipayClient" class="com.alipay.api.DefaultAlipayClient">
<constructor-arg value="${alipay.gateway}"/>
<constructor-arg value="${alipay.appid}"/>
<constructor-arg value="${alipay.rsa.private_key}"/>
@ -17,5 +17,9 @@
<constructor-arg value="${alipay.alipay_public_key}"/>
<constructor-arg value="${alipay.sign_type}"/>
</bean>
<bean id="alipayRequest" class="com.alipay.api.request.AlipayTradeWapPayRequest">
<property name="returnUrl" value="${alipay.returnUrl}"/>
<property name="notifyUrl" value="${alipay.notifyUrl}"/>
</bean>
</beans>

View File

@ -1,10 +1,12 @@
env=${profile.env}
alipay.appid=${alipay.appid}
alipay.gateway=${alipay.gateway}
alipay.rsa.private_key=${alipay.rsa.private_key}
alipay.rsa.public_key=${alipay.rsa.public_key}
alipay.alipay_public_key=${alipay.alipay_public_key}
alipay.format=${alipay.format}
alipay.charset=${alipay.charset}
alipay.sign_type=${alipay.sign_type}
alipay.appid=
alipay.gateway=https://openapi.alipaydev.com/gateway.do
alipay.rsa.private_key=
alipay.rsa.public_key=
alipay.alipay_public_key=
alipay.format=json
alipay.charset=UTF-8
alipay.sign_type=RSA2
alipay.returnUrl=http://pay.zhangshuzheng.cn/alipay/returnUrl
alipay.notifyUrl=http://pay.zhangshuzheng.cn/alipay/notifyUrl

View File

@ -1,10 +1 @@
profile.env=dev
alipay.appid=
alipay.gateway=https://openapi.alipaydev.com/gateway.do
alipay.rsa.private_key=
alipay.rsa.public_key=
alipay.alipay_public_key=
alipay.format=json
alipay.charset=UTF-8
alipay.sign_type=RSA2
profile.env=dev