Пример #1
0
        /// <summary>
        /// Payment Information
        /// </summary>
        /// <param name="type">Type. Eg: CredictCard, DebitCard, Eletronic Transfer, etc.</param>
        /// <param name="amount">Total purchase value</param>
        /// <param name="installments">Installments</param>
        /// <param name="softDescriptor">Text to be printed in the Bank Invoice</param>
        /// <param name="capture">Should capture payment</param>
        /// <param name="authenticate">Should redirect to the Bank to authenticate card.</param>
        /// <param name="returnUrl">Url which user will be redirect after finish the payment process.</param>
        /// <param name="creditCard">Credit Card Information</param>
        /// <param name="debitCard">Debit Card Information</param>
        public Payment(PaymentType type,
                       decimal amount,
                       byte installments     = 1,
                       string softDescriptor = "",
                       bool capture          = false,
                       bool authenticate     = false,
                       string returnUrl      = null,
                       CreditCard creditCard = null,
                       DebitCard debitCard   = null)
        {
            Type         = type.ToString();
            Amount       = (int)(amount * 100);
            Installments = installments;
            if (!string.IsNullOrEmpty(softDescriptor))
            {
                SoftDescriptor = softDescriptor;
            }
            Capture      = capture;
            Authenticate = Authenticate;
            ReturnUrl    = returnUrl;

            if (type == PaymentType.CreditCard)
            {
                if (creditCard == null)
                {
                    throw new ArgumentNullException(paramName: nameof(creditCard), message: "Suas informações do cartão de crédito não podem ser nulas.");
                }
                else
                {
                    _creditCard = creditCard;
                }
            }

            else if (type == PaymentType.DebitCard)
            {
                if (debitCard == null)
                {
                    throw new ArgumentNullException(paramName: nameof(debitCard), message: "As informações do seu cartão de débito não podem ser nulas.");
                }
                else
                {
                    _debitCard = debitCard;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Payment Information
        /// </summary>
        /// <param name="type">Type. Eg: CredictCard, DebitCard, Eletronic Transfer, etc.</param>
        /// <param name="amount">Total purchase value</param>
        /// <param name="installments">Installments</param>
        /// <param name="softDescriptor">Text to be printed in the Bank Invoice</param>
        /// <param name="capture">Should capture payment</param>
        /// <param name="authenticate">Should redirect to the Bank to authenticate card.</param>
        /// <param name="returnUrl">Url which user will be redirect after finish the payment process.</param>
        /// <param name="creditCard">Credit Card Information</param>
        /// <param name="debitCard">Debit Card Information</param>
        public Payment(PaymentType type,
                       decimal amount,
                       byte installments,
                       string softDescriptor,
                       bool capture          = false,
                       bool authenticate     = false,
                       string returnUrl      = null,
                       CreditCard creditCard = null,
                       DebitCard debitCard   = null)
        {
            Type           = type.ToString();
            Amount         = (int)(amount * 100);
            Installments   = installments;
            SoftDescriptor = softDescriptor;
            Capture        = capture;
            Authenticate   = Authenticate;
            ReturnUrl      = returnUrl;

            if (type == PaymentType.CreditCard)
            {
                if (creditCard == null)
                {
                    throw new ArgumentNullException(paramName: nameof(creditCard), message: "Your CreditCard information cannot be null.");
                }
                else
                {
                    _creditCard = creditCard;
                }
            }

            else if (type == PaymentType.DebitCard)
            {
                if (debitCard == null)
                {
                    throw new ArgumentNullException(paramName: nameof(debitCard), message: "Your DebitCard information cannot be null.");
                }
                else
                {
                    _debitCard = debitCard;
                }
            }
        }