Skip to content

Commit

Permalink
1.2.2 :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Javen205 committed Jun 30, 2019
1 parent 78da6be commit 9ed36ec
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.javen205</groupId>
<artifactId>IJPay</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<packaging>jar</packaging>
<name>IJPay</name>
<description>Easy Pay Library</description>
Expand Down
41 changes: 37 additions & 4 deletions src/main/java/com/jpay/alipay/AliPayApi.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.jpay.alipay;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date;
Expand Down Expand Up @@ -62,12 +64,43 @@ public static AlipayTradeAppPayResponse appPayToResponse(AlipayTradeAppPayModel
public static void wapPay(HttpServletResponse response, AlipayTradeWapPayModel model, String returnUrl,
String notifyUrl) throws AlipayApiException, IOException {
String form = wapPayStr(response, model, returnUrl, notifyUrl);
HttpServletResponse httpResponse = response;
httpResponse.setContentType("text/html;charset=" + AliPayApiConfigKit.getAliPayApiConfig().getCharset());
httpResponse.getWriter().write(form);// 直接将完整的表单html输出到页面
httpResponse.getWriter().flush();
response.setContentType("text/html;charset=" + AliPayApiConfigKit.getAliPayApiConfig().getCharset());
/**
* PrintWriter out = response.getWriter(); out对象用于输出字符流数据
* 直接输出html表单数据到页面
*/
PrintWriter out = response.getWriter();
out.write(form);
out.flush();
}

/**
* WAP支付
* 为了解决Filter中使用OutputStream getOutputStream() 和PrintWriter getWriter()冲突异常问题
* @param response
* {HttpServletResponse}
* @param model
* {AlipayTradeWapPayModel}
* @param returnUrl
* 异步通知URL
* @param notifyUrl
* 同步通知URL
* @throws AlipayApiException
* @throws IOException
*/
public static void wapPayOutputStream(HttpServletResponse response, AlipayTradeWapPayModel model, String returnUrl, String notifyUrl) throws AlipayApiException, IOException {
String form = wapPayStr(response, model, returnUrl, notifyUrl);
response.setContentType("text/html;charset=" + AliPayApiConfigKit.getAliPayApiConfig().getCharset());
/**
* OutputStream out = response.getOutputStream();
* out用于输出字符流数据或者二进制的字节流数据
*/
OutputStream out = response.getOutputStream();
out.write(form.getBytes(AliPayApiConfigKit.getAliPayApiConfig().getCharset()));
response.getOutputStream().flush();
}


/**
* WAP支付
*
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/jpay/ext/kit/HashKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,3 @@ public static boolean slowEquals(byte[] a, byte[] b) {
return diff == 0;
}
}




6 changes: 0 additions & 6 deletions src/main/java/com/jpay/ext/kit/HttpKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,3 @@ public static String readIncommingRequestData(HttpServletRequest request) {
return readData(request);
}
}






4 changes: 0 additions & 4 deletions src/main/java/com/jpay/ext/kit/StrKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,3 @@ public static String getRandomUUID() {
return java.util.UUID.randomUUID().toString().replace("-", "");
}
}




10 changes: 9 additions & 1 deletion src/main/java/com/jpay/util/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ private interface HttpDelegate {
}

// http请求工具代理对象
private static final HttpDelegate delegate;
public static HttpDelegate delegate;

public static HttpDelegate getDelegate() {
return delegate;
}

public static void setDelegate(HttpDelegate delegate) {
HttpUtils.delegate = delegate;
}

static {
HttpDelegate delegateToUse = null;
Expand Down

0 comments on commit 9ed36ec

Please sign in to comment.