Ejemplo n.º 1
0
        /// <summary>
        /// Updates a payment profile for a user.
        /// </summary>
        /// <param name="profileID">The profile ID.</param>
        /// <param name="profile">The profile.</param>
        /// <returns></returns>
        public ANetApiResponse UpdatePaymentProfile(string profileID, PaymentProfile profile)
        {
            var req = new updateCustomerPaymentProfileRequest();

            req.customerProfileId = profileID;
            req.paymentProfile    = profile.ToAPI();

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

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates a payment profile for a user.
        /// </summary>
        /// <param name="profileID">The profile ID.</param>
        /// <param name="profile">The profile.</param>
        /// <returns></returns>
        public bool UpdatePaymentProfile(string profileID, PaymentProfile profile)
        {
            var req = new updateCustomerPaymentProfileRequest();

            req.customerProfileId = profileID;
            req.paymentProfile    = profile.ToAPI();

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

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

            return(true);
        }
Ejemplo n.º 3
0
        public void UpdatePaymentProfileTest_eCheck()
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><updateCustomerPaymentProfileResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages></updateCustomerPaymentProfileResponse>";
            LocalRequestObject.ResponseString = responseString;

            var email = Path.GetRandomFileName() + "@visa.com";
            const string description = "Create a new customer";
            var customer = CreateCustomer(email, description);

            string custPaymentProfileId = null;
            try
            {
                custPaymentProfileId = _target.AddECheckBankAccount(customer.ProfileID, BankAccountType.Checking, "125000024", "1234588", "Sue Zhu", "Bank of Seattle", EcheckType.WEB, null);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.AddECheckBankAccount() failed: " + e.Message);
            }
            Assert.IsNotNull(custPaymentProfileId);
	    
            var paymentProfile = new PaymentProfile(new customerPaymentProfileMaskedType())
                {
                    ProfileID = custPaymentProfileId,
                    eCheckBankAccount = new BankAccount
                        {
                            routingNumber = "125000025",
                            accountNumber = "1234567",
                            nameOnAccount = "Sue Zhu"
                        }
                };

            var actual = false;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = _target.UpdatePaymentProfile(customer.ProfileID, paymentProfile);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.UpdatePaymentProfile() failed: " + e.Message);
            }

            Assert.IsTrue(actual);
        }
Ejemplo n.º 4
0
        public void UpdatePaymentProfileTest_Mask()
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><updateCustomerPaymentProfileResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages></updateCustomerPaymentProfileResponse>";
            LocalRequestObject.ResponseString = responseString;

            var email = Path.GetRandomFileName() + "@visa.com";
            const string description = "Create a new customer";
            var customer = CreateCustomer(email, description);

            string custPaymentProfileId = null;
            try
            {
                custPaymentProfileId = _target.AddCreditCard(customer.ProfileID, "4111111111111111", 1, 2030);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.AddECheckBankAccount() failed: " + e.Message);
            }
            Assert.IsNotNull(custPaymentProfileId);

            var profile = new PaymentProfile(new customerPaymentProfileMaskedType())
                {
                    ProfileID = custPaymentProfileId,
                    CardNumber = "XXXX1111",
                    CardExpiration = "XXXX",
                    BillingAddress = new Address
                        {
                            First = "Sue",
                            Last = "Zhu",
                            Company = "Visa",
                            Street = "123 Elm Street",
                            City = "Bellevue",
                            State = "WA",
                            Country = "US",
                            Zip = "98006"
                        }
                };

            var actual = false;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = _target.UpdatePaymentProfile(customer.ProfileID, profile);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.UpdatePaymentProfile() failed: " + e.Message);
            }

            Assert.IsTrue(actual);
        }
Ejemplo n.º 5
0
        public void UpdatePaymentProfileMinTest()
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><updateCustomerPaymentProfileResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages></updateCustomerPaymentProfileResponse>";
            LocalRequestObject.ResponseString = responseString;

            var email = Path.GetRandomFileName() + "@visa.com";
            const string description = "Create a new customer";
            var customer = CreateCustomer(email, description);

            const string cardNumber = "4111111111111111";
            const int expirationMonth = 1;
            const int expirationYear = 2030;

            var custPaymentProfileId = CreateCustomerPaymentProfile(customer.ProfileID, cardNumber, expirationMonth, expirationYear);

            var profile = new PaymentProfile(new customerPaymentProfileMaskedType())
                {
                    ProfileID = custPaymentProfileId,
                    CardNumber = "4111111111111112",
                    CardExpiration = "2029-02"
                };

            var actual = false;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = _target.UpdatePaymentProfile(customer.ProfileID, profile);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.UpdatePaymentProfile() failed: " + e.Message);
            }

            Assert.IsTrue(actual);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates a payment profile for a user.
        /// </summary>
        /// <param name="profileID">The profile ID.</param>
        /// <param name="profile">The profile.</param>
        /// <returns></returns>
        public bool UpdatePaymentProfile(string profileID, PaymentProfile profile)
        {
            var req = new updateCustomerPaymentProfileRequest();

            req.customerProfileId = profileID;
            req.paymentProfile = profile.ToAPI();

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

            return true;
        }
        /// <summary>
        /// Updates a payment profile for a user.
        /// </summary>
        /// <param name="profileID">The profile ID.</param>
        /// <param name="profile">The profile.</param>
        /// <returns></returns>
        public bool UpdatePaymentProfile(string profileID, PaymentProfile profile) {

            var req = new updateCustomerPaymentProfileRequest();
            
            req.customerProfileId = profileID;
            req.paymentProfile = profile.ToAPI();

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

            var response = (updateCustomerPaymentProfileResponse)_gateway.Send(req);
            
            return true;
        }