Closed Arisono closed 5 years ago
支付宝退款接口BUG: 已经确保了应用配置正确,退款等单号信息正确; AliPayController
出问题代码:
/** * 退款 */ @RequestMapping(value = "/tradeRefund") @ResponseBody public String tradeRefund() { try { AlipayTradeRefundModel model = new AlipayTradeRefundModel(); model.setOutTradeNo("042518161915246");//商户订单号 model.setTradeNo("2018042521001004610572946934");//支付宝订单号 model.setRefundAmount("0.01"); model.setRefundReason("正常退款"); AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AliPayApiConfigKit.getAliPayApiConfig().getAppId(), AliPayApiConfigKit.getAliPayApiConfig().getPrivateKey(),"json","GBK", AliPayApiConfigKit.getAliPayApiConfig().getAlipayPublicKey(),"RSA2"); AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); request.setBizModel(model); AlipayTradeRefundResponse response = alipayClient.execute(request); //return response.getBody(); return AliPayApi.tradeRefund(model); } catch (AlipayApiException e) { e.printStackTrace(); } return null; }
出问题报 参数 appid无效!后面我改成下面的方式,就退款成功了,非常疑惑,不止为何,我也相信看了楼主的封装代码,AliPayApi.tradeRefund(model);里面的代码没有看出问题来。
{ alipay_trade_refund_response: { code: "40002", msg: "Invalid Arguments", sub_code: "isv.invalid-app-id", sub_msg: "无效的AppID参数" } }
正常代码:
/** * 退款 */ @RequestMapping(value = "/tradeRefund") @ResponseBody public String tradeRefund() { try { AlipayTradeRefundModel model = new AlipayTradeRefundModel(); model.setOutTradeNo("042518161915246");//商户订单号 model.setTradeNo("2018042521001004610572946934");//支付宝订单号 model.setRefundAmount("0.01"); model.setRefundReason("正常退款"); AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",AliPayApiConfigKit.getAliPayApiConfig().getAppId(), AliPayApiConfigKit.getAliPayApiConfig().getPrivateKey(),"json","GBK", AliPayApiConfigKit.getAliPayApiConfig().getAlipayPublicKey(),"RSA2"); AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); request.setBizModel(model); AlipayTradeRefundResponse response = alipayClient.execute(request); return response.getBody(); //AliPayApi.tradeRefund(model); } catch (AlipayApiException e) { e.printStackTrace(); } return null; }
{ alipay_trade_refund_response: { code: "10000", msg: "Success", buyer_logon_id: "132****9268", buyer_user_id: "2088702312871614", fund_change: "N", gmt_refund_pay: "2018-04-25 19:30:34", out_trade_no: "042518161915246", refund_fee: "0.01", send_back_fee: "0.00", trade_no: "2018042521001004610572946934" }, sign: "VVkWEPT8p6nJ03SxUBPJGdU5DVT3xoloDPkpbdwKMBCI3uI3EEDNKw/WnOxN6xgdBpa2VONOsrKqmu3A+xHiLnasWuDd769FR1e0lnWLbG5BcF+ScNICpa3zTak1sDeXhfNSvtE6oGDo/vnogp135ZhfLi6cR8kIeawnOYC3dCD6mA90kFrlxG+N9Op59VPx0hq3DIbFGpbOnL8NXznIUOJj3Im8X7l1qe79yN0hCNeyzhTPabxhqRroJeqeKLv4Fsq3/ofv2UrG+uGexlv/Ekd/ASuI+oyHbs0kJX5wqplTjJUqj8BaBoxxzknbMmaX6g1JCE5FThGAo4abi3YjTQ==" }
请楼主看下,这是为何?appid已经配置成功了,拦截器拦截的时候把appid也通过配置类传入,但是还是发生了上面的 参数无效 appid.
你可以Debug调试下,看看AliPayApi.tradeRefund中使用的AlipayClient中获取到的appId是多少
AliPayApi.tradeRefund
AlipayClient
appId
支付宝退款接口BUG: 已经确保了应用配置正确,退款等单号信息正确; AliPayController
出问题代码:
出问题报 参数 appid无效!后面我改成下面的方式,就退款成功了,非常疑惑,不止为何,我也相信看了楼主的封装代码,AliPayApi.tradeRefund(model);里面的代码没有看出问题来。
正常代码:
请楼主看下,这是为何?appid已经配置成功了,拦截器拦截的时候把appid也通过配置类传入,但是还是发生了上面的 参数无效 appid.