新增抽出货币类型接口,国家地区代码

This commit is contained in:
egan
2019-04-16 23:14:28 +08:00
parent 66ffdc5782
commit 1b7b2f7c90
13 changed files with 227 additions and 44 deletions

View File

@@ -282,7 +282,7 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
String bizContent = (String) orderInfo.remove(BIZ_CONTENT);
formHtml.append(getReqUrl()).append("?").append(UriVariables.getMapToParameters(orderInfo))
.append("\" method=\"").append(method.name().toLowerCase()).append("\">");
formHtml.append("<input type=\"hidden\" name=\"biz_content\" value=\'" + bizContent + "\'/>");
formHtml.append("<input type=\"hidden\" name=\"biz_content\" value=\'" ).append( bizContent ).append( "\'/>");
formHtml.append("</form>");
formHtml.append("<script>document.forms['_alipaysubmit_'].submit();</script>");

View File

@@ -508,6 +508,17 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
return null;
}
/**
* 获取支付请求地址
*
* @param transactionType 交易类型
* @return 请求地址
*/
@Override
public String getReqUrl(TransactionType transactionType) {
return null;
}
/**
* 获取biz_content。请求参数的集合 不包含下载账单

View File

@@ -0,0 +1,22 @@
package com.egzosn.pay.common.bean;
/**
* 国家代码
* @author egan
* email egzosn@gmail.com
* date 2019/4/16.22:43
*/
public interface CountryCode {
/**
* 获取国家代码
* @return 国家代码
*/
String getCode();
/**
* 获取国家名称
* @return
*/
String getName();
}

View File

