Exemple #1
0
        /// <summary>
        /// 申请退款
        /// </summary>
        /// <param name="transactionId">微信支付交易号</param>
        /// <param name="outRefundNo">商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔</param>
        /// <returns></returns>
        public async Task <RefundResponse> RefundAsync(string transactionId, string outRefundNo, decimal totalFee, decimal refundFee)
        {
            // var appEnv = _commonContext.GetService<IApplicationEnvironment>();
            var clientService = new ClientService(_loggerFactory);
            var refundReq     = new RefundRequest(_weixinSetting);

            refundReq.transaction_id = transactionId;
            refundReq.out_refund_no  = outRefundNo;
            refundReq.total_fee      = refundReq.ConverDecimalToIntMoney(totalFee);
            refundReq.refund_fee     = refundReq.ConverDecimalToIntMoney(refundFee);
            refundReq.nonce_str      = Utility.GenerateNonceStr();
            refundReq.sign           = Utility.MakeSign(refundReq, _weixinSetting.PartnerKey);

            var resp = await clientService.ExecuteAsync(
                refundReq,
                RequestStringDataTypes.Xml,
                _weixinSetting.CertPassword,
                _weixinSetting.CertFullName);

            return(resp);
        }