Esempio n. 1
0
        public Plan(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }
            BillingDayOfMonth = node.GetInteger("billing-day-of-month");
            BillingFrequency  = node.GetInteger("billing-frequency");
            CurrencyIsoCode   = node.GetString("currency-iso-code");
            Description       = node.GetString("description");
            Id   = node.GetString("id");
            Name = node.GetString("name");
            NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
            Price         = node.GetDecimal("price");
            TrialPeriod   = node.GetBoolean("trial-period");
            TrialDuration = node.GetInteger("trial-duration");
            String trialDurationUnitStr = node.GetString("trial-duration-unit");

            if (trialDurationUnitStr != null)
            {
                TrialDurationUnit = (PlanDurationUnit)CollectionUtil.Find(PlanDurationUnit.ALL, trialDurationUnitStr, PlanDurationUnit.UNRECOGNIZED);
            }
            AddOns = new List <AddOn> ();
            foreach (NodeWrapper addOnResponse in node.GetList("add-ons/add-on"))
            {
                AddOns.Add(new AddOn(addOnResponse));
            }
            Discounts = new List <Discount> ();
            foreach (NodeWrapper discountResponse in node.GetList("discounts/discount"))
            {
                Discounts.Add(new Discount(discountResponse));
            }
        }
Esempio n. 2
0
 public Plan(NodeWrapper node)
 {
     if (node == null) return;
     BillingDayOfMonth = node.GetInteger("billing-day-of-month");
     BillingFrequency = node.GetInteger("billing-frequency");
     CurrencyIsoCode = node.GetString("currency-iso-code");
     Description = node.GetString("description");
     Id = node.GetString("id");
     Name = node.GetString("name");
     NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
     Price = node.GetDecimal("price");
     TrialPeriod = node.GetBoolean("trial-period");
     TrialDuration = node.GetInteger("trial-duration");
     string trialDurationUnitStr = node.GetString("trial-duration-unit");
     if (trialDurationUnitStr != null) {
         TrialDurationUnit = (PlanDurationUnit) CollectionUtil.Find(PlanDurationUnit.ALL, trialDurationUnitStr, PlanDurationUnit.UNRECOGNIZED);
     }
     AddOns = new List<AddOn> ();
     foreach (var addOnResponse in node.GetList("add-ons/add-on")) {
         AddOns.Add(new AddOn(addOnResponse));
     }
     Discounts = new List<Discount> ();
     foreach (var discountResponse in node.GetList("discounts/discount")) {
         Discounts.Add(new Discount(discountResponse));
     }
 }
Esempio n. 3
0
 internal Modification(NodeWrapper node)
 {
     Amount = node.GetDecimal("amount");
     Id = node.GetString("id");
     NeverExpires = node.GetBoolean("never-expires");
     NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
     Quantity = node.GetInteger("quantity");
 }
Esempio n. 4
0
 protected Modification(NodeWrapper node)
 {
     Amount = node.GetDecimal("amount");
     CreatedAt = node.GetDateTime("created-at");
     Description = node.GetString("description");
     Id = node.GetString("id");
     Kind = node.GetString("kind");
     MerchantId = node.GetString("merchant-id");
     Name = node.GetString("name");
     NeverExpires = node.GetBoolean("never-expires");
     NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
     Quantity = node.GetInteger("quantity");
     UpdatedAt = node.GetDateTime("updated-at");
 }