@@ -1,39 +1,22 @@
package com.egzosn.pay.common.bean;
/**
* 货币类型
* @author Actinia
* <pre>
* email hayesfu@qq.com
* create 2017 2017/1/16
* </pre>
* 基础货币类型
* @author egan
* email egzosn@gmail.com
* date 2019/4/16.20:55
*/
public enum CurType {
CNY("人民币"),
USD("美元"),
HKD("港币"),
MOP("澳门元"),
EUR("欧元"),
TWD("新台币"),
KRW("韩元"),
JPY("日元"),
SGD("新加坡元"),
AUD("澳大利亚元");
public interface CurType {
/**
* 币种名称
* 获取货币类型
* @return 货币类型
*/
private String name;
//索引
private int index;
String getType();
/**
* 构造函数
* @param name
* 货币名称
* @return 货币名称
*/
CurType(String name) {
this.name = name;
}
String getName();
}

View File

@@ -0,0 +1,47 @@
package com.egzosn.pay.common.bean;
/**
* 默认的国家地区代码
* @author egan
* email egzosn@gmail.com
* date 2019/4/16.22:43
*/
public enum DefaultCountryCode implements CountryCode{
CHN("中国"),
USA("美国"),
JPN("日本"),
HKG("香港"),
GBR("英国"),
MAC("澳门"),
TWN("中国台湾"),
;
/**
* 国家名称
*/
private String name;
DefaultCountryCode(String name) {
this.name = name;
}
/**
* 获取国家代码
*
* @return 国家代码
*/
@Override
public String getCode() {
return this.name();
}
/**
* 获取国家名称
*
* @return
*/
@Override
public String getName() {
return name;
}
}

View File

@@ -0,0 +1,54 @@
package com.egzosn.pay.common.bean;
/**
* 基础货币类型
* @author Actinia
* <pre>
* email hayesfu@qq.com
* create 2017 2017/1/16
* </pre>
*/
public enum DefaultCurType implements CurType{
CNY("人民币"),
USD("美元"),
HKD("港币"),
MOP("澳门元"),
EUR("欧元"),
TWD("新台币"),
KRW("韩元"),
JPY("日元"),
SGD("新加坡元"),
AUD("澳大利亚元");
/**
* 币种名称
*/
private String name;
/**
* 构造函数
* @param name
*/
DefaultCurType(String name) {
this.name = name;
}
/**
* 获取货币类型
*
* @return 货币类型
*/
@Override
public String getType() {
return this.name();
}
/**
* 货币名称
*
* @return 货币名称
*/
@Override
public String getName() {
return name;
}
}

View File

@@ -12,13 +12,18 @@ import java.math.BigDecimal;
*/
public class TransferOrder {
/**
* 转账批次订单单号
*/
private String batchNo;
/**
* 转账订单单号
*/
private String outNo;
/**
* 收款方账户, 用户openid
* 收款方账户, 用户openid,卡号等等
*/
private String payeeAccount ;
@@ -36,6 +41,11 @@ public class TransferOrder {
* 收款人名称
*/
private String payeeName;
/**
* 收款人地址
*/
private String payeeAddress;
/**
* 备注
*/
@@ -46,10 +56,19 @@ public class TransferOrder {
*/
private Bank bank;
/**
* 收款开户行地址
*/
private String payeeBankAddress;
/**
* 币种
*/
private CurType curType;
/**
* 国家代码
*/
private CountryCode countryCode;
/**
* 转账类型,收款方账户类型,比如支付宝账户或者银行卡
*/
@@ -60,6 +79,14 @@ public class TransferOrder {
*/
private String ip;
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public String getOutNo() {
return outNo;
}
@@ -100,6 +127,14 @@ public class TransferOrder {
this.payeeName = payeeName;
}
public String getPayeeAddress() {
return payeeAddress;
}
public void setPayeeAddress(String payeeAddress) {
this.payeeAddress = payeeAddress;
}
public String getRemark() {
return remark;
}
@@ -116,6 +151,22 @@ public class TransferOrder {
this.bank = bank;
}
public String getPayeeBankAddress() {
return payeeBankAddress;
}
public void setPayeeBankAddress(String payeeBankAddress) {
this.payeeBankAddress = payeeBankAddress;
}
public CountryCode getCountryCode() {
return countryCode;
}
public void setCountryCode(CountryCode countryCode) {
this.countryCode = countryCode;
}
public CurType getCurType() {
return curType;
}

View File

@@ -180,7 +180,7 @@ public class PayoneerPayService extends BasePayService<PayoneerConfigStorage> im
params.put("amount", Util.conversionAmount(order.getPrice()));
params.put("client_reference_id", order.getOutTradeNo());
if (null == order.getCurType()) {
order.setCurType(CurType.USD);
order.setCurType(DefaultCurType.USD);
}
params.put("currency", order.getCurType());
params.put("description", order.getSubject());

View File

@@ -147,9 +147,9 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage>{
public Map<String, Object> orderInfo(PayOrder order) {
Amount amount = new Amount();
if (null == order.getCurType()){
order.setCurType(CurType.USD);
order.setCurType(DefaultCurType.USD);
}
amount.setCurrency(order.getCurType().name());
amount.setCurrency(order.getCurType().getType());
amount.setTotal(Util.conversionAmount(order.getPrice()).toString());
Transaction transaction = new Transaction();
@@ -264,7 +264,11 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage>{
if (null != refundOrder.getRefundAmount() && BigDecimal.ZERO.compareTo( refundOrder.getRefundAmount()) == -1){
Amount amount = new Amount();
amount.setCurrency(refundOrder.getCurType().name());
if(null == refundOrder.getCurType()){
refundOrder.setCurType(DefaultCurType.USD);
}
amount.setCurrency(refundOrder.getCurType().getType());
amount.setTotal(Util.conversionAmount(refundOrder.getRefundAmount()).toString());
request.put("amount", amount);
request.put("description", refundOrder.getDescription());

View File

@@ -96,14 +96,23 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
return this;
}
/**
* 获取支付请求地址
*
* @param transactionType 交易类型
* @return 请求地址
*/
@Override
public String getReqUrl(TransactionType transactionType) {
return (payConfigStorage.isTest() ? TEST_BASE_DOMAIN : RELEASE_BASE_DOMAIN);
}
/**
* 根据是否为沙箱环境进行获取请求地址
*
* @return 请求地址
*/
public String getReqUrl() {
return (payConfigStorage.isTest() ? TEST_BASE_DOMAIN : RELEASE_BASE_DOMAIN);
return getReqUrl(null);
}
public String getFrontTransUrl() {
@@ -677,4 +686,6 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
}
}

View File

@@ -67,7 +67,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
StringBuilder param = new StringBuilder().append("access_token=").append(payConfigStorage.getAccessToken());
String sign = createSign(param.toString() + apbNonce, payConfigStorage.getInputCharset());
param.append("&apb_nonce=").append(apbNonce).append("&sign=").append(sign);
JSONObject json = execute(getUrl(YoudianTransactionType.RESET_LOGIN) + "?" + param.toString(), MethodType.GET, null );
JSONObject json = execute(getReqUrl(YoudianTransactionType.RESET_LOGIN) + "?" + param.toString(), MethodType.GET, null );
int errorcode = json.getIntValue("errorcode");
if (0 == errorcode){
payConfigStorage.updateAccessToken(payConfigStorage.getAccessToken(), 7200);
@@ -99,7 +99,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
String sign = createSign(SignUtils.parameterText(data, "") + apbNonce, payConfigStorage.getInputCharset());
String queryParam = SignUtils.parameterText(data) + "&apb_nonce=" + apbNonce + "&sign=" + sign;
JSONObject json = execute(getUrl(YoudianTransactionType.LOGIN) + "?" + queryParam, MethodType.GET, null);
JSONObject json = execute(getReqUrl(YoudianTransactionType.LOGIN) + "?" + queryParam, MethodType.GET, null);
payConfigStorage.updateAccessToken(json.getString("access_token"), json.getLongValue("viptime"));
return json;
}
@@ -231,7 +231,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
data.put("PayMoney", data.remove("paymoney"));
String params = SignUtils.parameterText(data) + "&apb_nonce=" + apbNonce + "&sign=" + sign;
try {
JSONObject json = execute(getUrl(order.getTransactionType())+ "?" + params, MethodType.GET, null);
JSONObject json = execute(getReqUrl(order.getTransactionType())+ "?" + params, MethodType.GET, null);
//友店比较特殊,需要在下完预订单后,自己存储 order_sn 对应 微信官方文档 out_trade_no
order.setOutTradeNo(json.getString("order_sn"));
return json;
@@ -369,7 +369,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
}
String sign = createSign(SignUtils.parameterText(data, "") + apbNonce, payConfigStorage.getInputCharset());
String queryParam = SignUtils.parameterText(data) + "&apb_nonce=" + apbNonce + "&sign=" + sign;
JSONObject jsonObject = execute(getUrl(YoudianTransactionType.NATIVE_STATUS) + "?" + queryParam, MethodType.GET, null);
JSONObject jsonObject = execute(getReqUrl(YoudianTransactionType.NATIVE_STATUS) + "?" + queryParam, MethodType.GET, null);
return jsonObject;
}
@@ -403,7 +403,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
data.put("refund_fee", refundOrder.getRefundAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
String sign = createSign(SignUtils.parameterText(data, "") + apbNonce, payConfigStorage.getInputCharset());
String queryParam = SignUtils.parameterText(data) + "&apb_nonce=" + apbNonce + "&sign=" + sign;
JSONObject jsonObject = execute(getUrl(YoudianTransactionType.NATIVE_STATUS) + "?" + queryParam, MethodType.GET, null);
JSONObject jsonObject = execute(getReqUrl(YoudianTransactionType.NATIVE_STATUS) + "?" + queryParam, MethodType.GET, null);
return jsonObject;
}
@@ -459,7 +459,7 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
* @param type 交易类型
* @return 请求地址
*/
private String getUrl(TransactionType type){
public String getReqUrl(TransactionType type){
return URL + type.getMethod();
}

View File

@@ -305,7 +305,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> {
String sign = createSign(SignUtils.parameterText(parameters, "&", SIGN, "appId"), payConfigStorage.getInputCharset(), false);
parameters.put(SIGN, sign);
JSONObject result = requestTemplate.postForObject(getUrl(WxTransactionType.GETSIGNKEY), XML.getMap2Xml(parameters), JSONObject.class);
JSONObject result = requestTemplate.postForObject(getReqUrl(WxTransactionType.GETSIGNKEY), XML.getMap2Xml(parameters), JSONObject.class);
if (SUCCESS.equals(result.get(RETURN_CODE))) {
return result.getString("sandbox_signkey");
}

View File

@@ -51,8 +51,8 @@
<module>pay-java-union</module>
<module>pay-java-payoneer</module>
<module>pay-java-paypal</module>
<module>pay-java-demo</module>
<module>pay-java-yiji</module>
<module>pay-java-demo</module>
</modules>