/// <summary>
        /// Popula o objeto RequestBase em comum a todos.
        /// </summary>
        private void FillRequestBase(String operation, String merchantId, String merchantKey, String referenceNum, decimal chargeTotal, String creditCardNumber
                , String expMonth, String expYear, String cvvInd, String cvvNumber, String authentication, String processorId
                , String numberOfInstallments, String chargeInterest, String ipAddress, String customerIdExt, String currencyCode
                , String fraudCheck, String softDescriptor, decimal? iataFee) {

            this.request = new TransactionRequest(merchantId, merchantKey);

            Order order = this.request.Order;
            RequestBase rBase = new RequestBase();

            if (operation.Equals("sale"))
                order.Sale = rBase;
            else if (operation.Equals("auth"))
                order.Auth = rBase;

            rBase.ReferenceNum = referenceNum;
            rBase.ProcessorId = processorId;
            rBase.Authentication = authentication;
            rBase.IpAddress = ipAddress;
            rBase.CustomerIdExt = customerIdExt;
            rBase.FraudCheck = fraudCheck;

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            Payment payment = new Payment();
            rBase.Payment = payment;
            payment.ChargeTotal = chargeTotal;
            payment.CurrencyCode = currencyCode;
            payment.SoftDescriptor = softDescriptor;
            payment.IataFee = iataFee;

            if (String.IsNullOrEmpty(numberOfInstallments))
                numberOfInstallments = "0";

            int tranInstallments = int.Parse(numberOfInstallments);

            //Verifica se vai precisar criar o nó de parcelas e juros.
            if (!String.IsNullOrEmpty(chargeInterest) && tranInstallments > 1) {
                payment.CreditInstallment = new CreditInstallment();
                payment.CreditInstallment.ChargeInterest = chargeInterest.ToUpper();
                payment.CreditInstallment.NumberOfInstallments = numberOfInstallments;
            }

            TransactionDetail detail = rBase.TransactionDetail;
            PayType payType = detail.PayType;

            CreditCard creditCard = new CreditCard();
            payType.CreditCard = creditCard;

            creditCard.CvvInd = cvvInd;
            creditCard.CvvNumber = cvvNumber;
            creditCard.ExpMonth = expMonth;
            creditCard.ExpYear = expYear;
            creditCard.Number = creditCardNumber;

        }
Exemplo n.º 2
0
        /// <summary>
        /// Passa uma transação salvando o número de cartão automaticamente.
        /// </summary>
        private ResponseBase PaySavingCreditCardAutomatically(String operation, String merchantId, String merchantKey, String referenceNum, decimal chargeTotal
            , String creditCardNumber, String expMonth, String expYear, String cvvInd, String cvvNumber
            , String processorId, String numberOfInstallments, String chargeInterest, String ipAddress
            , String customerToken, String onFileEndDate, String onFilePermission, String onFileComment
            , String onFileMaxChargeAmount, String billingName, String billingAddress, String billingAddress2
            , String billingCity, String billingState, String billingPostalCode, String billingCountry
            , String billingPhone, String billingEmail, String currencyCode, String fraudCheck)
        {
            this.request = new TransactionRequest(merchantId, merchantKey);

            Order order = this.request.Order;
            RequestBase rBase = new RequestBase();

            if (operation.Equals("sale"))
                order.Sale = rBase;
            else if (operation.Equals("auth"))
                order.Auth = rBase;

            rBase.ReferenceNum = referenceNum;
            rBase.ProcessorId = processorId;
            rBase.IpAddress = ipAddress;
            rBase.FraudCheck = fraudCheck;

            Billing billing = new Billing();
            rBase.Billing = billing;

            billing.Address1 = billingAddress;
            billing.Address2 = billingAddress2;
            billing.City = billingCity;
            billing.Country = billingCountry;
            billing.Email = billingEmail;
            billing.Name = billingName;
            billing.Phone = billingPhone;
            billing.Postalcode = billingPostalCode;
            billing.State = billingState;

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            Payment payment = new Payment();
            rBase.Payment = payment;
            payment.ChargeTotal = chargeTotal;
            payment.CurrencyCode = currencyCode;

            if (String.IsNullOrEmpty(numberOfInstallments))
                numberOfInstallments = "0";

            int tranInstallments = int.Parse(numberOfInstallments);

            //Verifica se vai precisar criar o nó de parcelas e juros.
            if (!String.IsNullOrEmpty(chargeInterest) && tranInstallments > 1)
            {
                payment.CreditInstallment = new CreditInstallment();
                payment.CreditInstallment.ChargeInterest = chargeInterest.ToUpper();
                payment.CreditInstallment.NumberOfInstallments = numberOfInstallments;
            }

            TransactionDetail detail = rBase.TransactionDetail;
            PayType payType = detail.PayType;

            CreditCard creditCard = new CreditCard();
            payType.CreditCard = creditCard;

            creditCard.CvvInd = cvvInd;
            creditCard.CvvNumber = cvvNumber;
            creditCard.ExpMonth = expMonth;
            creditCard.ExpYear = expYear;
            creditCard.Number = creditCardNumber;

            rBase.SaveOnFile = new SaveOnFile();
            rBase.SaveOnFile.CustomerToken = customerToken;
            rBase.SaveOnFile.OnFileComment = onFileComment;
            rBase.SaveOnFile.OnFileEndDate = onFileEndDate;
            rBase.SaveOnFile.OnFileMaxChargeAmount = onFileMaxChargeAmount;
            rBase.SaveOnFile.OnFilePermission = onFilePermission;

            return new Utils().SendRequest<TransactionRequest>(this.request, this.Environment);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Faz uma recorrência.
        /// </summary>
        public ResponseBase Recurring(String merchantId, String merchantKey, String referenceNum, decimal chargeTotal
            , String creditCardNumber, String expMonth, String expYear, String cvvInd, String cvvNumber, String processorId
            , String numberOfInstallments, String chargeInterest, String ipAddress, String action
            , String startDate, String frequency, String period, String installments, String failureThreshold
            , String currencyCode)
        {
            FillRecurringBase(merchantId, merchantKey, referenceNum, chargeTotal, processorId, numberOfInstallments
                , chargeInterest, ipAddress, action, startDate, frequency, period, installments
                , failureThreshold, currencyCode);

            TransactionDetail detail = this.request.Order.RecurringPayment.TransactionDetail;

            PayType payType = detail.PayType;

            CreditCard creditCard = new CreditCard();
            payType.CreditCard = creditCard;

            creditCard.CvvInd = cvvInd;
            creditCard.CvvNumber = cvvNumber;
            creditCard.ExpMonth = expMonth;
            creditCard.ExpYear = expYear;
            creditCard.Number = creditCardNumber;

            return new Utils().SendRequest<TransactionRequest>(this.request, this.Environment);
        }