| | |
| | | package cc.mrbird.febs.pay.util; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | |
| | | private static final String API_URL = "https://api.fiuu.com/RMS/API/refundAPI/index.php"; |
| | | private static final String MERCHANT_ID = "e2umart01"; |
| | | private static final String SECRET_KEY = "59c709fc18978a6a83b87f05d37cecbf"; |
| | | |
| | | @Transactional |
| | | public boolean comRefund(String outTradeNo, String outRefundNo,String amount){ |
| | | public void comRefund(String outTradeNo, String outRefundNo,String amount){ |
| | | // 退款请求参数 |
| | | Map<String, String> params = new LinkedHashMap<>(); |
| | | params.put("RefundType", "P"); // P: Partial Refund, F: Full Refund |
| | |
| | | } |
| | | System.out.println("退款响应: " + response); |
| | | |
| | | JSONObject jsonObject = JSONUtil.parseObj(response); |
| | | |
| | | String status = jsonObject.getStr("status"); |
| | | if ("00".equals(status)) { |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | // JSONObject jsonObject = JSONUtil.parseObj(response); |
| | | // |
| | | // String status = jsonObject.getStr("status"); |
| | | // if ("00".equals(status)) { |
| | | // return true; |
| | | // }else{ |
| | | // return false; |
| | | // } |
| | | |
| | | } |
| | | public static void main(String[] args) { |
| | |
| | | Map<String, String> params = new LinkedHashMap<>(); |
| | | params.put("RefundType", "P"); // P: Partial Refund, F: Full Refund |
| | | params.put("MerchantID", MERCHANT_ID); |
| | | params.put("RefID", "REF123456"); // 商户唯一退款ID |
| | | params.put("TxnID", "123456789"); // Fiuu原始交易ID |
| | | params.put("Amount", "100.00"); // 退款金额 |
| | | params.put("BankCode", "MBBEMYKL"); // 银行代码(可选) |
| | | params.put("BankCountry", "MY"); // 国家代码(可选) |
| | | params.put("BeneficiaryName", "John Doe"); // 收款人姓名(可选) |
| | | params.put("BeneficiaryAccNo", "1234567890"); // 收款账号(可选) |
| | | params.put("RefID", "2025020611124868512_RITEM42432121"); // 商户唯一退款ID |
| | | params.put("TxnID", "2685352601"); // Fiuu原始交易ID |
| | | params.put("Amount", "1.00"); // 退款金额 |
| | | |
| | | // 生成签名 |
| | | String signature = generateSignature(params); |