mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-06-09 19:02:19 +08:00
增加订单付款后的校验
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package com.egzosn.pay.payoneer.api;
|
||||
|
||||
import com.egzosn.pay.common.api.PayService;
|
||||
import com.egzosn.pay.common.bean.AuthPageType;
|
||||
import com.egzosn.pay.common.bean.PayOrder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -10,9 +10,13 @@ import com.egzosn.pay.common.bean.outbuilder.PayTextOutMessage;
|
||||
import com.egzosn.pay.common.bean.result.PayException;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import com.egzosn.pay.common.http.HttpConfigStorage;
|
||||
import com.egzosn.pay.common.http.HttpHeader;
|
||||
import com.egzosn.pay.common.http.HttpStringEntity;
|
||||
import com.egzosn.pay.payoneer.bean.PayoneerTransactionType;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@@ -44,7 +48,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
/**
|
||||
* 响应状态码
|
||||
*/
|
||||
private final static String OUT_TRADE_NO = "{client_reference_id}";
|
||||
private final static String OUT_TRADE_NO = "client_reference_id";
|
||||
|
||||
|
||||
public PayoneerPayService(PayConfigStorage payConfigStorage) {
|
||||
@@ -83,9 +87,11 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
@Override
|
||||
public boolean verify(Map<String, Object> params) {
|
||||
if (params != null && 0 == Integer.parseInt(params.get(CODE).toString())) {
|
||||
return true;
|
||||
if (params.containsKey(OUT_TRADE_NO)){
|
||||
return verifySource((String) params.get(OUT_TRADE_NO));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,13 +111,14 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* 支付宝需要,微信是否也需要再次校验来源,进行订单查询
|
||||
* 校验数据来源
|
||||
*
|
||||
* @param id 业务id, 数据的真实性.
|
||||
* @param outTradeNo 业务id, 数据的真实性.
|
||||
*
|
||||
* @return true通过
|
||||
*/
|
||||
@Override
|
||||
public boolean verifySource(String id) {
|
||||
return true;
|
||||
public boolean verifySource(String outTradeNo) {
|
||||
Map<String, Object> data = query(null, outTradeNo);
|
||||
return "DONE".equals(data.get("status"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,12 +237,10 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> query(String tradeNo, String outTradeNo) {
|
||||
|
||||
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.chargeStatus).replace(OUT_TRADE_NO, outTradeNo), new HttpStringEntity("", ContentType.APPLICATION_JSON), JSONObject.class);
|
||||
|
||||
if (0 != result.getIntValue(CODE)) {
|
||||
JSONObject result = getHttpRequestTemplate().getForObject(getReqUrl(PayoneerTransactionType.chargeStatus), JSONObject.class, outTradeNo);
|
||||
/* if (0 != result.getIntValue(CODE)) {
|
||||
throw new PayErrorException(new PayException(result.getString(CODE), result.getString("description"), result.toJSONString()));
|
||||
}
|
||||
}*/
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -264,11 +269,11 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
@Override
|
||||
public Map<String, Object> close(String tradeNo, String outTradeNo) {
|
||||
|
||||
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.chargeCancel).replace(OUT_TRADE_NO, outTradeNo), new HttpStringEntity("", ContentType.APPLICATION_JSON), JSONObject.class);
|
||||
JSONObject result = getHttpRequestTemplate().getForObject(getReqUrl(PayoneerTransactionType.chargeCancel), JSONObject.class, outTradeNo);
|
||||
|
||||
if (0 != result.getIntValue(CODE)) {
|
||||
/* if (0 != result.getIntValue(CODE)) {
|
||||
throw new PayErrorException(new PayException(result.getString(CODE), result.getString("description"), result.toJSONString()));
|
||||
}
|
||||
}*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
import com.egzosn.pay.common.util.sign.encrypt.Base64;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
@@ -32,6 +33,13 @@ import java.util.UUID;
|
||||
public class PayTest {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
if (1==1){
|
||||
|
||||
String auth = Base64.encode("Huodull6190:12BkDT8152Zj".getBytes());
|
||||
System.out.println(auth);
|
||||
return;
|
||||
}
|
||||
// URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/payees/registration-link");
|
||||
// https://api.sandbox.payoneer.com/v2/programs/100086190/payees/registration-link
|
||||
URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/charges");
|
||||
@@ -64,7 +72,8 @@ public class PayTest {
|
||||
// localContext.setAttribute(ClientContext.AUTH_CACHE,authCache);
|
||||
|
||||
// PayoneerRequestBean bean = new PayoneerRequestBean("666");
|
||||
PayoneerRequestBean bean = new PayoneerRequestBean("asdfg11213","1.01", UUID.randomUUID().toString().replace("-", ""), CurType.USD,"huodull order");
|
||||
String referenceId = UUID.randomUUID().toString().replace("-", "");
|
||||
PayoneerRequestBean bean = new PayoneerRequestBean("8a2950f959043699015904453b330057","1.01", referenceId, CurType.USD,"huodull order");
|
||||
// PayoneerRequestBean bean = JSON.parseObject("{\"amount\":\"1.00\",\"client_reference_id\":\""+ System.nanoTime()+"\",\"currency\":\"USD\",\"description\":\"aaabb\",\"payee_id\":\"asdfg13\"}", PayoneerRequestBean.class);
|
||||
System.out.println(JSON.toJSONString(bean));
|
||||
StringEntity entity = new StringEntity(JSON.toJSONString(bean), ContentType.APPLICATION_JSON);
|
||||
|
||||
Reference in New Issue
Block a user