public void Init()
        {
#if DEBUG
            _gateway = new BillingGateway(BillingEnvironment.DEVELOPMENT, Constants.PUBLIC_KEY, Constants.PRIVATE_KEY);
#else
            _gateway = new BillingGateway(BillingEnvironment.QA, Constants.PUBLIC_KEY, Constants.PRIVATE_KEY);
#endif
            _testsHelper = new TestsHelper(_gateway);
            _testData = _testsHelper.PrepareEventsTestData();
        }
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            //Instantiate DynabicPlatform and DynabicBilling Gateways with the provided configuration.
            //Modify these configuration variables in Config class.
            _dynabicPlatformGateway = new PlatformGateway(
                Config.PlatformEnvironment,
                Config.PublicKey,
                Config.PrivateKey);

            _dynabicBillingGateway = new BillingGateway(
                Config.BillingEnvironment,
                Config.PublicKey,
                Config.PrivateKey);
        }
 public ChangePlanModel(BillingGateway dynabicBillingGateway, int currentPlanId)
 {
     //get the current plan that this user is subscribed to
     CurrentPlan = dynabicBillingGateway.Products.GetProductById(currentPlanId.ToString());
     //get all your products
     Plans = new MyPlansModel(dynabicBillingGateway);
 }
 public RegisterModel(BillingGateway dynabicBillingGateway)
     : this()
 {
     //get all your products
     Plans = new MyPlansModel(dynabicBillingGateway);
 }
        public PaymentInfoModel(BillingGateway dynabicBillingGateway, string customerReferenceId)
            : this()
        {
            CreditCard = new CreditCardModel();
            BillingAddress = new BillingAddressModel();
            
            //get the first credit card of our customer to edit
            CreditCardResponse creditCard;
            try
            {
                creditCard = dynabicBillingGateway.Customer.GetFirstCreditCardForCustomerByReferenceId(Config.MySiteSubdomain, customerReferenceId);
            }
            catch (NotFoundException)
            {
                creditCard = new CreditCardResponse();
            }

            CreditCard.Id = creditCard.Id;
            CreditCard.FirstNameOnCard = creditCard.FirstNameOnCard;
            CreditCard.LastNameOnCard = creditCard.LastNameOnCard;
            CreditCard.ExpirationDate = creditCard.ExpirationDate;
            CreditCard.Number = creditCard.Number;
            CreditCard.Cvv = creditCard.Cvv;

            //get the first Billing Address of our customer to edit
            AddressResponse billingAddress;
            try
            {
                billingAddress = dynabicBillingGateway.Customer.GetFirstBillingAddressForCustomerByReferenceId(Config.MySiteSubdomain, customerReferenceId);
            }
            catch (NotFoundException)
            {
                billingAddress = new AddressResponse();
            }

            BillingAddress.BillingAddressId = billingAddress.Id;
            BillingAddress.BillingAddress1 = billingAddress.Address1;
            BillingAddress.BillingCity = billingAddress.City;
            BillingAddress.BillingCountry = billingAddress.Country;
            BillingAddress.BillingFirstName = billingAddress.FirstName;
            BillingAddress.BillingLastName = billingAddress.LastName;
            BillingAddress.BillingProvince = billingAddress.StateProvince;
            BillingAddress.BillingZipPostalCode = billingAddress.ZipPostalCode;
        }
        /// <summary>
        /// Get a list containing all Products within a Site defined in Billing app
        /// sorted by Family Name and Product Name.
        /// </summary>
        /// <param name="dynabicBillingGateway">an instance of Bylling Gateway</param>
        /// <returns>a list o SelectListItem objects</returns>
        public List<SelectListItem> GetAllPlans(BillingGateway dynabicBillingGateway)
        {
            //instantiate your list
            List<SelectListItem> allPlans = new List<SelectListItem>();

            //get all your Products(Plans) through Billing Gateway 
            //and order them by Family Name then by Plan Name
            var myPlans = dynabicBillingGateway.Products.GetProductsBySite(Config.MySiteSubdomain)
                .OrderBy(o => o.FamilyId)
                .ThenBy(o => o.Name);

            //add the plans to the list
            if (myPlans != null)
            {
                foreach (var plan in myPlans)
                {
                    allPlans.Add(new SelectListItem() { Text = "(" + plan.FamilyId + ") " + plan.Name, Value = plan.Id.ToString() });
                }
            }
            return allPlans;
        }
 public MyPlansModel(BillingGateway dynabicBillingGateway)
 {
     //get all your products
     MyPlans = GetAllPlans(dynabicBillingGateway);
 }
Beispiel #8
0
 public TestsHelper(BillingGateway gateway)
 {
     _gateway = gateway;
     CleanupTestData();
 }