public PaymentResponse Post([FromBody] PaymentInformation paymentInformation)
        {
            log.Info("POST-REQUEST:" + JsonConvert.SerializeObject(paymentInformation));
            try
            {
                EncryptedPaymentInformation encryptedPaymentInformation = new EncryptedPaymentInformation();
                //Encrypt data before sending to bank
                encryptedPaymentInformation = EncryptData(paymentInformation);

                PaymentResponse response = _bankService.PaymentRequest(encryptedPaymentInformation);
                using (var context = new PaymentsStorageContext())
                {
                    var paymentRecord = new PaymentRecord()
                    {
                        CardNo     = paymentInformation.CardNo,
                        Expiry     = paymentInformation.Expiry,
                        Status     = response.Status,
                        Identifier = response.Identifier
                    };
                    context.PaymentRecords.Add(paymentRecord);
                    context.SaveChanges();
                }
                log.Info("POST-RESPONSE:" + JsonConvert.SerializeObject(response));
                return(response);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);

                return(null);
            }
        }
        public PaymentResponse PaymentRequest(EncryptedPaymentInformation encryptedPaymentInformation)
        {
            PaymentResponse response = new PaymentResponse();
            Guid            transactionIdentifier = Guid.NewGuid();
            string          personName            = "Mr David Peterson";

            response.Identifier = transactionIdentifier.ToString();
            response.Status     = "SUCCESS";
            return(response);
        }
        private static EncryptedPaymentInformation EncryptData(PaymentInformation paymentInformation)
        {
            EncryptedPaymentInformation encryptedPaymentInformation = new EncryptedPaymentInformation();
            CryptographyService         cryptographyService         = new CryptographyService();

            encryptedPaymentInformation.CardNo   = cryptographyService.EncryptText(paymentInformation.CardNo);
            encryptedPaymentInformation.Expiry   = cryptographyService.EncryptText(paymentInformation.Expiry);
            encryptedPaymentInformation.Amount   = cryptographyService.EncryptText(paymentInformation.Amount.ToString());
            encryptedPaymentInformation.Currency = cryptographyService.EncryptText(paymentInformation.Currency);
            encryptedPaymentInformation.CVV      = cryptographyService.EncryptText(paymentInformation.CVV);
            return(encryptedPaymentInformation);
        }