public void MapsCorrectly_GatewayRequest_To_ProcessorRequest()
        {
            var gatewayRequest = GetTestGatewayRequest();
            var result         = PaymentProcessorMapper.MapRequest(gatewayRequest);

            Check.That(result).IsNotNull();
            Check.That(result.LongCardNumber).Equals(gatewayRequest.LongNumber);
            Check.That(result.CCV).Equals(gatewayRequest.CVV);
            Check.That(result.NameOnCard).Equals(gatewayRequest.NameOnCard);
            Check.That(result.PaymentAmount).Equals(gatewayRequest.PaymentAmount);
            Check.That(result.PaymentCurrency).Equals(gatewayRequest.PaymentCurrency);
        }
Beispiel #2
0
        public async Task <GatewayResponse> HandlePaymentRequest(GatewayPaymentRequest request)
        {
            var encyptedRequest = CardEncryptor.EncryptCardData(request);
            var gatewayId       = await repository.RegisterPaymentRequest(encyptedRequest);

            var paymentRequest = PaymentProcessorMapper.MapRequest(request);
            var result         = await paymentProcessor.HandlePaymentRequest(paymentRequest);

            var response = PaymentProcessorMapper.MapResponse(result, encyptedRequest);

            await repository.RegisterResponse(response);

            return(response);
        }
        public void MapsCorrectly_PaymentProcessorResponse()
        {
            var gatewayRequest = GetTestGatewayRequest();
            var response       = new PaymentProcessorResponse
            {
                GatewayId                 = gatewayRequest.GatewayId,
                FailureReason             = "funds not sufficient",
                IsSuccess                 = false,
                PaymentProcessorReference = Guid.NewGuid().ToString()
            };

            var result = PaymentProcessorMapper.MapResponse(response, gatewayRequest);

            Check.That(response).IsNotNull();
            Check.That(result.TruncatedCardNumber).IsNotEqualTo(gatewayRequest.LongNumber);
            Check.That(result.GatewayId).Equals(gatewayRequest.GatewayId);
            Check.That(result.PaymentAmount).Equals(gatewayRequest.PaymentAmount);
            Check.That(result.PaymentCurrency).Equals(gatewayRequest.PaymentCurrency);
            Check.That(result.PaymentProcessorId).Equals(response.PaymentProcessorReference);
            Check.That(result.MerchantId).Equals(gatewayRequest.MerchantId);
            Check.That(result.MerchantReferenceNumber).Equals(gatewayRequest.MerchantReferenceNumber);
        }