public override async Task OnCancelStartedAsync(Payment payment)
        {
            await _paymentManager.CompleteCancelAsync(payment);

            if (payment.PayeeAccount == null)
            {
                return;
            }

            var outTradeNo = payment.Id.ToString("N");

            var orderQueryResult = await _serviceProviderPayService.CloseOrderAsync(
                appId : payment.GetProperty <string>("appid"),
                mchId : payment.PayeeAccount,
                subAppId : null,
                subMchId : null,
                outTradeNo : outTradeNo
                );

            var dict       = orderQueryResult.SelectSingleNode("xml").ToDictionary() ?? throw new NullReferenceException();
            var resultCode = dict.GetOrDefault("result_code");
            var errCode    = dict.GetOrDefault("err_code");
            var errCodeDes = dict.GetOrDefault("err_code_des");

            // ignore the "ORDERCLOSED" status.
            if (resultCode != "SUCCESS" && errCode != "ORDERCLOSED")
            {
                throw new WeChatPayBusinessErrorException(outTradeNo, errCode, errCodeDes);
            }
        }
        public virtual async Task OnCancelStartedAsync(Payment payment)
        {
            _unitOfWorkManager.Current.OnCompleted(async() =>
            {
                // Just try to close it.
                await _serviceProviderPayService.CloseOrderAsync(
                    appId: payment.GetProperty <string>("appid"),
                    mchId: payment.PayeeAccount,
                    subAppId: null,
                    subMchId: null,
                    outTradeNo: payment.Id.ToString("N")
                    );
            });

            await _paymentManager.CompleteCancelAsync(payment);
        }
Example #3
0
 public override async Task OnCancelStartedAsync(Payment payment)
 {
     await _paymentManager.CompleteCancelAsync(payment);
 }
 public virtual async Task OnCancelStartedAsync(Payment payment)
 {
     await _paymentManager.CompleteCancelAsync(payment);
 }