|
@@ -3,10 +3,7 @@ package com.szwl.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.szwl.constant.AirwallexConstant;
|
|
|
-import com.szwl.model.bean.PaymentIntent;
|
|
|
-import com.szwl.model.bean.PaymentIntentRequestBody;
|
|
|
import com.szwl.model.bo.R;
|
|
|
-import com.szwl.model.entity.TOrderAbroad;
|
|
|
import com.szwl.model.utils.HttpClientSslUtils;
|
|
|
import com.szwl.service.AirwallexService;
|
|
|
import com.szwl.service.TOrderAbroadService;
|
|
@@ -15,13 +12,9 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.apache.http.message.BasicHeader;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.sql.Array;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -109,6 +102,9 @@ public class AirwallexServiceImpl implements AirwallexService {
|
|
|
String paymentIntentId = (String) responseMap.get("id");
|
|
|
String clientSecret = (String) responseMap.get("client_secret");
|
|
|
|
|
|
+ // 把 paymentIntentId 保存到数据库
|
|
|
+
|
|
|
+
|
|
|
String env = AirwallexConstant.ENV;
|
|
|
String mode = AirwallexConstant.MODE;
|
|
|
|
|
@@ -118,7 +114,7 @@ public class AirwallexServiceImpl implements AirwallexService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String createARefund(String requestId) {
|
|
|
+ public String createARefund(String requestId, String paymentIntentId) {
|
|
|
|
|
|
// 请求头
|
|
|
String url = AirwallexConstant.url + "/api/v1/pa/refunds/create";
|
|
@@ -131,11 +127,12 @@ public class AirwallexServiceImpl implements AirwallexService {
|
|
|
bodyMap.put("request_id", requestId);
|
|
|
// bodyMap.put("amount", amount); // 退款金额
|
|
|
// bodyMap.put("reason", reason); // 退款原因
|
|
|
+ bodyMap.put("payment_intent_id", paymentIntentId);
|
|
|
String data = JSON.toJSONString(bodyMap);
|
|
|
|
|
|
String resp = null;
|
|
|
try {
|
|
|
- resp = HttpClientSslUtils.doPost(url, data, ContentType.APPLICATION_JSON, headers);
|
|
|
+ HttpClientSslUtils.doPost(url, data, ContentType.APPLICATION_JSON, headers);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|