Skip to content

Commit

Permalink
0.8 Release:)
Browse files Browse the repository at this point in the history
  • Loading branch information
Javen205 committed Nov 16, 2017
1 parent 98aeab4 commit c7c8686
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 51 deletions.
84 changes: 47 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.javen205</groupId>
<artifactId>IJPay</artifactId>
<version>0.7</version>
<version>0.8</version>
<packaging>jar</packaging>
<name>IJPay</name>
<description>Easy Pay Library</description>
Expand Down Expand Up @@ -38,7 +38,7 @@
</developers>

<properties>
<jdk.version>1.8</jdk.version>
<jdk.version>1.6</jdk.version>
<log4j.version>1.2.17</log4j.version>
<zxing.version>3.2.1</zxing.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -147,42 +147,46 @@
<build>
<finalName>IJPay</finalName>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>attach-sources</id>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>a_little_config.txt</exclude>
<exclude>a_little_config_pro.txt</exclude>
<exclude>ehcache.xml</exclude>
<exclude>log4j.properties</exclude>
<exclude>com/jfinal/weixin/demo</exclude>
<exclude>com/jfinal/weixin/demo/*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- 解决 java8 下发布到 maven 中心库时,生成 doc 的异常 -->
<additionalparam>-Xdoclint:none</additionalparam>
Expand All @@ -191,25 +195,31 @@
<reportOutputDirectory>${basedir}</reportOutputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<!-- mvn clean javadoc:jar source:jar deploy -P release -Dgpg.passphrase=xxxx -->
<profile>
<id>release</id>
<build>
<plugins>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>nexus-release</id>
Expand Down
97 changes: 83 additions & 14 deletions src/main/java/com/jpay/alipay/AliPayApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public class AliPayApi {
* @return {String}
* @throws {AlipayApiException}
*/
public static String startAppPayStr(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
AlipayTradeAppPayResponse response = appPay(model,notifyUrl);
public static String startAppPay(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
AlipayTradeAppPayResponse response = appPayToResponse(model,notifyUrl);
return response.getBody();
}

Expand All @@ -111,7 +111,7 @@ public static String startAppPayStr(AlipayTradeAppPayModel model, String notifyU
* @return {AlipayTradeAppPayResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
public static AlipayTradeAppPayResponse appPayToResponse(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
Expand All @@ -121,6 +121,19 @@ public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, Str
AlipayTradeAppPayResponse response = AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().sdkExecute(request);
return response;
}

/**
* APP支付
* https://doc.open.alipay.com/docs/doc.htm?treeId=54&articleId=106370&docType=1
* @param model
* @param notifyUrl
* @return {AlipayTradeAppPayResponse}
* @throws {AlipayApiException}
*/
@Deprecated
public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
return appPayToResponse(model, notifyUrl);
}

/**
* WAP支付
Expand All @@ -133,7 +146,7 @@ public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, Str
* @throws IOException
*/
public static void wapPay(HttpServletResponse response,AlipayTradeWapPayModel model,String returnUrl,String notifyUrl) throws AlipayApiException, IOException {
String form = wapPayToString(response, model, returnUrl, notifyUrl);
String form = wapPayStr(response, model, returnUrl, notifyUrl);
HttpServletResponse httpResponse = response;
httpResponse.setContentType("text/html;charset=" + AliPayApiConfigKit.getAliPayApiConfig().getCharset());
httpResponse.getWriter().write(form);// 直接将完整的表单html输出到页面
Expand All @@ -149,13 +162,28 @@ public static void wapPay(HttpServletResponse response,AlipayTradeWapPayModel mo
* @throws {AlipayApiException}
* @throws IOException
*/
public static String wapPayToString(HttpServletResponse response,AlipayTradeWapPayModel model,String returnUrl,String notifyUrl) throws AlipayApiException, IOException {
public static String wapPayStr(HttpServletResponse response,AlipayTradeWapPayModel model,String returnUrl,String notifyUrl) throws AlipayApiException, IOException {
AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();// 创建API对应的request
alipayRequest.setReturnUrl(returnUrl);
alipayRequest.setNotifyUrl(notifyUrl);// 在公共参数中设置回跳和通知地址
alipayRequest.setBizModel(model);// 填充业务参数
return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().pageExecute(alipayRequest).getBody(); // 调用SDK生成表单
}

/**
* WAP支付
* @param response
* @param model
* @param returnUrl
* @param notifyUrl
* @return {String}
* @throws {AlipayApiException}
* @throws IOException
*/
@Deprecated
public static String wapPayToString(HttpServletResponse response,AlipayTradeWapPayModel model,String returnUrl,String notifyUrl) throws AlipayApiException, IOException {
return wapPayStr(response, model, returnUrl, notifyUrl);
}

/**
* 条形码支付、声波支付
Expand Down Expand Up @@ -281,7 +309,7 @@ public static AlipayFundTransOrderQueryResponse transferQueryToResponse(AlipayFu
* @throws {AlipayApiException}
*/
public static boolean isTradeQuery(AlipayTradeQueryModel model) throws AlipayApiException{
AlipayTradeQueryResponse response = tradeQuery(model);
AlipayTradeQueryResponse response = tradeQueryToResponse(model);
if(response.isSuccess()){
return true;
}
Expand All @@ -293,11 +321,21 @@ public static boolean isTradeQuery(AlipayTradeQueryModel model) throws AlipayApi
* @return {AlipayTradeQueryResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeQueryResponse tradeQuery(AlipayTradeQueryModel model) throws AlipayApiException{
public static AlipayTradeQueryResponse tradeQueryToResponse(AlipayTradeQueryModel model) throws AlipayApiException{
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
request.setBizModel(model);
return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
}
/**
* 交易查询接口
* @param model
* @return {AlipayTradeQueryResponse}
* @throws {AlipayApiException}
*/
@Deprecated
public static AlipayTradeQueryResponse tradeQuery(AlipayTradeQueryModel model) throws AlipayApiException{
return tradeQueryToResponse(model);
}


/**
Expand All @@ -308,7 +346,7 @@ public static AlipayTradeQueryResponse tradeQuery(AlipayTradeQueryModel model)
* @throws {AlipayApiException}
*/
public static boolean isTradeCancel(AlipayTradeCancelModel model) throws AlipayApiException{
AlipayTradeCancelResponse response = tradeCancel(model);
AlipayTradeCancelResponse response = tradeCancelToResponse(model);
if(response.isSuccess()){
return true;
}
Expand All @@ -320,12 +358,22 @@ public static boolean isTradeCancel(AlipayTradeCancelModel model) throws AlipayA
* @return {AlipayTradeCancelResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeCancelResponse tradeCancel(AlipayTradeCancelModel model) throws AlipayApiException{
public static AlipayTradeCancelResponse tradeCancelToResponse(AlipayTradeCancelModel model) throws AlipayApiException{
AlipayTradeCancelRequest request = new AlipayTradeCancelRequest();
request.setBizModel(model);
AlipayTradeCancelResponse response = AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
return response;
}
/**
* 交易撤销接口
* @param model
* @return {AlipayTradeCancelResponse}
* @throws {AlipayApiException}
*/
@Deprecated
public static AlipayTradeCancelResponse tradeCancel(AlipayTradeCancelModel model) throws AlipayApiException{
return tradeCancelToResponse(model);
}
/**
* 关闭订单
* https://doc.open.alipay.com/docs/api.htm?spm=a219a.7629065.0.0.21yRUe&apiId=1058&docType=4
Expand All @@ -334,7 +382,7 @@ public static AlipayTradeCancelResponse tradeCancel(AlipayTradeCancelModel model
* @throws {AlipayApiException}
*/
public static boolean isTradeClose(AlipayTradeCloseModel model) throws AlipayApiException{
AlipayTradeCloseResponse response = tradeClose(model);
AlipayTradeCloseResponse response = tradeCloseToResponse(model);
if(response.isSuccess()){
return true;
}
Expand All @@ -346,11 +394,22 @@ public static boolean isTradeClose(AlipayTradeCloseModel model) throws AlipayApi
* @return {AlipayTradeCloseResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeCloseResponse tradeClose(AlipayTradeCloseModel model) throws AlipayApiException{
public static AlipayTradeCloseResponse tradeCloseToResponse(AlipayTradeCloseModel model) throws AlipayApiException{
AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
request.setBizModel(model);
return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);

}
/**
* 关闭订单
* @param model
* @return {AlipayTradeCloseResponse}
* @throws {AlipayApiException}
*/
@Deprecated
public static AlipayTradeCloseResponse tradeClose(AlipayTradeCloseModel model) throws AlipayApiException{
return tradeCloseToResponse(model);

}
/**
* 统一收单交易创建接口
Expand All @@ -360,7 +419,7 @@ public static AlipayTradeCloseResponse tradeClose(AlipayTradeCloseModel model) t
* @return {AlipayTradeCreateResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeCreateResponse tradeCreate(AlipayTradeCreateModel model, String notifyUrl) throws AlipayApiException{
public static AlipayTradeCreateResponse tradeCreateToResponse(AlipayTradeCreateModel model, String notifyUrl) throws AlipayApiException{
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);
Expand Down Expand Up @@ -446,7 +505,7 @@ public static AlipayDataDataserviceBillDownloadurlQueryResponse billDownloadurl
* @throws {AlipayApiException}
*/
public static boolean isTradeOrderSettle(AlipayTradeOrderSettleModel model) throws AlipayApiException{
AlipayTradeOrderSettleResponse response = tradeOrderSettle(model);
AlipayTradeOrderSettleResponse response = tradeOrderSettleToResponse(model);
if(response.isSuccess()){
return true;
}
Expand All @@ -458,11 +517,21 @@ public static boolean isTradeOrderSettle(AlipayTradeOrderSettleModel model) thro
* @return {AlipayTradeOrderSettleResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeOrderSettleResponse tradeOrderSettle(AlipayTradeOrderSettleModel model) throws AlipayApiException{
public static AlipayTradeOrderSettleResponse tradeOrderSettleToResponse(AlipayTradeOrderSettleModel model) throws AlipayApiException{
AlipayTradeOrderSettleRequest request = new AlipayTradeOrderSettleRequest();
request.setBizModel(model);
return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
}
/**
* 交易结算接口
* @param model
* @return {AlipayTradeOrderSettleResponse}
* @throws {AlipayApiException}
*/
@Deprecated
public static AlipayTradeOrderSettleResponse tradeOrderSettle(AlipayTradeOrderSettleModel model) throws AlipayApiException{
return tradeOrderSettleToResponse(model);
}

/**
* 电脑网站支付(PC支付)
Expand Down

0 comments on commit c7c8686

Please sign in to comment.