博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
支付宝退款接口及反回参数
阅读量:5171 次
发布时间:2019-06-13

本文共 3420 字,大约阅读时间需要 11 分钟。

支付宝退款接口:

参考:https://docs.open.alipay.com/api_1/alipay.trade.refund/    官方文档

直接上代码:

    

/**     * 支付宝的退款接口     * @param orderId 商户的订单号     * @param tradeNo 支付宝的交易流水号     * @param totalAmount 退款金额     * @return     */    public static Map alipayCreateOrderRefund(String orderId,String tradeNo,String totalAmount) {        Map map = new LinkedHashMap();        AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig. aliPayUrl,                AlipayConfig.appId, AlipayConfig.developerSpoon,                "json", AlipayConfig.input_charset, AlipayConfig.aliPaySpoon, "RSA2");        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();        AlipayTradeRefundModel model= new AlipayTradeRefundModel();        model.setOutTradeNo(orderId);//订单支付时传入的商户订单号        model.setTradeNo(tradeNo);//支付宝交易号        model.setRefundAmount(totalAmount);//refund_amount    需要退款的金额,该金额不能大于订单金额,单位为元        request.setBizModel(model);//请求参数        AlipayTradeRefundResponse  response=null;        try {            response = alipayClient.execute(request);            System.out.println(JSONObject.fromObject(response).toString());            Map tuiMap=JSONObject.fromObject(response);        }catch ( AlipayApiException e){            String massage = "alipay.trade.refund退款接口:订单签名错误";            System.out.println(massage);        }        if(response.isSuccess()){            System.out.println("调用成功");            map.put("status", 0);//订单退款  status:0 成功 1:失败            logger.info("支付宝:支付订单支付结果查询:订单out_trade_no----"+orderId+"---订单退款成功!");        } else {            System.out.println("调用失败");            map.put("status",1);//订单退款  status:0 成功 1:失败            logger.info("支付宝:支付订单支付结果查询:订单out_trade_no----"+orderId+"---订单退款失败!");        }        return map;    }

 

退款成功的参数例如以下:

退款成功:{    "body":"{"alipay_trade_refund_response":{"code":"10000","msg":"Success","buyer_logon_id":"185******13","buyer_user_id":"2088422483503995","fund_change":"N","gmt_refund_pay":"2019-08-13 17:48:25","out_trade_no":"12337925","refund_fee":"0.01","send_back_fee":"0.00","trade_no":"2019081322001403990517324158"},"sign":"dNhUcD9THBOpAigyklYLyaNqUOEv2IpxENZLshgG4dzQkKa04GvVU1a9dqib98osDOEYAnGf1RNzm1QZvvw/9ybVCWMkQK0C/No+Tv13+7DZ2DfSqmtG+JsEugQM4lHJfsVm/QUIU9kprPOeuKJAoAw+fLVXaSgFT+hsnatHUpR0F+3ail/jpQDfonneMfJanMuAxbfA2LVlxHVpIaoC73yyHK0WEQNrSwnp0pTEO30uqnLi4EehiV+Wo8bSdGr9ilzAEmq1bcDsNQuftE+4TU/I4J5KyhjAJos4SbOU+98fQylwSqdG16Od3lDEuusedPq5bz1yoW+mDW0peU5i+g=="}",    "buyerLogonId":"185******13",    "buyerUserId":"2088422483503995",    "code":"10000",    "errorCode":"10000",    "fundChange":"N",    "gmtRefundPay":{        "date":13,        "day":2,        "hours":17,        "minutes":48,        "month":7,        "seconds":25,        "time":1565689705000,        "timezoneOffset":-480,        "year":119    },    "msg":"Success",    "openId":"",    "outTradeNo":"12337925",    "params":{        "biz_content":"{"out_trade_no":"12337925","refund_amount":"0.01","trade_no":"2019081322001403990517324158"}"    },    "presentRefundBuyerAmount":"",    "presentRefundDiscountAmount":"",    "presentRefundMdiscountAmount":"",    "refundCurrency":"",    "refundDetailItemList":[    ],    "refundFee":"0.01",    "sendBackFee":"0.00",    "storeName":"",    "subCode":"",    "subMsg":"",    "success":true,    "tradeNo":"2019081322001403990517324158"}

根据自己的业务进行解析就行了,然后处理订单就行

转载于:https://www.cnblogs.com/wyf-love-dch/p/11347575.html

你可能感兴趣的文章
[leedcode 137] Single Number II
查看>>
[转载]如何捕获控制台消息
查看>>
myeclipse激活+Aptana安装配置
查看>>
嵊州D1T1 总统先生,一路走好!
查看>>
Python字符串图解
查看>>
[家里蹲大学数学杂志]第270期张恭庆编《泛函分析讲义》2.5节以前的习题参考解答...
查看>>
博文内部设置目录尝试
查看>>
Linux下的.NET之旅:第一站,CentOS+Mono+Xsp构建最简单的ASP.NET服务器
查看>>
什么是生成器
查看>>
电脑快捷键总结
查看>>
VS 快捷键
查看>>
QT语言翻译
查看>>
HTML DOM对象的属性和方法介绍(原生JS方法)
查看>>
js手机号批量滚动抽奖代码实现
查看>>
properties类
查看>>
php常见问题辨析(二)
查看>>
面试、笔试中常用的SQL语句(数据库知识必杀)一共50个!!!
查看>>
BigDecimal的add方法
查看>>
实现MFC扩展DLL中导出类和对话框
查看>>
windows 弹出 api-ms-win-crt-runtime-l1-1-0.dll 丢失的问题
查看>>