public async Task <PaymentDetails> GetPaymentDetails(GatewayPaymentId paymentGatewayId)
        {
            //Simulate IO
            await Task.Delay(1);

            return(_storage[paymentGatewayId]);
        }
Ejemplo n.º 2
0
 public void RememberMapping(AcquiringBankPaymentId acquiringBankPaymentId, GatewayPaymentId gatewayPaymentId)
 {
     if (!_map.TryAdd(acquiringBankPaymentId, gatewayPaymentId))
     {
         //Can happen only when Acquiring bank sent duplicated unique identifier for a payment
         throw new BankDuplicatedPaymentIdException($"Bank paymentId {acquiringBankPaymentId} already maps to Gateway Payment Id {_map[acquiringBankPaymentId]}");
     }
 }
        public async Task Update(GatewayPaymentId gatewayPaymentId, PaymentStatus paymentStatus)
        {
            //Simulate IO
            await Task.Delay(1);

            var paymentDetails = _storage[gatewayPaymentId];

            paymentDetails.Update(paymentStatus);
        }
        public async Task Create(GatewayPaymentId gatewayPaymentId, PaymentGateway.Domain.Card card)
        {
            //Simulate IO
            await Task.Delay(1);

            if (!_storage.TryAdd(gatewayPaymentId, new PaymentDetails(new Domain.Card(Mask(card.Number), card.Expiry, card.Cvv))))
            {
                // Can happen only if the read projected receive twice the same `PaymentRequested`
                // For a real distributed message bus, it can never deliver once and only once for a message
                // We should ensure the operation on duplicated message is idempotent, just log in this case

                _logger.LogInformation($"{nameof(PaymentRequested)} of gateway id {gatewayPaymentId} has already been handled. We received duplicated message from message bus");
            }
        }