| | |
| | | import com.alipay.api.request.*; |
| | | import com.alipay.api.response.*; |
| | | import com.dsh.communityWorldCup.util.httpClinet.HttpClientUtil; |
| | | import com.dsh.communityWorldCup.util.wx.PartnerAppPrepay; |
| | | import com.dsh.communityWorldCup.util.wx.WXPayUtility; |
| | | import com.dsh.communityWorldCup.util.wx.WeChatV3SignUtil; |
| | | import com.dsh.communityWorldCup.util.wx.WxV3PayConfig; |
| | | import com.dsh.communityWorldCup.util.wx.*; |
| | | import org.apache.commons.collections.map.HashedMap; |
| | | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
| | | import org.dom4j.Document; |
| | |
| | | } |
| | | } |
| | | |
| | | public ResultUtil weixinRefundV3(String subMchid,String outRefundNo, String transactionId, String totalFee, String notifyUrl) throws Exception { |
| | | BigDecimal bigDecimal = new BigDecimal(totalFee); |
| | | int i = bigDecimal.multiply(new BigDecimal("100")).intValue(); |
| | | // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 |
| | | Create client = new Create( |
| | | "1681873607", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 |
| | | "55714944F7A7E52526F708280B176DCC838F371A", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 |
| | | "/usr/playpai/server/wxV3/1681873607_20250424_cert/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 |
| | | "PUB_KEY_ID_0116818736072025042400351694002605", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 |
| | | "/usr/playpai/server/wxV3/pub_key.pem" // 微信支付公钥文件路径,本地文件路径 |
| | | ); |
| | | |
| | | Create.CreateRequest request = new Create.CreateRequest(); |
| | | request.subMchid = subMchid; |
| | | request.transactionId = transactionId; |
| | | request.outRefundNo = outRefundNo; |
| | | request.reason = "退款"; |
| | | request.notifyUrl = callbackPath+notifyUrl; |
| | | request.amount = new Create.AmountReq(); |
| | | request.amount.refund = (long) i; |
| | | request.amount.total = (long) i; |
| | | request.amount.currency = "CNY"; |
| | | try { |
| | | Create.Refund response = client.run(request); |
| | | |
| | | // TODO: 请求成功,继续业务逻辑 |
| | | System.out.println(response); |
| | | } catch (WXPayUtility.ApiException e) { |
| | | // TODO: 请求失败,根据状态码执行不同的逻辑 |
| | | e.printStackTrace(); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 微信退款成功后的回调处理 |