mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 #2980【微信支付】增加部分回调相关的单元测试代码
This commit is contained in:
@@ -22,6 +22,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES;
|
||||
|
||||
@@ -149,6 +150,13 @@ public abstract class BaseWxPayRequest implements Serializable {
|
||||
return new BigDecimal(yuan).setScale(2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 元转分
|
||||
*/
|
||||
public static Integer yuan2Fen(BigDecimal yuan) {
|
||||
return yuan.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查请求参数内容,包括必填参数以及特殊约束.
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,17 @@ public class WxPayConstants {
|
||||
*/
|
||||
public static final Format QUERY_COMMENT_DATE_FORMAT = FastDateFormat.getInstance("yyyyMMddHHmmss");
|
||||
|
||||
/**
|
||||
* 币种类型.
|
||||
*/
|
||||
public static class CurrencyType {
|
||||
/**
|
||||
* 人民币.
|
||||
*/
|
||||
public static final String CNY = "CNY";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户姓名选项,企业付款时使用.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.github.binarywang.wxpay.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 请求工具类.
|
||||
* Created by Wang_Wong on 2023-04-14.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/0katekate0/">Wang_Wong</a>
|
||||
*/
|
||||
public class RequestUtils {
|
||||
|
||||
/**
|
||||
* 获取请求头数据,微信V3版本回调使用
|
||||
*
|
||||
* @param request
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String readData(HttpServletRequest request) {
|
||||
BufferedReader br = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
br = request.getReader();
|
||||
for (String line; (line = br.readLine()) != null; ) {
|
||||
if (result.length() > 0) {
|
||||
result.append("\n");
|
||||
}
|
||||
result.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user