public async Task<Transaction> AuthorizePayment(PaymentInfo payment)
        {
            var planetPaySvc = new PlanetPayService(_paymentConfig.DefaultApiKey,
                _paymentConfig.DefaultEncryptionKey);

            var cardHashGen = new CardHash(planetPaySvc)
            {
                CardNumber = payment.CreditCard.CardNumber,
                CardHolderName = payment.CreditCard.CardHolder,
                CardExpirationDate = payment.CreditCard.CardExpiration,
                CardCvv = payment.CreditCard.CardCvv
            };
            var cardHash = cardHashGen.Generate();

            var dealTransaction = new DealTransaction(planetPaySvc)
            {
                CardHash = cardHash,
                CardNumber = payment.CreditCard.CardNumber,
                CardHolderName = payment.CreditCard.CardHolder,
                CardExpirationDate = payment.CreditCard.CardExpiration,
                CardCvv = payment.CreditCard.CardCvv,
                PaymentMethod = PaymentMethod.CreditCard,
                Amount = payment.TotalValue
            };

            return ConvertToTransaction(await dealTransaction.AuthorizeCardTransaction());
        }
        public async Task<Transaction> CancelPayment(Transaction transaction)
        {
            var planetPaySvc = new PlanetPayService(_paymentConfig.DefaultApiKey,
                _paymentConfig.DefaultEncryptionKey);

            var dealTransaction = ConvertToDealTransaction(transaction, planetPaySvc);

            return ConvertToTransaction(await dealTransaction.CancelAuthorization());
        }
 public static DealTransaction ConvertToDealTransaction(Transaction transaction, PlanetPayService planetPayService)
 {
     return new DealTransaction(planetPayService)
     {
         Status = (TransactionStatus)transaction.Status,
         Amount = transaction.TotalValue,
         CardBrand = transaction.FlagCard,
         AuthorizationCode = transaction.AuthorizationCode,
         Cost = transaction.CostTransaction,
         Nsu = transaction.NSU,
         Tid = transaction.TID
     };
 }