发起支付简化交易类型,方法能够确定交易类型的全部以方法为基准,如果自行设置了但发现不一样就报错提示

This commit is contained in:
egzosn
2019-12-08 21:01:23 +08:00
parent 99895bf540
commit 9c447db949
8 changed files with 84 additions and 34 deletions

View File

@@ -379,6 +379,18 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
return null;
}
@Override
public String toPay(PayOrder order) {
if (null == order.getTransactionType()){
order.setTransactionType(UnionTransactionType.WEB);
}else if (UnionTransactionType.WEB != order.getTransactionType() && UnionTransactionType.WAP != order.getTransactionType() && UnionTransactionType.B2B != order.getTransactionType()){
throw new PayErrorException(new PayException("-1", "错误的交易类型:" + order.getTransactionType()));
}
return super.toPay(order);
}
/**
* 获取输出二维码,用户返回给支付端,
*
@@ -387,6 +399,7 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
*/
@Override
public String getQrPay(PayOrder order) {
order.setTransactionType(UnionTransactionType.APPLY_QR_CODE);
Map<String, Object> params = orderInfo(order);
String responseStr = getHttpRequestTemplate().postForObject(this.getBackTransUrl(), params, String.class);
Map<String, Object> response = UriVariables.getParametersToMap(responseStr);
@@ -411,6 +424,7 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
*/
@Override
public Map<String, Object> microPay(PayOrder order) {
order.setTransactionType(UnionTransactionType.CONSUME);
Map<String, Object> params = orderInfo(order);
String responseStr = getHttpRequestTemplate().postForObject(this.getBackTransUrl(), params, String.class);
return UriVariables.getParametersToMap(responseStr);