mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-08 03:56:48 +08:00
修复base auth两次请求的问题,对支付配置增加配置参数
This commit is contained in:
@@ -15,6 +15,10 @@ public class PayoneerConfigStorage extends BasePayConfigStorage {
|
||||
* 商户Id
|
||||
*/
|
||||
public String programId;
|
||||
/**
|
||||
* PayoneerPay 用户名
|
||||
*/
|
||||
public String userName;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
@@ -26,6 +30,7 @@ public class PayoneerConfigStorage extends BasePayConfigStorage {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 合作商唯一标识
|
||||
*
|
||||
@@ -37,15 +42,48 @@ public class PayoneerConfigStorage extends BasePayConfigStorage {
|
||||
|
||||
@Override
|
||||
public String getSeller() {
|
||||
return null;
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商户Id
|
||||
* @return 商户Id
|
||||
*/
|
||||
public String getProgramId() {
|
||||
return programId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商户Id
|
||||
* @param programId 商户Id
|
||||
*/
|
||||
public void setProgramId(String programId) {
|
||||
this.programId = programId;
|
||||
}
|
||||
|
||||
/**
|
||||
* PayoneerPay 用户名
|
||||
* @param userName 用户名
|
||||
*/
|
||||
public void setUserName(String userName){
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置PayoneerPay API password
|
||||
* @param apiPassword api密钥
|
||||
*/
|
||||
public void setApiPassword(String apiPassword){
|
||||
setKeyPrivate(apiPassword);
|
||||
}
|
||||
/**
|
||||
* 获取 PayoneerPay API password
|
||||
*/
|
||||
public String getApiPassword(){
|
||||
return getKeyPrivate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.egzosn.pay.payoneer.api;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.api.Callback;
|
||||
import com.egzosn.pay.common.api.PayConfigStorage;
|
||||
import com.egzosn.pay.common.bean.*;
|
||||
import com.egzosn.pay.common.bean.outbuilder.PayTextOutMessage;
|
||||
@@ -12,17 +11,16 @@ 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.common.http.UriVariables;
|
||||
import com.egzosn.pay.payoneer.bean.PayoneerTransactionType;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
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;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* payoneer业务逻辑
|
||||
@@ -62,6 +60,17 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
super(payConfigStorage, configStorage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权请求头
|
||||
* @return 授权请求头
|
||||
*/
|
||||
private HttpHeader authHeader(){
|
||||
|
||||
List<Header> headers = new ArrayList<>();
|
||||
headers.add(new BasicHeader("Authorization", "Basic " + authorizationString(getPayConfigStorage().getSeller(), getPayConfigStorage().getKeyPrivate())));
|
||||
|
||||
return new HttpHeader(headers);
|
||||
}
|
||||
/**
|
||||
* 获取授权页面
|
||||
*
|
||||
@@ -73,6 +82,8 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
public String getAuthorizationPage(String payeeId) {
|
||||
|
||||
HttpStringEntity entity = new HttpStringEntity("{\"payee_id\":\"" + payeeId + "\"}", ContentType.APPLICATION_JSON);
|
||||
//设置 base atuh
|
||||
entity.setHeaders(authHeader());
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.REGISTRATION), entity, JSONObject.class);
|
||||
if (response != null && 0 == response.getIntValue(CODE)) {
|
||||
return response.getString("registration_link");
|
||||
@@ -250,6 +261,8 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
@Override
|
||||
public Map<String, Object> microPay(PayOrder order) {
|
||||
HttpStringEntity entity = new HttpStringEntity(JSON.toJSONString(orderInfo(order)), ContentType.APPLICATION_JSON);
|
||||
//设置 base atuh
|
||||
entity.setHeaders(authHeader());
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.CHARGE), entity, JSONObject.class);
|
||||
if (response != null) {
|
||||
return response;
|
||||
@@ -351,7 +364,13 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType) {
|
||||
JSONObject result = getHttpRequestTemplate().getForObject(getReqUrl(transactionType), JSONObject.class, outTradeNoBillType);
|
||||
MethodType methodType = null;
|
||||
if (transactionType == PayoneerTransactionType.CHARGE_CANCEL) { // 退款
|
||||
methodType = MethodType.POST;
|
||||
}else {
|
||||
methodType = MethodType.GET;
|
||||
}
|
||||
JSONObject result = getHttpRequestTemplate().doExecute(UriVariables.getUri(getReqUrl(transactionType), outTradeNoBillType), authHeader() ,JSONObject.class, methodType);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -375,6 +394,7 @@ public class PayoneerPayService extends BasePayService implements AdvancedPaySer
|
||||
info.put("payout_date", DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
|
||||
info.put("group_id", order.getPayerName());
|
||||
HttpStringEntity entity = new HttpStringEntity(JSON.toJSONString(info), ContentType.APPLICATION_JSON);
|
||||
entity.setHeaders(authHeader());
|
||||
JSONObject response = getHttpRequestTemplate().postForObject(getReqUrl(PayoneerTransactionType.PAYOUTS), entity, JSONObject.class);
|
||||
return response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user