コード例 #1
0
 public AuthorizeNet.APICore.createCustomerPaymentProfileResponse CreateCustomerPaymentProfile(AuthorizeNet.APICore.customerPaymentProfileType paymentProfile, long profileId)
 {
     AuthorizeNet.APICore.createCustomerPaymentProfileRequest req = new AuthorizeNet.APICore.createCustomerPaymentProfileRequest();
     req.customerProfileId = profileId.ToString();
     req.paymentProfile = paymentProfile;
     AuthorizeNet.HttpXmlUtility util = new AuthorizeNet.HttpXmlUtility(ServiceMode, MerchantAuthenticationType.name, MerchantAuthenticationType.transactionKey);
     return (AuthorizeNet.APICore.createCustomerPaymentProfileResponse)util.Send(req);
 }
コード例 #2
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());
            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;
        }
コード例 #3
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;
        }