Ejemplo n.º 1
0
        private static PiggyPaymentRequest BuildPiggyRequest(PaymentRequest processPayment)
        {
            var piggyRequest = new PiggyPaymentRequest();

            piggyRequest.CardNumber  = processPayment.CardNumber;
            piggyRequest.Cvv         = processPayment.Cvv;
            piggyRequest.ExpiryMonth = processPayment.ExpiryMonth;
            piggyRequest.ExpiryYear  = processPayment.ExpiryYear;
            piggyRequest.From        = processPayment.CardHolderName;
            piggyRequest.To          = processPayment.MerchantName;
            piggyRequest.Amount      = processPayment.Amount;
            piggyRequest.Currency    = processPayment.Currency;
            return(piggyRequest);
        }
Ejemplo n.º 2
0
 public static PiggyPaymentStatus ProcessPaymentRequest(PiggyPaymentRequest payment)
 {
     if (string.IsNullOrWhiteSpace(payment.CardNumber) && string.IsNullOrWhiteSpace(payment.Cvv))
     {
         var status = new PiggyPaymentStatus();
         status.Status = PiggyStatus.Failed;
         return(status);
     }
     else
     {
         var status = new PiggyPaymentStatus();
         status.PaymentId = Guid.NewGuid();
         status.Status    = PiggyStatus.Authorised;
         return(status);
     }
 }
        public static PiggyPaymentStatus ProcessPaymentRequest(PiggyPaymentRequest payment)
        {
            var firstDigit = payment.CardNumber[0];
            var failed     = false;

            if (firstDigit == '0')
            {
                failed = true;
            }

            if (failed)
            {
                var status = new PiggyPaymentStatus();
                status.Status = PiggyStatus.Failed;
                return(status);
            }
            else
            {
                var status = new PiggyPaymentStatus();
                status.PaymentId = Guid.NewGuid().ToString();
                status.Status    = PiggyStatus.Authorised;
                return(status);
            }
        }
        public async static Task <PiggyPaymentStatus> ProcessPaymentRequestAsync(PiggyPaymentRequest payment)
        {
            var task = Task.Run(() => ProcessPaymentRequest(payment));

            return(await task);
        }