Esempio n. 5
0
 protected Modification(NodeWrapper node)
 {
     Amount              = node.GetDecimal("amount");
     CreatedAt           = node.GetDateTime("created-at");
     CurrentBillingCycle = node.GetInteger("current-billing-cycle");
     Description         = node.GetString("description");
     Id                    = node.GetString("id");
     Kind                  = node.GetString("kind");
     MerchantId            = node.GetString("merchant-id");
     Name                  = node.GetString("name");
     NeverExpires          = node.GetBoolean("never-expires");
     NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
     Quantity              = node.GetInteger("quantity");
     UpdatedAt             = node.GetDateTime("updated-at");
 }
        private PaginatedResult <MerchantAccount> FetchMerchantAccounts(int page)
        {
            XmlNode merchantAccountXML = service.Get(service.MerchantPath() + "/merchant_accounts?page=" + page);
            var     nodeWrapper        = new NodeWrapper(merchantAccountXML);

            var totalItems       = nodeWrapper.GetInteger("total-items").Value;
            var pageSize         = nodeWrapper.GetInteger("page-size").Value;
            var merchantAccounts = new List <MerchantAccount>();

            foreach (var node in nodeWrapper.GetList("merchant-account"))
            {
                merchantAccounts.Add(new MerchantAccount(node));
            }

            return(new PaginatedResult <MerchantAccount>(totalItems, pageSize, merchantAccounts));
        }
Esempio n. 7
0
        private PaginatedResult <Dispute> FetchDisputes(int page)
        {
            DisputeSearchRequest request = DisputeSearch;
            XmlNode disputeXML           = Service.Post(Service.MerchantPath() + "/disputes/advanced_search?page=" + page, request);
            var     nodeWrapper          = new NodeWrapper(disputeXML);

            var totalItems = nodeWrapper.GetInteger("total-items").Value;
            var pageSize   = nodeWrapper.GetInteger("page-size").Value;
            var disputes   = new List <Dispute>();

            foreach (var node in nodeWrapper.GetList("dispute"))
            {
                disputes.Add(new Dispute(node));
            }

            return(new PaginatedResult <Dispute>(totalItems, pageSize, disputes));
        }
Esempio n. 8
0
 protected internal DisputeTransaction(NodeWrapper node)
 {
     Amount                   = node.GetDecimal("amount");
     CreatedAt                = node.GetDateTime("created-at");
     Id                       = node.GetString("id");
     InstallmentCount         = node.GetInteger("installment-count");
     OrderId                  = node.GetString("order-id");
     PaymentInstrumentSubtype = node.GetString("payment-instrument-subtype");
     PurchaseOrderNumber      = node.GetString("purchase-order-number");
 }
Esempio n. 9
0
        public Subscription(NodeWrapper node, IBraintreeGateway gateway)
        {
            Balance                = node.GetDecimal("balance");
            BillingDayOfMonth      = node.GetInteger("billing-day-of-month");
            BillingPeriodEndDate   = node.GetDateTime("billing-period-end-date");
            BillingPeriodStartDate = node.GetDateTime("billing-period-start-date");
            CurrentBillingCycle    = node.GetInteger("current-billing-cycle");
            DaysPastDue            = node.GetInteger("days-past-due");
            Descriptor             = new Descriptor(node.GetNode("descriptor"));
            Description            = node.GetString("description");
            FailureCount           = node.GetInteger("failure-count");
            FirstBillingDate       = node.GetDateTime("first-billing-date");
            CreatedAt              = node.GetDateTime("created-at");
            UpdatedAt              = node.GetDateTime("updated-at");
            Id                      = node.GetString("id");
            NextBillAmount          = node.GetDecimal("next-bill-amount");
            NextBillingDate         = node.GetDateTime("next-billing-date");
            NextBillingPeriodAmount = node.GetDecimal("next-billing-period-amount");
            NeverExpires            = node.GetBoolean("never-expires");
            NumberOfBillingCycles   = node.GetInteger("number-of-billing-cycles");
            PaymentMethodToken      = node.GetString("payment-method-token");
            PaidThroughDate         = node.GetDateTime("paid-through-date");
            PlanId                  = node.GetString("plan-id");
            Price                   = node.GetDecimal("price");
            Status                  = (SubscriptionStatus)CollectionUtil.Find(SubscriptionStatus.STATUSES, node.GetString("status"), SubscriptionStatus.UNRECOGNIZED);
            List <NodeWrapper> statusNodes = node.GetList("status-history/status-event");

            StatusHistory = new SubscriptionStatusEvent[statusNodes.Count];
            for (int i = 0; i < statusNodes.Count; i++)
            {
                StatusHistory[i] = new SubscriptionStatusEvent(statusNodes[i]);
            }
            HasTrialPeriod = node.GetBoolean("trial-period");
            TrialDuration  = node.GetInteger("trial-duration");
            var trialDurationUnitStr = node.GetString("trial-duration-unit");

            if (trialDurationUnitStr != null)
            {
                TrialDurationUnit = (SubscriptionDurationUnit)CollectionUtil.Find(SubscriptionDurationUnit.ALL, trialDurationUnitStr, SubscriptionDurationUnit.UNRECOGNIZED);
            }
            MerchantAccountId = node.GetString("merchant-account-id");

            AddOns = new List <AddOn> ();
            foreach (var addOnResponse in node.GetList("add-ons/add-on"))
            {
                AddOns.Add(new AddOn(addOnResponse));
            }
            Discounts = new List <Discount> ();
            foreach (var discountResponse in node.GetList("discounts/discount"))
            {
                Discounts.Add(new Discount(discountResponse));
            }
            Transactions = new List <Transaction> ();
            foreach (var transactionResponse in node.GetList("transactions/transaction"))
            {
                Transactions.Add(new Transaction(transactionResponse, gateway));
            }
        }
Esempio n. 10
0
        public Subscription(NodeWrapper node, BraintreeService service)
        {
            Balance = node.GetDecimal("balance");
            BillingDayOfMonth = node.GetInteger("billing-day-of-month");
            BillingPeriodEndDate = node.GetDateTime("billing-period-end-date");
            BillingPeriodStartDate = node.GetDateTime("billing-period-start-date");
            CurrentBillingCycle = node.GetInteger("current-billing-cycle");
            DaysPastDue = node.GetInteger("days-past-due");
            Descriptor = new Descriptor(node.GetNode("descriptor"));
            FailureCount = node.GetInteger("failure-count");
            FirstBillingDate = node.GetDateTime("first-billing-date");
            Id = node.GetString("id");
            NextBillAmount = node.GetDecimal("next-bill-amount");
            NextBillingDate = node.GetDateTime("next-billing-date");
            NextBillingPeriodAmount = node.GetDecimal("next-billing-period-amount");
            NeverExpires = node.GetBoolean("never-expires");
            NumberOfBillingCycles = node.GetInteger("number-of-billing-cycles");
            PaymentMethodToken = node.GetString("payment-method-token");
            PaidThroughDate = node.GetDateTime("paid-through-date");
            PlanId = node.GetString("plan-id");
            Price = node.GetDecimal("price");
            Status = (SubscriptionStatus)CollectionUtil.Find(SubscriptionStatus.STATUSES, node.GetString("status"), SubscriptionStatus.UNRECOGNIZED);
            HasTrialPeriod = node.GetBoolean("trial-period");
            TrialDuration = node.GetInteger("trial-duration");
            String trialDurationUnitStr = node.GetString("trial-duration-unit");
            if (trialDurationUnitStr != null) {
                TrialDurationUnit = (SubscriptionDurationUnit)CollectionUtil.Find(SubscriptionDurationUnit.ALL, trialDurationUnitStr, SubscriptionDurationUnit.UNRECOGNIZED);
            }
            MerchantAccountId = node.GetString("merchant-account-id");

            AddOns = new List<AddOn> ();
            foreach (NodeWrapper addOnResponse in node.GetList("add-ons/add-on")) {
                AddOns.Add(new AddOn(addOnResponse));
            }
            Discounts = new List<Discount> ();
            foreach (NodeWrapper discountResponse in node.GetList("discounts/discount")) {
                Discounts.Add(new Discount(discountResponse));
            }
            Transactions = new List<Transaction> ();
            foreach (NodeWrapper transactionResponse in node.GetList("transactions/transaction")) {
                Transactions.Add(new Transaction(transactionResponse, service));
            }
        }