mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-07 19:46:15 +08:00
Payoneer 支付
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
package com.egzosn.pay.payoneer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
import com.egzosn.pay.payoneer.bean.PayoneerRequestBean;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.AuthCache;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.auth.BasicScheme;
|
||||
import org.apache.http.impl.client.BasicAuthCache;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* An example of HttpClient can be customized to authenticate
|
||||
* preemptively using BASIC scheme.
|
||||
* <b>
|
||||
* Generally, preemptive authentication can be considered less
|
||||
* secure than a response to an authentication challenge
|
||||
* and therefore discouraged.
|
||||
*/
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/payees/registration-link");
|
||||
URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/charges");
|
||||
HttpHost target = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
|
||||
HttpPost httpPost = new HttpPost(uri.toString());
|
||||
|
||||
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||
credsProvider.setCredentials(
|
||||
new AuthScope(uri.getHost(), uri.getPort()),
|
||||
new UsernamePasswordCredentials("Huodull6190", "12BkDT8152Zj"));
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.custom()
|
||||
.setDefaultCredentialsProvider(credsProvider)
|
||||
.build();
|
||||
try {
|
||||
|
||||
// Create AuthCache instance
|
||||
AuthCache authCache = new BasicAuthCache();
|
||||
// Generate BASIC scheme object and add it to the local
|
||||
// auth cache
|
||||
BasicScheme basicAuth = new BasicScheme();
|
||||
authCache.put(target, basicAuth);
|
||||
|
||||
// Add AuthCache to the execution context
|
||||
HttpClientContext localContext = HttpClientContext.create();
|
||||
// localContext.setCredentialsProvider(credsProvider);
|
||||
localContext.setAuthCache(authCache);
|
||||
|
||||
// BasicHttpContext localContext = new BasicHttpContext();
|
||||
// localContext.setAttribute(ClientContext.AUTH_CACHE,authCache);
|
||||
|
||||
// PayoneerRequestBean bean = new PayoneerRequestBean("666");
|
||||
PayoneerRequestBean bean = new PayoneerRequestBean("6666","1","566002", CurType.USD,"66");
|
||||
StringEntity entity = new StringEntity(JSON.toJSONString(bean), ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
|
||||
System.out.println("Executing request " + httpPost.getRequestLine() + " to target " + target);
|
||||
for (int i = 0; i < 1; i++) {
|
||||
CloseableHttpResponse response = httpclient.execute(target, httpPost, localContext);
|
||||
try {
|
||||
System.out.println("----------------------------------------");
|
||||
System.out.println(response.getStatusLine());
|
||||
System.out.println(EntityUtils.toString(response.getEntity()));
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
httpclient.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 高级支付接口
|
||||
* @author Actinia
|
||||
* @email hayesfu@qq.com
|
||||
* @date 2018/1/18
|
||||
*
|
||||
*/
|
||||
|
||||
public interface AdvancedPayService extends PayService {
|
||||
/**
|
||||
* 获取授权页面
|
||||
* @param payeeId 收款id
|
||||
* @return 返回请求结果
|
||||
*/
|
||||
String getAuthorizationPage(String payeeId);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.egzosn.pay.payoneer.api;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.AdvancedPayService;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.api.Callback;
|
||||
import com.egzosn.pay.common.api.PayConfigStorage;
|
||||
@@ -10,66 +10,41 @@ 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.payoneer.bean.PayoneerRequestBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.egzosn.pay.common.http.HttpStringEntity;
|
||||
import com.egzosn.pay.payoneer.bean.PayoneerTransactionType;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @descrption payoneer业务逻辑
|
||||
* payoneer业务逻辑
|
||||
*
|
||||
* @author Actinia
|
||||
* @email hayesfu@qq.com
|
||||
* @date 2018-01-19
|
||||
* <pre>
|
||||
* email hayesfu@qq.com
|
||||
* date 2018-01-19
|
||||
* </pre>
|
||||
*/
|
||||
public class PayoneerPayService extends BasePayService implements AdvancedPayService {
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
protected final Log log = LogFactory.getLog(PayoneerPayService.class);
|
||||
/**
|
||||
* 测试地址
|
||||
*/
|
||||
public final static String SANDBOX_DOMAIN= "https://api.sandbox.payoneer.com/v2/programs/";
|
||||
|
||||
public final static String SANDBOX_DOMAIN = "https://api.sandbox.payoneer.com/v2/programs/";
|
||||
/**
|
||||
* 正式地址
|
||||
*/
|
||||
public final static String RELEASE_DOMAIN = "https://api.payoneer.com/v2/programs/";
|
||||
|
||||
/**
|
||||
* 授权登录url
|
||||
* https://api.sandbox.payoneer.com/v2/programs/{Program_Id}/payees/login-link
|
||||
* 响应状态码
|
||||
*/
|
||||
public String urlLoginLink = payConfigStorage.getPid()+"/payees/login-link";
|
||||
|
||||
private final static String CODE = "code";
|
||||
/**
|
||||
* 授权注册url
|
||||
* https://api.sandbox.payoneer.com/v2/programs/{Program_Id}/payees/registration-link
|
||||
* 响应状态码
|
||||
*/
|
||||
public String urlRegistrationLink = payConfigStorage.getPid()+"/payees/registration-link";
|
||||
|
||||
/**
|
||||
* 收款url
|
||||
* https://api.sandbox.payoneer.com/v2/programs/{Program_Id}/charges
|
||||
*/
|
||||
public String urlChargesLink = payConfigStorage.getPid()+"/charges";
|
||||
|
||||
/**
|
||||
* 取消收款url
|
||||
* https://api.sandbox.payoneer.com/v2/programs/{Program_Id}/charges/{client_reference_id}/cancel
|
||||
*/
|
||||
public String urlCancelChargesLink = payConfigStorage.getPid()+"/charges/%s/cancel";
|
||||
|
||||
/**
|
||||
* 查看收款状态
|
||||
* https://api.sandbox.payoneer.com/v2/programs/{Program_Id}/charges/{client_reference_id}/status
|
||||
*/
|
||||
public String urlStatusLink = payConfigStorage.getPid()+"/charges/%s/status";
|
||||
private final static String OUT_TRADE_NO = "{client_reference_id}";
|
||||
|
||||
|
||||
public PayoneerPayService(PayConfigStorage payConfigStorage) {
|
||||
@@ -83,46 +58,33 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
/**
|
||||
* 获取授权页面
|
||||
*
|
||||
* @param payeeId 收款id
|
||||
* @param authPageType 授权类型
|
||||
* @param payeeId 收款id
|
||||
*
|
||||
* @return 返回请求结果
|
||||
*/
|
||||
@Override
|
||||
public String getAuthorizationPage(String payeeId, AuthPageType authPageType) {
|
||||
PayoneerRequestBean params = new PayoneerRequestBean();
|
||||
params.setPayeeId(payeeId);
|
||||
JSONObject response = getHttpRequestTemplate().postForObject("login".equals(authPageType.name())?getUrlLoginLink():getUrlRegistrationLink(),params,JSONObject.class);
|
||||
if(response != null && "0".equals(response.getString("code"))){
|
||||
return response.getString(authPageType.name()+"_link");
|
||||
}
|
||||
public String getAuthorizationPage(String payeeId) {
|
||||
|
||||
throw new PayErrorException(new PayException("fail", "Payoneer获取授权页面失败,原因:"+response.getString("hint"), response.toJSONString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起授权
|
||||
* @param payeeId 授权id(收款id)
|
||||
* @param payOrder 订单信息
|
||||
* @return 返回请求结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String ,Object> charges(String payeeId,PayOrder payOrder){
|
||||
PayoneerRequestBean params = new PayoneerRequestBean(payeeId,payOrder.getPrice().toString(),payOrder.getOutTradeNo(),payOrder.getCurType(),payOrder.getBody());
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getUrlChargesLink(),params,JSONObject.class);
|
||||
if(response != null && "0".equals(response.getString("code"))){
|
||||
return response;
|
||||
HttpStringEntity entity = new HttpStringEntity("{\"payee_id\":\"" + payeeId + "\"}", ContentType.APPLICATION_JSON);
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.registration), entity, JSONObject.class);
|
||||
if (response != null && 0 == response.getIntValue(CODE)) {
|
||||
return response.getString("registration_link");
|
||||
}
|
||||
throw new PayErrorException(new PayException("fail", "Payoneer申请收款失败,原因:"+response.getString("hint"), response.toJSONString()));
|
||||
throw new PayErrorException(new PayException("fail", "Payoneer获取授权页面失败,原因:" + response.getString("hint"), response.toJSONString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调校验
|
||||
*
|
||||
* @param params 回调回来的参数集
|
||||
*
|
||||
* @return 签名校验 true通过
|
||||
*/
|
||||
@Override
|
||||
public boolean verify(Map<String, Object> params) {
|
||||
if (params != null && 0 == Integer.parseInt(params.get(CODE).toString())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,11 +93,12 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param params 参数集
|
||||
* @param sign 签名原文
|
||||
*
|
||||
* @return 签名校验 true通过
|
||||
*/
|
||||
@Override
|
||||
public boolean signVerify(Map<String, Object> params, String sign) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,24 +106,35 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* 校验数据来源
|
||||
*
|
||||
* @param id 业务id, 数据的真实性.
|
||||
*
|
||||
* @return true通过
|
||||
*/
|
||||
@Override
|
||||
public boolean verifySource(String id) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回创建的订单信息
|
||||
*
|
||||
* @param order 支付订单
|
||||
*
|
||||
* @return 订单信息
|
||||
* @see PayOrder 支付订单信息
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> orderInfo(PayOrder order) {
|
||||
Map<String, Object> params = new HashMap<>(5);
|
||||
params.put("payee_id", order.getAuthCode());
|
||||
params.put("amount", order.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
params.put("client_reference_id", order.getOutTradeNo());
|
||||
if (null == order.getCurType()) {
|
||||
order.setCurType(CurType.USD);
|
||||
}
|
||||
params.put("currency", order.getCurType());
|
||||
params.put("description", order.getSubject());
|
||||
|
||||
return null;
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,6 +142,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param content 需要签名的内容
|
||||
* @param characterEncoding 字符编码
|
||||
*
|
||||
* @return 签名
|
||||
*/
|
||||
@Override
|
||||
@@ -175,35 +150,13 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建签名
|
||||
*
|
||||
* @param content 需要签名的内容
|
||||
* @param characterEncoding 字符编码
|
||||
* @return 签名
|
||||
*/
|
||||
@Override
|
||||
public String createSign(Map<String, Object> content, String characterEncoding) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将请求参数或者请求流转化为 Map
|
||||
*
|
||||
* @param parameterMap 请求参数
|
||||
* @param is 请求流
|
||||
* @return 获得回调的请求参数
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getParameter2Map(Map<String, String[]> parameterMap, InputStream is) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取输出消息,用户返回给支付端
|
||||
*
|
||||
* @param code 状态
|
||||
* @param message 消息
|
||||
*
|
||||
* @return 返回输出消息
|
||||
*/
|
||||
@Override
|
||||
@@ -216,6 +169,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* 主要用于拦截器中返回
|
||||
*
|
||||
* @param payMessage 支付回调消息
|
||||
*
|
||||
* @return 返回输出消息
|
||||
*/
|
||||
@Override
|
||||
@@ -228,6 +182,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param orderInfo 发起支付的订单信息
|
||||
* @param method 请求方式 "post" "get",
|
||||
*
|
||||
* @return 获取输出消息,用户返回给支付端, 针对于web端
|
||||
* @see MethodType 请求类型
|
||||
*/
|
||||
@@ -240,6 +195,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* 获取输出二维码,用户返回给支付端,
|
||||
*
|
||||
* @param order 发起支付的订单信息
|
||||
*
|
||||
* @return 返回图片信息,支付时需要的
|
||||
*/
|
||||
@Override
|
||||
@@ -251,11 +207,17 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* 刷卡付,pos主动扫码付款(条码付)
|
||||
*
|
||||
* @param order 发起支付的订单信息
|
||||
*
|
||||
* @return 返回支付结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> microPay(PayOrder order) {
|
||||
return null;
|
||||
HttpStringEntity entity = new HttpStringEntity(JSON.toJSONString(orderInfo(order)), ContentType.APPLICATION_JSON);
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.charge), entity, JSONObject.class);
|
||||
if (response != null && 0 == response.getIntValue(CODE)) {
|
||||
return response;
|
||||
}
|
||||
throw new PayErrorException(new PayException("fail", "Payoneer申请收款失败,原因:" + response.getString("hint"), response.toJSONString()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,11 +225,18 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
*
|
||||
* @return 返回查询回来的结果集,支付方原值返回
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> query(String tradeNo, String outTradeNo) {
|
||||
return null;
|
||||
|
||||
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.chargeStatus).replace(OUT_TRADE_NO, outTradeNo), new HttpStringEntity("", ContentType.APPLICATION_JSON), JSONObject.class);
|
||||
|
||||
if (0 != result.getIntValue(CODE)) {
|
||||
throw new PayErrorException(new PayException(result.getString(CODE), result.getString("description"), result.toJSONString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,11 +245,12 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回查询回来的结果集
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String tradeNo, String outTradeNo, Callback<T> callback) {
|
||||
return null;
|
||||
return callback.perform(query(tradeNo, outTradeNo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,11 +258,18 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
*
|
||||
* @return 返回支付方交易关闭后的结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> close(String tradeNo, String outTradeNo) {
|
||||
return null;
|
||||
|
||||
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.chargeCancel).replace(OUT_TRADE_NO, outTradeNo), new HttpStringEntity("", ContentType.APPLICATION_JSON), JSONObject.class);
|
||||
|
||||
if (0 != result.getIntValue(CODE)) {
|
||||
throw new PayErrorException(new PayException(result.getString(CODE), result.getString("description"), result.toJSONString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,11 +278,12 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方交易关闭后的结果
|
||||
*/
|
||||
@Override
|
||||
public <T> T close(String tradeNo, String outTradeNo, Callback<T> callback) {
|
||||
return null;
|
||||
return callback.perform(close(tradeNo, outTradeNo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,12 +294,13 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param outTradeNo 商户单号
|
||||
* @param refundAmount 退款金额
|
||||
* @param totalAmount 总金额
|
||||
*
|
||||
* @return 返回支付方申请退款后的结果
|
||||
* @see #refund(RefundOrder)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount) {
|
||||
return null;
|
||||
return close(tradeNo, outTradeNo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,23 +312,25 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param refundAmount 退款金额
|
||||
* @param totalAmount 总金额
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方申请退款后的结果
|
||||
* @see #refund(RefundOrder, Callback)
|
||||
*/
|
||||
@Override
|
||||
public <T> T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback<T> callback) {
|
||||
return null;
|
||||
return callback.perform(close(tradeNo, outTradeNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款接口
|
||||
*
|
||||
* @param refundOrder 退款订单信息
|
||||
*
|
||||
* @return 返回支付方申请退款后的结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> refund(RefundOrder refundOrder) {
|
||||
return null;
|
||||
return close(refundOrder.getTradeNo(), refundOrder.getOutTradeNo());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,11 +338,12 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param refundOrder 退款订单信息
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方申请退款后的结果
|
||||
*/
|
||||
@Override
|
||||
public <T> T refund(RefundOrder refundOrder, Callback<T> callback) {
|
||||
return null;
|
||||
return close(refundOrder.getTradeNo(), refundOrder.getOutTradeNo(), callback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,6 +351,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
*
|
||||
* @return 返回支付方查询退款后的结果
|
||||
*/
|
||||
@Override
|
||||
@@ -382,6 +365,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param tradeNo 支付平台订单号
|
||||
* @param outTradeNo 商户单号
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方查询退款后的结果
|
||||
*/
|
||||
@Override
|
||||
@@ -394,10 +378,12 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
*
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Override
|
||||
public Object downloadbill(Date billDate, String billType) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -407,6 +393,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param billDate 账单时间:具体请查看对应支付平台
|
||||
* @param billType 账单类型,具体请查看对应支付平台
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Override
|
||||
@@ -421,6 +408,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @param outTradeNoBillType 商户单号或者 账单类型
|
||||
* @param transactionType 交易类型
|
||||
* @param callback 处理器
|
||||
*
|
||||
* @return 返回支付方对应接口的结果
|
||||
*/
|
||||
@Override
|
||||
@@ -428,23 +416,14 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUrlLoginLink() {
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlLoginLink;
|
||||
/**
|
||||
* 根据是否为沙箱环境进行获取请求地址
|
||||
*
|
||||
* @return 请求地址
|
||||
*/
|
||||
public String getReqUrl(TransactionType type) {
|
||||
return (payConfigStorage.isTest() ? SANDBOX_DOMAIN : RELEASE_DOMAIN) + payConfigStorage.getPid() + "/" + type.getMethod();
|
||||
}
|
||||
|
||||
public String getUrlRegistrationLink() {
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlRegistrationLink;
|
||||
}
|
||||
|
||||
public String getUrlChargesLink() {
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlChargesLink;
|
||||
}
|
||||
|
||||
public String getUrlCancelChargesLink() {
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlCancelChargesLink;
|
||||
}
|
||||
|
||||
public String getUrlStatusLink() {
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlStatusLink;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,24 @@ import com.egzosn.pay.common.bean.TransactionType;
|
||||
*/
|
||||
public enum PayoneerTransactionType implements TransactionType {
|
||||
|
||||
charge("charge");
|
||||
/**
|
||||
* 收款
|
||||
*/
|
||||
registration("payees/registration-link"),
|
||||
/**
|
||||
* 收款
|
||||
*/
|
||||
charge("charges"),
|
||||
/**
|
||||
* 取消收款(取消订单与退款)
|
||||
*/
|
||||
chargeCancel("charges/{client_reference_id}/cancel"),
|
||||
/**
|
||||
* 查询收款订单与订单状态
|
||||
*/
|
||||
chargeStatus("charges/{client_reference_id}/status")
|
||||
;
|
||||
|
||||
private String method;
|
||||
|
||||
PayoneerTransactionType(String method) {
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
import com.egzosn.pay.payoneer.bean.PayoneerRequestBean;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.AuthCache;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.auth.BasicScheme;
|
||||
import org.apache.http.impl.client.BasicAuthCache;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -12,8 +31,60 @@ import com.egzosn.pay.payoneer.bean.PayoneerRequestBean;
|
||||
*/
|
||||
public class PayTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
// 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");
|
||||
HttpHost target = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
|
||||
HttpPost httpPost = new HttpPost(uri.toString());
|
||||
|
||||
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||
credsProvider.setCredentials(
|
||||
new AuthScope(uri.getHost(), uri.getPort()),
|
||||
new UsernamePasswordCredentials("Huodull6190", "12BkDT8152Zj"));
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.custom()
|
||||
.setDefaultCredentialsProvider(credsProvider)
|
||||
.build();
|
||||
try {
|
||||
|
||||
// Create AuthCache instance
|
||||
AuthCache authCache = new BasicAuthCache();
|
||||
// Generate BASIC scheme object and add it to the local
|
||||
// auth cache
|
||||
BasicScheme basicAuth = new BasicScheme();
|
||||
authCache.put(target, basicAuth);
|
||||
|
||||
// Add AuthCache to the execution context
|
||||
HttpClientContext localContext = HttpClientContext.create();
|
||||
// localContext.setCredentialsProvider(credsProvider);
|
||||
localContext.setAuthCache(authCache);
|
||||
|
||||
// BasicHttpContext localContext = new BasicHttpContext();
|
||||
// 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");
|
||||
// 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);
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
|
||||
System.out.println("Executing request " + httpPost.getRequestLine() + " to target " + target);
|
||||
for (int i = 0; i < 1; i++) {
|
||||
CloseableHttpResponse response = httpclient.execute(target, httpPost, localContext);
|
||||
try {
|
||||
System.out.println("----------------------------------------");
|
||||
System.out.println(response.getStatusLine());
|
||||
System.out.println(EntityUtils.toString(response.getEntity()));
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
httpclient.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
package com.egzosn.pay.payoneer.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
|
||||
@@ -19,7 +17,10 @@ public class PayoneerRequestBean {
|
||||
this.payeeId = payeeId;
|
||||
this.amount = amount;
|
||||
this.clientReferenceId = clientReferenceId;
|
||||
this.currency = currency;
|
||||
if (null == currency){
|
||||
currency = CurType.USD;
|
||||
}
|
||||
this.currency = currency;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user