public async Task <string> AddAsync(Payments payment)
        {
            var resultFromPayment = _gateway.PaymentProcess(payment);

            payment.PaymentStatus = PaymetStatus.Completed;

            var paymentRef = await _context.AddAsync(payment);

            //Publish the event here
            //Create Integration Event
            var paymentProcessedEvent = new PaymentProcessedIntegrationEvent(paymentRef.PaymentsId,
                                                                             paymentRef.BookingOrderId,
                                                                             paymentRef.CustomerId, (int)payment.PaymentStatus);

            _eventBus.Publish(paymentProcessedEvent);

            return(paymentRef.PaymentsId);
        }
Beispiel #2
0
        public async Task <string> AddAsync(PaymentDTO payment)
        {
            var resultFromPayment = _gateway.PaymentProcess(payment);

            var paymentEntity = new Payments
            {
                BookingOrderId = payment.BookingOrderId,
                CustomerId     = payment.CustomerId,
                Price          = payment.Price,
                PaymentStatus  = PaymetStatus.Completed //This part is based on the result returned from external gateway
            };

            var paymentRef = await _context.AddAsync(paymentEntity);

            //Publish the event here
            //Create Integration Event
            var paymentProcessedEvent = new PaymentProcessedIntegrationEvent(paymentRef.PaymentsId,
                                                                             paymentRef.BookingOrderId,
                                                                             paymentRef.CustomerId, (int)paymentEntity.PaymentStatus);

            _eventBus.Publish(paymentProcessedEvent);

            return(paymentRef.PaymentsId);
        }