Exemple #1
0
        public async Task <BaseApiResponse> PaymentRejected(ProcessorPaymentRequest request)
        {
            request.CheckNotNull(nameof(request));
            var paymentDTO = WaitUntilAvailable(request.PaymentId);

            if (paymentDTO == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有支付项目"
                });
            }

            var command = new CancelPaymentCommand {
                AggregateRootId = request.PaymentId
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Exemple #2
0
        public async Task <BaseApiResponse> PaymentAccepted([FromBody] ProcessorPaymentRequest request)
        {
            request.CheckNotNull(nameof(request));

            var payment = _paymentQueryService.FindPayment(request.PaymentId);

            if (payment == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有支付项目"
                });
            }

            var command = new CompletePaymentCommand(
                new Common.PayInfo(request.Total, request.ShopCash))
            {
                AggregateRootId = request.PaymentId
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }