mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-19 07:31:36 +08:00
1.Payoneer 接口初步完成
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.egzosn.pay.common.http;
|
||||
package com.egzosn.pay.payoneer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.http.HttpEntity;
|
||||
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;
|
||||
@@ -32,14 +33,19 @@ import java.net.URI;
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
URI uri = URI.create("https://api.sandbox.payoneer.com/v2/programs/100086190/payees/login-link");
|
||||
// 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(target.getHostName(), target.getPort()),
|
||||
new AuthScope(uri.getHost(), uri.getPort()),
|
||||
new UsernamePasswordCredentials("Huodull6190", "12BkDT8152Zj"));
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.custom()
|
||||
.setDefaultCredentialsProvider(credsProvider).build();
|
||||
.setDefaultCredentialsProvider(credsProvider)
|
||||
.build();
|
||||
try {
|
||||
|
||||
// Create AuthCache instance
|
||||
@@ -51,14 +57,20 @@ public class Test {
|
||||
|
||||
// Add AuthCache to the execution context
|
||||
HttpClientContext localContext = HttpClientContext.create();
|
||||
// localContext.setCredentialsProvider(credsProvider);
|
||||
localContext.setAuthCache(authCache);
|
||||
|
||||
HttpPost httpPost = new HttpPost("https://api.sandbox.payoneer.com/v2/programs/100086190/payees/login-link");
|
||||
StringEntity entity = new StringEntity(JSON.toJSONString(Pay), ContentType.APPLICATION_JSON);
|
||||
// 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);
|
||||
|
||||
|
||||
httpPost.setEntity();
|
||||
System.out.println("Executing request " + httpPost.getRequestLine() + " to target " + target);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 1; i++) {
|
||||
CloseableHttpResponse response = httpclient.execute(target, httpPost, localContext);
|
||||
try {
|
||||
System.out.println("----------------------------------------");
|
||||
|
||||
@@ -106,8 +106,8 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
* @return 返回请求结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String ,Object> charge(String payeeId,PayOrder payOrder){
|
||||
PayoneerRequestBean params = new PayoneerRequestBean(payeeId,payOrder.getPrice(),payOrder.getOutTradeNo(),payOrder.getCurType(),payOrder.getBody());
|
||||
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;
|
||||
@@ -429,22 +429,22 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
}
|
||||
|
||||
public String getUrlLoginLink() {
|
||||
return payConfigStorage.isTest()?SANDBOX_DOMAIN+urlLoginLink:RELEASE_DOMAIN+urlLoginLink;
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlLoginLink;
|
||||
}
|
||||
|
||||
public String getUrlRegistrationLink() {
|
||||
return payConfigStorage.isTest()?SANDBOX_DOMAIN+urlRegistrationLink:RELEASE_DOMAIN+urlRegistrationLink;
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlRegistrationLink;
|
||||
}
|
||||
|
||||
public String getUrlChargesLink() {
|
||||
return payConfigStorage.isTest()?SANDBOX_DOMAIN+urlChargesLink:RELEASE_DOMAIN+urlChargesLink;
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlChargesLink;
|
||||
}
|
||||
|
||||
public String getUrlCancelChargesLink() {
|
||||
return payConfigStorage.isTest()?SANDBOX_DOMAIN+urlCancelChargesLink:RELEASE_DOMAIN+urlCancelChargesLink;
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlCancelChargesLink;
|
||||
}
|
||||
|
||||
public String getUrlStatusLink() {
|
||||
return payConfigStorage.isTest()?SANDBOX_DOMAIN+urlStatusLink:RELEASE_DOMAIN+urlStatusLink;
|
||||
return (payConfigStorage.isTest()?SANDBOX_DOMAIN:RELEASE_DOMAIN)+urlStatusLink;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.egzosn.pay.payoneer.bean;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Fuzx
|
||||
* @create 2018 2018/1/22 0022
|
||||
@@ -14,7 +12,10 @@ public class PayoneerRequestBean {
|
||||
|
||||
}
|
||||
|
||||
public PayoneerRequestBean(String payeeId, BigDecimal amount, String clientReferenceId, CurType currency, String description) {
|
||||
public PayoneerRequestBean(String payeeId) {
|
||||
this.payeeId = payeeId;
|
||||
}
|
||||
public PayoneerRequestBean(String payeeId, String amount, String clientReferenceId, CurType currency, String description) {
|
||||
this.payeeId = payeeId;
|
||||
this.amount = amount;
|
||||
this.clientReferenceId = clientReferenceId;
|
||||
@@ -30,7 +31,7 @@ public class PayoneerRequestBean {
|
||||
/**
|
||||
* 收款金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
private String amount;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
@@ -53,11 +54,11 @@ public class PayoneerRequestBean {
|
||||
this.payeeId = payeeId;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user