Exemple #1
0
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddCreditCard(string profileID, string cardNumber, int expirationMonth, int expirationYear, string cardCode, Address billToAddress)
        {
            var req = new createCustomerPaymentProfileRequest();


            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var card = new creditCardType();

            card.cardCode                   = cardCode;
            card.cardNumber                 = cardNumber;
            card.expirationDate             = string.Format("{0}-{1}", expirationYear.ToString(), expirationMonth.ToString());
            req.paymentProfile.payment.Item = card;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }


            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);

            return(response.customerPaymentProfileId);
        }
Exemple #2
0
        /// <summary>
        /// Adds a bank account profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddECheckBankAccount(string profileID, BankAccount bankAccount, Address billToAddress)
        {
            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var bankAcct = new bankAccountType()
            {
                accountTypeSpecified = bankAccount.accountTypeSpecified,
                accountType          = (bankAccountTypeEnum)Enum.Parse(typeof(bankAccountTypeEnum), bankAccount.accountType.ToString(), true),
                routingNumber        = bankAccount.routingNumber,
                accountNumber        = bankAccount.accountNumber,
                nameOnAccount        = bankAccount.nameOnAccount,
                bankName             = bankAccount.bankName,
                echeckTypeSpecified  = bankAccount.echeckTypeSpecified,
                echeckType           = (echeckTypeEnum)Enum.Parse(typeof(echeckTypeEnum), bankAccount.echeckType.ToString(), true)
            };

            req.paymentProfile.payment.Item = bankAcct;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }

            req.validationModeSpecified = true;
            req.validationMode          = this._mode;

            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);

            return(response.customerPaymentProfileId);
        }
Exemple #3
0
        /// <summary>
        /// Adds a Shipping Address to the customer profile
        /// </summary>
        public string AddShippingAddress(string profileID, Address address)
        {
            var req = new createCustomerShippingAddressRequest();

            req.address           = address.ToAPIType();
            req.customerProfileId = profileID;
            var response = (createCustomerShippingAddressResponse)_gateway.Send(req);

            return(response.customerAddressId);
        }
Exemple #4
0
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddCreditCard(string profileID, string cardNumber, int expirationMonth, int expirationYear, string cardCode, Address billToAddress)
        {
            // Get the expiration date.

            DateTime dt; // = DateTime.Parse(expirationMonth.ToString() + "-1-" + expirationYear.ToString());

            if (!CommonFunctions.ParseDateTime(expirationYear, expirationMonth, 1, out dt))
            {
                throw new Exception("Invalid credit card expiration date");
            }

            DateTime expDate  = new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
            string   sExpDate = expDate.ToString("yyyy-MM");

            // Make sure the card has not expired.
            if (expDate <= DateTime.Now)
            {
                throw new Exception("The credit card expiration date \"" + sExpDate + "\" is expired.");
            }

            var req = new createCustomerPaymentProfileRequest();


            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var card = new creditCardType();

            if (!String.IsNullOrEmpty(cardCode))
            {
                card.cardCode = cardCode;
            }
            card.cardNumber                 = cardNumber;
            card.expirationDate             = sExpDate;
            req.paymentProfile.payment.Item = card;

            if (billToAddress != null)
            {
                req.paymentProfile.billTo = billToAddress.ToAPIType();
            }

            req.validationModeSpecified = true;
            req.validationMode          = this._mode;

            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);

            return(response.customerPaymentProfileId);
        }
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public String AddCreditCard(String profileID, PaymentCard paymentCard, Address billingAddress)
        {
            // Make sure the card has not expired.
            if (paymentCard.ExpirationDate <= DateTime.Now)
            {
                throw new Exception("The payment-card expiration date \"" + paymentCard.ExpirationDate.ToExpirationDateString() + "\" is expired.");
            }

            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId      = profileID;
            req.paymentProfile         = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            req.paymentProfile.payment.Item = paymentCard.Get_creditCardType();

            req.paymentProfile.billTo = billingAddress.ToAPIType();

            req.validationMode = this._mode;

            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);

            return(response.customerPaymentProfileId);
        }
        /// <summary>
        /// Adds a credit card profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddCreditCard(string profileID, string cardNumber, int expirationMonth, int expirationYear, string cardCode, Address billToAddress)
        {
            // Get the expiration date.
            DateTime dt = DateTime.Parse(expirationMonth.ToString() + "-1-" + expirationYear.ToString());
            DateTime expDate = new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
            string sExpDate = expDate.ToString("yyyy-MM");
            // Make sure the card has not expired.
            if (expDate <= DateTime.Now)
                throw new Exception("The credit card expiration date \"" + sExpDate + "\" is expired.");

            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId = profileID;
            req.paymentProfile = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var card = new creditCardType();
            if (!String.IsNullOrEmpty(cardCode)) card.cardCode = cardCode;
            card.cardNumber = cardNumber;
            card.expirationDate = sExpDate;
            req.paymentProfile.payment.Item = card;

            if (billToAddress != null)
                req.paymentProfile.billTo = billToAddress.ToAPIType();

            var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);

            return response.customerPaymentProfileId;
        }
        /// <summary>
        /// Adds a Shipping Address to the customer profile
        /// </summary>
        public string AddShippingAddress(string profileID, Address address)
        {
            var req = new createCustomerShippingAddressRequest();

            req.address = address.ToAPIType();
            req.customerProfileId = profileID;
            var response = (createCustomerShippingAddressResponse)_gateway.Send(req);

            return response.customerAddressId;
        }
        /// <summary>
        /// Adds a bank account profile to the user and returns the profile ID
        /// </summary>
        /// <returns></returns>
        public string AddECheckBankAccount(string profileID, BankAccount bankAccount, Address billToAddress)
        {
            var req = new createCustomerPaymentProfileRequest();

            req.customerProfileId = profileID;
            req.paymentProfile = new customerPaymentProfileType();
            req.paymentProfile.payment = new paymentType();

            var bankAcct = new bankAccountType()
                {
                    accountTypeSpecified = bankAccount.accountTypeSpecified,
                    accountType = (bankAccountTypeEnum)Enum.Parse(typeof(bankAccountTypeEnum), bankAccount.accountType.ToString(), true),
                    routingNumber = bankAccount.routingNumber,
                    accountNumber = bankAccount.accountNumber,
                    nameOnAccount = bankAccount.nameOnAccount,
                    bankName = bankAccount.bankName,
                    echeckTypeSpecified = bankAccount.echeckTypeSpecified,
                    echeckType = (echeckTypeEnum)Enum.Parse(typeof(echeckTypeEnum), bankAccount.echeckType.ToString(), true)
                };
 
            req.paymentProfile.payment.Item = bankAcct;

            if (billToAddress != null)
                req.paymentProfile.billTo = billToAddress.ToAPIType();

            req.validationModeSpecified = true;
            req.validationMode = this._mode;

            var response = (createCustomerPaymentProfileResponse) _gateway.Send(req);

            return response.customerPaymentProfileId;
        }