forked from jeequan/jeepay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jmdhappy
committed
Oct 24, 2017
1 parent
c454edf
commit 20a5732
Showing
39 changed files
with
2,724 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.xxpay</groupId> | ||
<artifactId>xxpay4spring-boot</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
<name>xxpay4spring-boot</name> | ||
<description>xxpay4spring-boot</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.6.RELEASE</version> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<springboot.version>1.5.6.RELEASE</springboot.version> | ||
<springboot.dubbo.version>1.0.0</springboot.dubbo.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.xxpay</groupId> | ||
<artifactId>xxpay-dal</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>1.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-freemarker</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-activemq</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.activemq</groupId> | ||
<artifactId>activemq-pool</artifactId> | ||
</dependency> | ||
<!--wx_pay--> | ||
<dependency> | ||
<groupId>com.github.binarywang</groupId> | ||
<artifactId>weixin-java-pay</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
<!--ali_pay--> | ||
<dependency> | ||
<groupId>com.alipay</groupId> | ||
<artifactId>sdk</artifactId> | ||
<version>1.5</version> | ||
<scope>system</scope> | ||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170818173712.jar</systemPath> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<finalName>${project.name}</finalName> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
16 changes: 16 additions & 0 deletions
16
xxpay4spring-boot/src/main/java/org/xxpay/boot/XxPayBootAppliaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.xxpay.boot; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
/** | ||
* | ||
*/ | ||
@SpringBootApplication | ||
@ComponentScan(basePackages={"org.xxpay"}) | ||
public class XxPayBootAppliaction { | ||
public static void main(String[] args) { | ||
SpringApplication.run(XxPayBootAppliaction.class, args); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/Notify4AliPayController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.xxpay.boot.ctrl; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.xxpay.boot.web.NotifyPayService; | ||
import org.xxpay.common.constant.PayConstant; | ||
import org.xxpay.common.util.MyLog; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
/** | ||
* @Description: 接收处理支付宝通知 | ||
* @author dingzhiwei [email protected] | ||
* @date 2017-07-05 | ||
* @version V1.0 | ||
* @Copyright: www.xxpay.org | ||
*/ | ||
@RestController | ||
public class Notify4AliPayController { | ||
|
||
private static final MyLog _log = MyLog.getLog(Notify4AliPayController.class); | ||
|
||
@Autowired | ||
private NotifyPayService notifyPayService; | ||
|
||
/** | ||
* 支付宝移动支付后台通知响应 | ||
* @param request | ||
* @return | ||
* @throws ServletException | ||
* @throws IOException | ||
*/ | ||
@RequestMapping(value = "/notify/pay/aliPayNotifyRes.htm") | ||
@ResponseBody | ||
public String aliPayNotifyRes(HttpServletRequest request) throws ServletException, IOException { | ||
_log.info("====== 开始接收支付宝支付回调通知 ======"); | ||
String notifyRes = doAliPayRes(request); | ||
_log.info("响应给支付宝:{}", notifyRes); | ||
_log.info("====== 完成接收支付宝支付回调通知 ======"); | ||
return notifyRes; | ||
} | ||
|
||
public String doAliPayRes(HttpServletRequest request) throws ServletException, IOException { | ||
String logPrefix = "【支付宝支付回调通知】"; | ||
//获取支付宝POST过来反馈信息 | ||
Map<String,String> params = new HashMap<String,String>(); | ||
Map requestParams = request.getParameterMap(); | ||
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) { | ||
String name = (String) iter.next(); | ||
String[] values = (String[]) requestParams.get(name); | ||
String valueStr = ""; | ||
for (int i = 0; i < values.length; i++) { | ||
valueStr = (i == values.length - 1) ? valueStr + values[i] | ||
: valueStr + values[i] + ","; | ||
} | ||
//乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化 | ||
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk"); | ||
params.put(name, valueStr); | ||
} | ||
_log.info("{}通知请求数据:reqStr={}", logPrefix, params); | ||
if(params.isEmpty()) { | ||
_log.error("{}请求参数为空", logPrefix); | ||
return PayConstant.RETURN_ALIPAY_VALUE_FAIL; | ||
} | ||
return notifyPayService.doAliPayNotify(params); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
xxpay4spring-boot/src/main/java/org/xxpay/boot/ctrl/Notify4WxPayController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.xxpay.boot.ctrl; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.xxpay.boot.web.NotifyPayService; | ||
import org.xxpay.common.util.MyLog; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @Description: 接收处理微信通知 | ||
* @author dingzhiwei [email protected] | ||
* @date 2017-07-05 | ||
* @version V1.0 | ||
* @Copyright: www.xxpay.org | ||
*/ | ||
@RestController | ||
public class Notify4WxPayController { | ||
|
||
private static final MyLog _log = MyLog.getLog(Notify4WxPayController.class); | ||
|
||
@Autowired | ||
private NotifyPayService notifyPayService; | ||
|
||
/** | ||
* 微信支付(统一下单接口)后台通知响应 | ||
* @param request | ||
* @return | ||
* @throws ServletException | ||
* @throws IOException | ||
*/ | ||
@RequestMapping("/notify/pay/wxPayNotifyRes.htm") | ||
@ResponseBody | ||
public String wxPayNotifyRes(HttpServletRequest request) throws ServletException, IOException { | ||
_log.info("====== 开始接收微信支付回调通知 ======"); | ||
String notifyRes = doWxPayRes(request); | ||
_log.info("响应给微信:{}", notifyRes); | ||
_log.info("====== 完成接收微信支付回调通知 ======"); | ||
return notifyRes; | ||
} | ||
|
||
public String doWxPayRes(HttpServletRequest request) throws ServletException, IOException { | ||
String logPrefix = "【微信支付回调通知】"; | ||
String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding()); | ||
_log.info("{}通知请求数据:reqStr={}", logPrefix, xmlResult); | ||
return notifyPayService.doWxPayNotify(xmlResult); | ||
} | ||
|
||
} |
Oops, something went wrong.