예제 #1
0
        public async Task <PurchaseResultDto> ProcessPaymentAsync(PurchaseRequestDto purchaseRequestDto)
        {
            Random rnd          = new();
            bool   isSuccessful = rnd.NextDouble() >= 0.5;
            var    status       = isSuccessful ? PaymentStatus.Successful : PaymentStatus.Failed;

            var result = new PurchaseResultDto(Guid.NewGuid(), status);

            return(await Task.FromResult(result));
        }
예제 #2
0
        private async Task CreatePaymentAsync(PurchaseRequestDto request, PurchaseResultDto response)
        {
            var product = Constants.ProductPrices[request.Product];
            var payment = new Payment
            {
                Id            = response.Id,
                Amount        = product.Price,
                Currency      = product.Currency,
                PaymentStatus = response.PaymentStatus,
                CreatedDate   = DateTime.UtcNow,
                MerchantId    = product.MerchantId
            };

            int total = await InsertPaymentAndShopperAsync(request, payment);

            _logger.LogInformation($"Number of entries written to db: {total}");
        }
예제 #3
0
        public async Task <PurchaseResultDto> ProcessPaymentAsync(PurchaseRequestDto purchaseRequestDto)
        {
            var result = new PurchaseResultDto(TestConstants.TestPaymentId, PaymentStatus.Successful);

            return(await Task.FromResult(result));
        }