public async Task HandleAsync(ProcessPiggyPayment command)
        {
            try
            {
                var logCreated = new CreateLog(command.UserId, command.PaymentId, LogLevel.Info, "Process_Payment_3",
                                               "Sent Process Payment Request to Piggy Bank API");
                await _busClient.PublishAsync(logCreated);

                var paymentProcessed = await _piggyService.ProcessAsync(command);

                await _busClient.PublishAsync(paymentProcessed);

                var logCreated2 = new CreateLog(command.UserId, command.PaymentId, LogLevel.Info, "Process_Payment_4",
                                                "Payment " + paymentProcessed.Status + " by PiggyBank");
                await _busClient.PublishAsync(logCreated2);

                return;
            }
            catch (Exception ex)
            {
                var failed = new PaymentFailed("error", ex.Message);
                command.CopyPayment(failed);
                await _busClient.PublishAsync(failed);

                var logCreated = new CreateLog(command.UserId, command.PaymentId, LogLevel.Error, "Process_Payment_Failed",
                                               "Process Payment Failed ");
                await _busClient.PublishAsync(logCreated);
            }
        }
Beispiel #2
0
        public async Task HandleAsync(ProcessPayment command)
        {
            try
            {
                var acquirerCommand = await _paymentService.ProcessAsync(command);

                await _busClient.PublishAsync(acquirerCommand);

                var logCreated = new CreateLog(command.UserId, command.PaymentId, LogLevel.Info, "Process_Payment_2",
                                               "Sent Process Payment Request to " + acquirerCommand.AquirerName + " Service");
                await _busClient.PublishAsync(logCreated);

                return;
            }
            catch (Exception ex)
            {
                var failed = new PaymentFailed("error", ex.Message);
                command.CopyPayment(failed);
                await _busClient.PublishAsync(failed);

                var logCreated = new CreateLog(command.UserId, command.PaymentId, LogLevel.Error, "Process_Payment_Failed",
                                               "Process Payment Failed ");
                await _busClient.PublishAsync(logCreated);
            }
        }
Beispiel #3
0
        public async Task SaveAsync(PaymentFailed @event)
        {
            var paymentHistory = new PaymentHistory();

            paymentHistory.Id           = Guid.NewGuid();
            paymentHistory.Processed    = false;
            paymentHistory.ErrorCode    = @event.ErrorCode;
            paymentHistory.ErrorMessage = @event.ErrorMessage;
            @event.CopyPayment(paymentHistory);

            await _historyRepository.AddAsync(paymentHistory);
        }
        public async Task Handle(PaymentTimedOut @event, CancellationToken cancellationToken)
        {
            var payment = await querySession.LoadAsync<Payment>(@event.PaymentId);

            var externalEvent = PaymentFailed.Create(
                @event.PaymentId,
                payment!.OrderId,
                payment.Amount,
                @event.TimedOutAt,
                PaymentFailReason.Discarded
            );

            await eventBus.Publish(externalEvent);
        }
Beispiel #5
0
 private void OnPaymentFailed(PaymentFailedEventArgs e) => PaymentFailed?.Invoke(this, e);
Beispiel #6
0
 protected void InvokePaymentFailed()
 {
     PaymentFailed?.Invoke(this, null);
 }
Beispiel #7
0
 protected void OnPaymentFailed(PaymentFailedEventArgs e) => PaymentFailed?.Invoke(this, e);
Beispiel #8
0
 public void Consume(PaymentFailed message)
 {
     Console.WriteLine("Payment failed.");
     CancelOrder();
 }
Beispiel #9
0
 protected virtual void OnPaymentFailed(PaymentFailedEventArgs e)
 {
     PaymentFailed?.Invoke(e);
 }