Esempio n. 1
0
        /// <summary>
        /// Creates an API object, ready to send to AuthNET servers.
        /// </summary>
        /// <returns></returns>
        public customerPaymentProfileExType ToAPI() {
            var result = new customerPaymentProfileExType();
            
            if (null != this.BillingAddress)
            { result.billTo = this.BillingAddress.ToAPIType(); }

            result.customerPaymentProfileId = this.ProfileID;
            
            if (!String.IsNullOrEmpty(this.DriversLicenseNumber)) {
                result.driversLicense = new driversLicenseType();
                result.driversLicense.dateOfBirth = this.DriversLicenseDOB;
                result.driversLicense.number = this.DriversLicenseNumber;
                result.driversLicense.state = this.DriversLicenseState;
            }

            if (this.IsBusiness) {
                result.customerType = customerTypeEnum.business;
            } else {
                result.customerType = customerTypeEnum.individual;
            }
            result.customerTypeSpecified = true;
            
            result.payment = new paymentType();
            if (!String.IsNullOrEmpty(this.CardNumber) && (this.CardNumber.Trim().Length > 0))
            {
                var card = new creditCardType();
                card.cardCode = this.CardCode;
                card.cardNumber = this.CardNumber;
                card.expirationDate = this.CardExpiration;
                result.payment.Item = card;
            }
            else if ((this.eCheckBankAccount != null) && !String.IsNullOrEmpty(this.eCheckBankAccount.accountNumber) && (this.eCheckBankAccount.accountNumber.Trim().Length > 0))
            {
                var bankAccount = new bankAccountType()
                    {
                        accountTypeSpecified = this.eCheckBankAccount.accountTypeSpecified,
                        accountType =(bankAccountTypeEnum)Enum.Parse(typeof(bankAccountTypeEnum), this.eCheckBankAccount.accountType.ToString(), true),
                        routingNumber = this.eCheckBankAccount.routingNumber,
                        accountNumber = this.eCheckBankAccount.accountNumber,
                        nameOnAccount = this.eCheckBankAccount.nameOnAccount,
                        echeckTypeSpecified = this.eCheckBankAccount.echeckTypeSpecified,
                        echeckType = (echeckTypeEnum)Enum.Parse(typeof(echeckTypeEnum), this.eCheckBankAccount.echeckType.ToString(), true),
                        bankName = this.eCheckBankAccount.bankName,
                        checkNumber = this.eCheckBankAccount.checkNumber
                    };
                result.payment.Item = bankAccount;
            }

            if (!String.IsNullOrEmpty(this.TaxID)) {
                result.taxId = this.TaxID;
            }
            return result;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an API object, ready to send to AuthNET servers.
        /// </summary>
        /// <returns></returns>
        public customerPaymentProfileExType ToAPI()
        {
            var result = new customerPaymentProfileExType();
            result.billTo = this.BillingAddress.ToAPIType();
            result.customerPaymentProfileId = this.ProfileID;

            if (!String.IsNullOrEmpty(this.DriversLicenseNumber)) {
                result.driversLicense = new driversLicenseType();
                result.driversLicense.dateOfBirth = this.DriversLicenseDOB;
                result.driversLicense.number = this.DriversLicenseNumber;
                result.driversLicense.state = this.DriversLicenseState;
            }

            if (this.IsBusiness) {
                result.customerType = customerTypeEnum.business;
            } else {
                result.customerType = customerTypeEnum.individual;
            }
            result.customerTypeSpecified = true;

            if (!String.IsNullOrEmpty(this.CardNumber)) {
                var card = new creditCardType();
                card.cardCode = this.CardCode;
                card.cardNumber = this.CardNumber;
                card.expirationDate = this.CardExpiration;
                result.payment.Item = card;
            }
            if (!String.IsNullOrEmpty(this.TaxID)) {
                result.taxId = this.TaxID;
            }
            return result;
        }