Skip to content

Commit

Permalink
完成支付宝手机网站支付接入
Browse files Browse the repository at this point in the history
  • Loading branch information
shuzheng committed Apr 3, 2017
1 parent 79a3281 commit 0b3806b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 33 deletions.
6 changes: 0 additions & 6 deletions zheng-pay/zheng-pay-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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}"/>
Expand All @@ -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>
18 changes: 10 additions & 8 deletions zheng-pay/zheng-pay-web/src/main/resources/config.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0b3806b

Please sign in to comment.