|
@@ -2,6 +2,11 @@ package com.yonge.cooleshow.biz.dal.sdk;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.alipay.api.AlipayApiException;
|
|
|
|
+import com.alipay.api.AlipayClient;
|
|
|
|
+import com.alipay.api.DefaultAlipayClient;
|
|
|
|
+import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
|
|
|
+import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
import com.huifu.adapay.model.Payment;
|
|
import com.huifu.adapay.model.Payment;
|
|
import com.huifu.adapay.model.PaymentConfirm;
|
|
import com.huifu.adapay.model.PaymentConfirm;
|
|
@@ -17,6 +22,7 @@ import com.yonge.toolset.utils.http.HttpUtil;
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -25,6 +31,8 @@ import java.util.*;
|
|
@Component
|
|
@Component
|
|
public class PaymentSdk {
|
|
public class PaymentSdk {
|
|
private final static Logger log = LoggerFactory.getLogger(PaymentSdk.class);
|
|
private final static Logger log = LoggerFactory.getLogger(PaymentSdk.class);
|
|
|
|
+ @Autowired
|
|
|
|
+ private AlipayClient alipayClient;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 执行一个支付交易
|
|
* 执行一个支付交易
|
|
@@ -177,6 +185,24 @@ public class PaymentSdk {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public HttpResponseResult<AlipaySystemOauthTokenResponse> getAliToken(String authorization_code) {
|
|
|
|
+ AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
|
|
|
+ request.setGrantType("authorization_code");
|
|
|
|
+ request.setCode(authorization_code);
|
|
|
|
+ AlipaySystemOauthTokenResponse response = null;
|
|
|
|
+ try {
|
|
|
|
+ response = alipayClient.execute(request);
|
|
|
|
+ if (response.isSuccess()) {
|
|
|
|
+ return HttpResponseResult.succeed(response);
|
|
|
|
+ } else {
|
|
|
|
+ return HttpResponseResult.failed(response.getMsg());
|
|
|
|
+ }
|
|
|
|
+ } catch (AlipayApiException e) {
|
|
|
|
+ log.error("请求支付宝获取token异常,参数{},code is {},msg is {}", authorization_code, e.getErrCode(), e.getErrMsg());
|
|
|
|
+ return HttpResponseResult.failed(e.getErrMsg());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/*
|
|
/*
|
|
public static Map<String, Object> queryList(Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
|
|
public static Map<String, Object> queryList(Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
|
|
Map<String, Object> paymentParams = new HashMap<>();
|
|
Map<String, Object> paymentParams = new HashMap<>();
|