public HpsPayPlanCustomer DeleteCustomer(HpsPayPlanCustomer customer, bool forceDelete = false)
        {
            if (customer == null)
                throw new HpsInvalidRequestException(HpsExceptionCodes.InvalidArgument,
                    "customer must be an instance of HpsPayPlanCustomer.", "customer");

            return DeleteCustomer(customer.CustomerKey, forceDelete);
        }
        public HpsPayPlanCustomer GetCustomer(HpsPayPlanCustomer customer)
        {
            if (customer == null)
                throw new HpsInvalidRequestException(HpsExceptionCodes.InvalidArgument,
                    "customer must be an instance of HpsPayPlanCustomer.", "customer");

            return GetCustomer(customer.CustomerKey);
        }
        public HpsPayPlanCustomer EditCustomer(HpsPayPlanCustomer customer)
        {
            if (customer == null)
                throw new HpsInvalidRequestException(HpsExceptionCodes.InvalidArgument,
                    "customer must be an instance of HpsPayPlanCustomer.", "customer");

            var response = DoRequest("PUT", "customers/" + customer.CustomerKey, customer.GetEditableFieldsWithValues());
            return HydrateObject<HpsPayPlanCustomer>(response);
        }
        /* CUSTOMER METHODS */

        public HpsPayPlanCustomer AddCustomer(HpsPayPlanCustomer customer)
        {
            if (customer == null)
                throw new HpsInvalidRequestException(HpsExceptionCodes.InvalidArgument,
                    "Customer must be an instance of HpsPayPlanCustomer.", "customer");

            var response = DoRequest("POST", "customers", customer);
            return HydrateObject<HpsPayPlanCustomer>(response);
        }
        public void AddPaymentMethodWithToken()
        {
            // Create Customer
            var customer = new HpsPayPlanCustomer
            {
                CustomerIdentifier = GetIdentifier("Person"),
                FirstName = "John",
                LastName = "Doe",
                CustomerStatus = HpsPayPlanCustomerStatus.Active,
                PrimaryEmail = "*****@*****.**",
                AddressLine1 = "123 Main St",
                City = "Dallas",
                StateProvince = "TX",
                ZipPostalCode = "98765",
                Country = "USA",
                PhoneDay = "5551112222"
            };
            HpsPayPlanService payPlanService = new HpsPayPlanService(TestServicesConfig.ValidTokenServiceConfig());
            var response = payPlanService.AddCustomer(customer);
            var customerKey = response.CustomerKey;

            // Create Card & Token
            var card = new HpsCreditCard
            {
                Number = "4111111111111111",
                ExpMonth = 12,
                ExpYear = 2020,
                Cvv = "123"
            };
            var tokenService = new HpsTokenService("pkapi_cert_jKc1FtuyAydZhZfbB3");
            var tokenResponse = tokenService.GetToken(card);

            // Create & Add Payment via Token
            var newPaymentMethod = new HpsPayPlanPaymentMethod
            {
                CustomerKey = customerKey,
                NameOnAccount = "Bill Johnson",
                PaymentToken = tokenResponse.token_value,
                PaymentMethodType = HpsPayPlanPaymentMethodType.CreditCard,
                Country = "USA"
            };

            var result = payPlanService.AddPaymentMethod(newPaymentMethod);
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.PaymentMethodKey);
        }
示例#6
0
        public void recurring_001_AddCustomerPerson()
        {
            var customer = new HpsPayPlanCustomer {
                CustomerIdentifier = GetIdentifier("Person"),
                FirstName = "John",
                LastName = "Doe",
                CustomerStatus = HpsPayPlanCustomerStatus.Active,
                PrimaryEmail = "*****@*****.**",
                AddressLine1 = "123 Main St",
                City = "Dallas",
                StateProvince = "TX",
                ZipPostalCode = "98765",
                Country = "USA",
                PhoneDay = "5551112222"
            };

            var response = _payPlanService.AddCustomer(customer);
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.CustomerKey);

            _customerPersonKey = response.CustomerKey;
        }
示例#7
0
        public void recurring_002_AddCustomerBusiness()
        {
            var customer = new HpsPayPlanCustomer {
                CustomerIdentifier = GetIdentifier("Business"),
                Company = "AcmeCo",
                CustomerStatus = HpsPayPlanCustomerStatus.Active,
                PrimaryEmail = "*****@*****.**",
                AddressLine1 = "987 Elm St",
                City = "Princeton",
                StateProvince = "NJ",
                ZipPostalCode = "12345",
                Country = "USA",
                PhoneDay = "5551112222"
            };

            var response = _payPlanService.AddCustomer(customer);
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.CustomerKey);

            _customerCompanyKey = response.CustomerKey;
        }