Example #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 (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));
     }
 }
Example #2
0
        internal Customer(NodeWrapper node, BraintreeService service)
        {
            if (node == null) return;

            Id = node.GetString("id");
            FirstName = node.GetString("first-name");
            LastName = node.GetString("last-name");
            Company = node.GetString("company");
            Email = node.GetString("email");
            Phone = node.GetString("phone");
            Fax = node.GetString("fax");
            Website = node.GetString("website");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var creditCardXmlNodes = node.GetList("credit-cards/credit-card");
            CreditCards = new CreditCard[creditCardXmlNodes.Count];
            for (int i = 0; i < creditCardXmlNodes.Count; i++)
            {
                CreditCards[i] = new CreditCard(creditCardXmlNodes[i], service);
            }

            var addressXmlNodes = node.GetList("addresses/address");
            Addresses = new Address[addressXmlNodes.Count];
            for (int i = 0; i < addressXmlNodes.Count; i++)
            {
                Addresses[i] = new Address(addressXmlNodes[i]);
            }

            CustomFields = node.GetDictionary("custom-fields");
        }
Example #3
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));
            }
        }
        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));
            }
        }
Example #5
0
        public Dispute(NodeWrapper node)
        {
            Amount          = node.GetDecimal("amount");
            AmountDisputed  = node.GetDecimal("amount-disputed");
            AmountWon       = node.GetDecimal("amount-won");
            CreatedAt       = node.GetDateTime("created-at");
            DateOpened      = node.GetDateTime("date-opened");
            DateWon         = node.GetDateTime("date-won");
            ReceivedDate    = node.GetDateTime("received-date");
            ReplyByDate     = node.GetDateTime("reply-by-date");
            UpdatedAt       = node.GetDateTime("updated-at");
            Reason          = node.GetEnum("reason", DisputeReason.GENERAL);
            Status          = node.GetEnum("status", DisputeStatus.UNRECOGNIZED);
            Kind            = node.GetEnum("kind", DisputeKind.UNRECOGNIZED);
            CaseNumber      = node.GetString("case-number");
            CurrencyIsoCode = node.GetString("currency-iso-code");
            GraphQLId       = node.GetString("global-id");
            Id = node.GetString("id");
            ProcessorComments = node.GetString("processor-comments");
            MerchantAccountId = node.GetString("merchant-account-id");
            OriginalDisputeId = node.GetString("original-dispute-id");
            ReasonCode        = node.GetString("reason-code");
            ReasonDescription = node.GetString("reason-description");
            ReferenceNumber   = node.GetString("reference-number");

            if (node.GetNode("transaction") != null)
            {
                TransactionDetails = new TransactionDetails(node.GetNode("transaction"));
                Transaction        = new DisputeTransaction(node.GetNode("transaction"));
            }

            Evidence = new List <DisputeEvidence>();
            foreach (var evidenceResponse in node.GetList("evidence/evidence"))
            {
                Evidence.Add(new DisputeEvidence(evidenceResponse));
            }

            PayPalMessages = new List <DisputePayPalMessage>();
            foreach (var paypalMessageResponse in node.GetList("paypal-messages/paypal-messages"))
            {
                PayPalMessages.Add(new DisputePayPalMessage(paypalMessageResponse));
            }

            StatusHistory = new List <DisputeStatusHistory>();
            foreach (var historyStatusResponse in node.GetList("status-history/status-history"))
            {
                StatusHistory.Add(new DisputeStatusHistory(historyStatusResponse));
            }
        }
Example #6
0
        protected internal CreditCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (node == null)
            {
                return;
            }

            Bin                    = node.GetString("bin");
            CardholderName         = node.GetString("cardholder-name");
            CardType               = node.GetEnum("card-type", CreditCardCardType.UNRECOGNIZED);
            CustomerId             = node.GetString("customer-id");
            IsDefault              = node.GetBoolean("default");
            IsVenmoSdk             = node.GetBoolean("venmo-sdk");
            ExpirationMonth        = node.GetString("expiration-month");
            ExpirationYear         = node.GetString("expiration-year");
            IsExpired              = node.GetBoolean("expired");
            IsNetworkTokenized     = node.GetBoolean("is-network-tokenized");
            CustomerLocation       = node.GetEnum("customer-location", CreditCardCustomerLocation.UNRECOGNIZED);
            LastFour               = node.GetString("last-4");
            UniqueNumberIdentifier = node.GetString("unique-number-identifier");
            Token                  = node.GetString("token");
            CreatedAt              = node.GetDateTime("created-at");
            UpdatedAt              = node.GetDateTime("updated-at");
            BillingAddress         = new Address(node.GetNode("billing-address"));
            Prepaid                = node.GetEnum("prepaid", CreditCardPrepaid.UNKNOWN);
            Payroll                = node.GetEnum("payroll", CreditCardPayroll.UNKNOWN);
            DurbinRegulated        = node.GetEnum("durbin-regulated", CreditCardDurbinRegulated.UNKNOWN);
            Debit                  = node.GetEnum("debit", CreditCardDebit.UNKNOWN);
            Commercial             = node.GetEnum("commercial", CreditCardCommercial.UNKNOWN);
            Healthcare             = node.GetEnum("healthcare", CreditCardHealthcare.UNKNOWN);
            AccountType            = node.GetString("account-type");
            _CountryOfIssuance     = node.GetString("country-of-issuance");
            _IssuingBank           = node.GetString("issuing-bank");
            _ProductId             = node.GetString("product-id");
            ImageUrl               = node.GetString("image-url");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");

            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }

            var verificationNodes = node.GetList("verifications/verification");

            Verification = FindLatestVerification(verificationNodes, gateway);
        }
        protected internal ApplePayCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            CardType              = node.GetString("card-type");
            Last4                 = node.GetString("last-4");
            ExpirationMonth       = node.GetString("expiration-month");
            ExpirationYear        = node.GetString("expiration-year");
            Token                 = node.GetString("token");
            PaymentInstrumentName = node.GetString("payment-instrument-name");
            SourceDescription     = node.GetString("source-description");
            IsDefault             = node.GetBoolean("default");
            IsExpired             = node.GetBoolean("expired");
            ImageUrl              = node.GetString("image-url");
            CustomerId            = node.GetString("customer-id");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");

            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
Example #8
0
        public Merchant(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }

            NodeWrapper merchantNode = node.GetNode("merchant");

            Id                 = merchantNode.GetString("id");
            Email              = merchantNode.GetString("email");
            CompanyName        = merchantNode.GetString("company-name");
            CountryCodeAlpha3  = merchantNode.GetString("country-code-alpha3");
            CountryCodeAlpha2  = merchantNode.GetString("country-code-alpha2");
            CountryCodeNumeric = merchantNode.GetString("country-code-numeric");
            CountryName        = merchantNode.GetString("country-name");

            Credentials = new OAuthCredentials(node.GetNode("credentials"));

            var merchantAccountXmlNodes = merchantNode.GetList("merchant-accounts/merchant-account");

            MerchantAccounts = new MerchantAccount[merchantAccountXmlNodes.Count];
            for (int i = 0; i < merchantAccountXmlNodes.Count; i++)
            {
                MerchantAccounts[i] = new MerchantAccount(merchantAccountXmlNodes[i]);
            }
        }
Example #9
0
        protected internal AmexExpressCheckoutCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            Token                = node.GetString("token");
            CardType             = node.GetString("card-type");
            Bin                  = node.GetString("bin");
            ExpirationMonth      = node.GetString("expiration-month");
            ExpirationYear       = node.GetString("expiration-year");
            CardMemberNumber     = node.GetString("card-member-number");
            CardMemberExpiryDate = node.GetString("card-member-expiry-date");
            SourceDescription    = node.GetString("source-description");
            IsDefault            = node.GetBoolean("default");
            ImageUrl             = node.GetString("image-url");
            CustomerId           = node.GetString("customer-id");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");

            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
        protected internal AndroidPayCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            CardType = node.GetString("virtual-card-type");
            VirtualCardType = node.GetString("virtual-card-type");
            SourceCardType = node.GetString("source-card-type");
            Last4 = node.GetString("virtual-card-last-4");
            SourceCardLast4 = node.GetString("source-card-last-4");
            VirtualCardLast4 = node.GetString("virtual-card-last-4");
            SourceDescription = node.GetString("source-description");
            Bin = node.GetString("bin");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            GoogleTransactionId = node.GetString("google-transaction-id");
            Token = node.GetString("token");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");
            CustomerId = node.GetString("customer-id");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
Example #11
0
        protected internal AndroidPayCard(NodeWrapper node, BraintreeGateway gateway)
        {
            CardType         = node.GetString("virtual-card-type");
            VirtualCardType  = node.GetString("virtual-card-type");
            SourceCardType   = node.GetString("source-card-type");
            Last4            = node.GetString("virtual-card-last-4");
            SourceCardLast4  = node.GetString("source-card-last-4");
            VirtualCardLast4 = node.GetString("virtual-card-last-4");
            Bin                 = node.GetString("bin");
            ExpirationMonth     = node.GetString("expiration-month");
            ExpirationYear      = node.GetString("expiration-year");
            GoogleTransactionId = node.GetString("google-transaction-id");
            Token               = node.GetString("token");
            IsDefault           = node.GetBoolean("default");
            ImageUrl            = node.GetString("image-url");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");

            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
        protected internal SettlementBatchSummary(NodeWrapper node)
        {
            records = new List <IDictionary <string, string> >();

            foreach (var record in node.GetList("records/record"))
            {
                records.Add(record.GetDictionary("."));
            }
        }
        protected internal SettlementBatchSummary (NodeWrapper node)
        {
            records = new List<IDictionary<String, String>>();

            foreach (var record in node.GetList("records/record"))
            {
                records.Add(record.GetDictionary("."));
            }
        }
Example #14
0
        public Dispute(NodeWrapper node)
        {
            Amount          = node.GetDecimal("amount");
            AmountDisputed  = node.GetDecimal("amount-disputed");
            AmountWon       = node.GetDecimal("amount-won");
            CreatedAt       = node.GetDateTime("created-at");
            DateOpened      = node.GetDateTime("date-opened");
            DateWon         = node.GetDateTime("date-won");
            ReceivedDate    = node.GetDateTime("received-date");
            ReplyByDate     = node.GetDateTime("reply-by-date");
            UpdatedAt       = node.GetDateTime("updated-at");
            Reason          = (DisputeReason)CollectionUtil.Find(DisputeReason.ALL, node.GetString("reason"), DisputeReason.GENERAL);
            Status          = (DisputeStatus)CollectionUtil.Find(DisputeStatus.ALL, node.GetString("status"), DisputeStatus.UNRECOGNIZED);
            Kind            = (DisputeKind)CollectionUtil.Find(DisputeKind.ALL, node.GetString("kind"), DisputeKind.UNRECOGNIZED);
            CaseNumber      = node.GetString("case-number");
            CurrencyIsoCode = node.GetString("currency-iso-code");
            Id = node.GetString("id");
            ForwardedComments = node.GetString("forwarded-comments");
            MerchantAccountId = node.GetString("merchant-account-id");
            OriginalDisputeId = node.GetString("original-dispute-id");
            ReasonCode        = node.GetString("reason-code");
            ReasonDescription = node.GetString("reason-description");
            ReferenceNumber   = node.GetString("reference-number");

            if (node.GetNode("transaction") != null)
            {
                TransactionDetails = new TransactionDetails(node.GetNode("transaction"));
                Transaction        = new DisputeTransaction(node.GetNode("transaction"));
            }

            Evidence = new List <DisputeEvidence>();
            foreach (var evidenceResponse in node.GetList("evidence/evidence"))
            {
                Evidence.Add(new DisputeEvidence(evidenceResponse));
            }

            StatusHistory = new List <DisputeStatusHistory>();
            foreach (var historyStatusResponse in node.GetList("status-history/status-history"))
            {
                StatusHistory.Add(new DisputeStatusHistory(historyStatusResponse));
            }
        }
        public virtual List<Plan> All()
        {
            var response = new NodeWrapper(service.Get(service.MerchantPath() + "/plans"));

            var plans = new List<Plan>();
            foreach (var node in response.GetList("plan"))
            {
                plans.Add(new Plan(node));
            }
            return plans;
        }
        public virtual List<Discount> All()
        {
            var response = new NodeWrapper(service.Get(service.MerchantPath() + "/discounts"));

            var discounts = new List<Discount>();
            foreach (var node in response.GetList("discount"))
            {
                discounts.Add(new Discount(node));
            }
            return discounts;
        }
Example #17
0
        public virtual List<Plan> All()
        {
            NodeWrapper response = new NodeWrapper(Service.Get("/plans"));

            List<Plan> plans = new List<Plan>();
            foreach (NodeWrapper node in response.GetList("plan"))
            {
                plans.Add(new Plan(node));
            }
            return plans;
        }
        public virtual List<AddOn> All()
        {
            var response = new NodeWrapper(Service.Get(Service.MerchantPath() + "/add_ons"));

            var addOns = new List<AddOn>();
            foreach (var node in response.GetList("add-on"))
            {
                addOns.Add(new AddOn(node));
            }
            return addOns;
        }
Example #19
0
        public virtual List <Plan> All()
        {
            var response = new NodeWrapper(service.Get(service.MerchantPath() + "/plans"));

            var plans = new List <Plan>();

            foreach (var node in response.GetList("plan"))
            {
                plans.Add(new Plan(node));
            }
            return(plans);
        }
Example #20
0
        public virtual async Task <List <AddOn> > AllAsync()
        {
            var response = new NodeWrapper(await Service.GetAsync(Service.MerchantPath() + "/add_ons").ConfigureAwait(false));

            var addOns = new List <AddOn>();

            foreach (var node in response.GetList("add-on"))
            {
                addOns.Add(new AddOn(node));
            }
            return(addOns);
        }
        public virtual async Task <List <Discount> > AllAsync()
        {
            var response = new NodeWrapper(await service.GetAsync(service.MerchantPath() + "/discounts"));

            var discounts = new List <Discount>();

            foreach (var node in response.GetList("discount"))
            {
                discounts.Add(new Discount(node));
            }
            return(discounts);
        }
Example #22
0
        public virtual List <AddOn> All()
        {
            var response = new NodeWrapper(Service.Get(Service.MerchantPath() + "/add_ons"));

            var addOns = new List <AddOn>();

            foreach (var node in response.GetList("add-on"))
            {
                addOns.Add(new AddOn(node));
            }
            return(addOns);
        }
Example #23
0
 protected internal Installment(NodeWrapper node)
 {
     Amount = node.GetDecimal("amount");
     Id     = node.GetString("id");
     ProjectedDisbursementDate = node.GetDateTime("projected_disbursement_date");
     ActualDisbursementDate    = node.GetDateTime("actual_disbursement_date");
     Adjustments = new List <Adjustment>();
     foreach (var adjustmentNode in node.GetList("adjustments/adjustment"))
     {
         Adjustments.Add(new Adjustment(adjustmentNode));
     }
 }
Example #24
0
        public virtual List <Plan> All()
        {
            NodeWrapper response = new NodeWrapper(Service.Get("/plans"));

            List <Plan> plans = new List <Plan>();

            foreach (NodeWrapper node in response.GetList("plan"))
            {
                plans.Add(new Plan(node));
            }
            return(plans);
        }
Example #25
0
        public virtual List <AddOn> All()
        {
            NodeWrapper response = new NodeWrapper(Service.Get("/add_ons"));

            List <AddOn> addOns = new List <AddOn>();

            foreach (NodeWrapper node in response.GetList("add-on"))
            {
                addOns.Add(new AddOn(node));
            }
            return(addOns);
        }
Example #26
0
        public virtual async Task <List <Plan> > AllAsync()
        {
            var response = new NodeWrapper(await service.GetAsync(service.MerchantPath() + "/plans").ConfigureAwait(false));

            var plans = new List <Plan>();

            foreach (var node in response.GetList("plan"))
            {
                plans.Add(new Plan(node));
            }
            return(plans);
        }
Example #27
0
        public virtual List <Discount> All()
        {
            NodeWrapper response = new NodeWrapper(Service.Get("/discounts"));

            List <Discount> discounts = new List <Discount>();

            foreach (NodeWrapper node in response.GetList("discount"))
            {
                discounts.Add(new Discount(node));
            }
            return(discounts);
        }
        private List<Subscription> FetchSubscriptions(SubscriptionSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/subscriptions/advanced_search", query));

            List<Subscription> subscriptions = new List<Subscription>();
            foreach (NodeWrapper node in response.GetList("subscription"))
            {
                subscriptions.Add(new Subscription(node, Service));
            }
            return subscriptions;
        }
        private List<CreditCardVerification> FetchCreditCardVerifications(CreditCardVerificationSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/verifications/advanced_search", query));

            List<CreditCardVerification> verifications = new List<CreditCardVerification>();
            foreach (NodeWrapper node in response.GetList("verification"))
            {
                verifications.Add(new CreditCardVerification(node, Service));
            }
            return verifications;
        }
        protected internal GrantedPaymentInstrumentUpdate(NodeWrapper node)
        {
            PaymentMethodNonce       = node.GetString("payment-method-nonce/nonce");
            GrantOwnerMerchantId     = node.GetString("grant-owner-merchant-id");
            GrantRecipientMerchantId = node.GetString("grant-recipient-merchant-id");
            Token = node.GetString("token");

            UpdatedFields = new List <string>();
            foreach (var field in node.GetList("updated-fields/item"))
            {
                UpdatedFields.Add(field.GetString("."));
            }
        }
        private List<Transaction> FetchTransactions(TransactionSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/transactions/advanced_search", query));

            List<Transaction> transactions = new List<Transaction>();
            foreach (NodeWrapper node in response.GetList("transaction"))
            {
                transactions.Add(new Transaction(node, Service));
            }
            return transactions;
        }
        private List<CreditCardVerification> FetchCreditCardVerifications(CreditCardVerificationSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/verifications/advanced_search", query));

            var verifications = new List<CreditCardVerification>();
            foreach (var node in response.GetList("verification"))
            {
                verifications.Add(new CreditCardVerification(node, gateway));
            }
            return verifications;
        }
        private List<Customer> FetchCustomers(String[] ids)
        {
            IdsSearchRequest query = new IdsSearchRequest().
                Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/customers/advanced_search", query));

            List<Customer> customers = new List<Customer>();
            foreach (NodeWrapper node in response.GetList("customer"))
            {
                customers.Add(new Customer(node, Service));
            }
            return customers;
        }
        // TODO async delegate in ResourceCollection constructor
        private async Task <List <Transaction> > FetchTransactionsAsync(TransactionSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(await service.PostAsync(service.MerchantPath() + "/transactions/advanced_search", query));

            var transactions = new List <Transaction>();

            foreach (var node in response.GetList("transaction"))
            {
                transactions.Add(new Transaction(node, gateway));
            }
            return(transactions);
        }
Example #35
0
        private List <Subscription> FetchSubscriptions(SubscriptionSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/subscriptions/advanced_search", query));

            List <Subscription> subscriptions = new List <Subscription>();

            foreach (NodeWrapper node in response.GetList("subscription"))
            {
                subscriptions.Add(new Subscription(node, Service));
            }
            return(subscriptions);
        }
Example #36
0
        private List <CreditCardVerification> FetchCreditCardVerifications(CreditCardVerificationSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/verifications/advanced_search", query));

            var verifications = new List <CreditCardVerification>();

            foreach (var node in response.GetList("verification"))
            {
                verifications.Add(new CreditCardVerification(node, gateway));
            }
            return(verifications);
        }
        private List <Subscription> FetchSubscriptions(SubscriptionSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/subscriptions/advanced_search", query));

            var subscriptions = new List <Subscription>();

            foreach (var node in response.GetList("subscription"))
            {
                subscriptions.Add(new Subscription(node, gateway));
            }
            return(subscriptions);
        }
Example #38
0
        private List <Customer> FetchCustomers(CustomerSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/customers/advanced_search", query));

            var customers = new List <Customer>();

            foreach (var node in response.GetList("customer"))
            {
                customers.Add(new Customer(node, gateway));
            }
            return(customers);
        }
Example #39
0
        private List <Customer> FetchCustomers(CustomerSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/customers/advanced_search", query));

            List <Customer> customers = new List <Customer>();

            foreach (NodeWrapper node in response.GetList("customer"))
            {
                customers.Add(new Customer(node, Service));
            }
            return(customers);
        }
Example #40
0
        private List <UsBankAccountVerification> FetchUsBankAccountVerifications(UsBankAccountVerificationSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/us_bank_account_verifications/advanced_search", query));

            var verifications = new List <UsBankAccountVerification>();

            foreach (var node in response.GetList("us-bank-account-verification"))
            {
                verifications.Add(new UsBankAccountVerification(node));
            }
            return(verifications);
        }
        private List <CreditCardVerification> FetchCreditCardVerifications(CreditCardVerificationSearchRequest query, String[] ids)
        {
            query.Ids.IncludedIn(ids);

            NodeWrapper response = new NodeWrapper(Service.Post("/verifications/advanced_search", query));

            List <CreditCardVerification> verifications = new List <CreditCardVerification>();

            foreach (NodeWrapper node in response.GetList("verification"))
            {
                verifications.Add(new CreditCardVerification(node, Service));
            }
            return(verifications);
        }
Example #42
0
        protected internal PayPalAccount(NodeWrapper node, BraintreeGateway gateway)
        {
            Email = node.GetString("email");
            Token = node.GetString("token");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
        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));
        }
Example #44
0
 public Disbursement(NodeWrapper node, BraintreeGateway gateway)
 {
     Id = node.GetString("id");
     Amount = node.GetDecimal("amount");
     ExceptionMessage = node.GetString("exception-message");
     DisbursementDate = node.GetDateTime("disbursement-date");
     FollowUpAction = node.GetString("follow-up-action");
     MerchantAccount = new MerchantAccount(node.GetNode("merchant-account"));
     TransactionIds = new List<string>();
     foreach (var stringNode in node.GetList("transaction-ids/item")) 
     {
         TransactionIds.Add(stringNode.GetString("."));
     }
     Success = node.GetBoolean("success");
     Retry = node.GetBoolean("retry");
     this.gateway = gateway;
 }
        public virtual ResourceCollection<CreditCard> Expired()
        {
            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/payment_methods/all/expired_ids"));

            return new ResourceCollection<CreditCard>(response, delegate(string[] ids) {
                var query = new IdsSearchRequest().
                    Ids.IncludedIn(ids);

                var fetchResponse = new NodeWrapper(service.Post(service.MerchantPath() + "/payment_methods/all/expired", query));

                var creditCards = new List<CreditCard>();
                foreach (var node in fetchResponse.GetList("credit-card"))
                {
                    creditCards.Add(new CreditCard(node, gateway));
                }
                return creditCards;
            });
        }
        public virtual ResourceCollection<CreditCard> Expired()
        {
            NodeWrapper response = new NodeWrapper(Service.Post("/payment_methods/all/expired_ids"));

            return new ResourceCollection<CreditCard>(response, delegate(String[] ids) {
                IdsSearchRequest query = new IdsSearchRequest().
                    Ids.IncludedIn(ids);

                NodeWrapper fetchResponse = new NodeWrapper(Service.Post("/payment_methods/all/expired", query));

                List<CreditCard> creditCards = new List<CreditCard>();
                foreach (NodeWrapper node in fetchResponse.GetList("credit-card"))
                {
                    creditCards.Add(new CreditCard(node, Service));
                }
                return creditCards;
            });
        }
Example #47
0
        protected internal CoinbaseAccount(NodeWrapper node, BraintreeService service)
        {
            UserId = node.GetString("user-id");
            UserEmail = node.GetString("user-email");
            UserName = node.GetString("user-name");

            Token = node.GetString("token");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], service);
            }
        }
        public virtual ResourceCollection<CreditCard> ExpiringBetween(DateTime start, DateTime end)
        {
            String queryString = String.Format("start={0:MMyyyy}&end={1:MMyyyy}", start, end);

            NodeWrapper response = new NodeWrapper(Service.Post("/payment_methods/all/expiring_ids?" + queryString));

            return new ResourceCollection<CreditCard>(response, delegate(String[] ids) {
                IdsSearchRequest query = new IdsSearchRequest().
                    Ids.IncludedIn(ids);

                NodeWrapper fetchResponse = new NodeWrapper(Service.Post("/payment_methods/all/expiring?" + queryString, query));

                List<CreditCard> creditCards = new List<CreditCard>();
                foreach (NodeWrapper node in fetchResponse.GetList("credit-card"))
                {
                    creditCards.Add(new CreditCard(node, Service));
                }
                return creditCards;
            });
        }
        protected internal VenmoAccount(NodeWrapper node, IBraintreeGateway gateway)
        {
            Token = node.GetString("token");
            Username = node.GetString("username");
            VenmoUserId = node.GetString("venmo-user-id");
            SourceDescription = node.GetString("source-description");
            ImageUrl = node.GetString("image-url");

            IsDefault = node.GetBoolean("default");
            CustomerId = node.GetString("customer-id");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
Example #50
0
        protected internal ApplePayCard(NodeWrapper node, BraintreeGateway gateway)
        {
            CardType = node.GetString("card-type");
            Last4 = node.GetString("last-4");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            Token = node.GetString("token");
            PaymentInstrumentName = node.GetString("payment-instrument-name");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
        protected internal AmexExpressCheckoutCard(NodeWrapper node, BraintreeGateway gateway)
        {
            Token = node.GetString("token");
            CardType = node.GetString("card-type");
            Bin = node.GetString("bin");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            CardMemberNumber = node.GetString("card-member-number");
            CardMemberExpiryDate = node.GetString("card-member-expiry-date");
            SourceDescription = node.GetString("source-description");
            IsDefault = node.GetBoolean("default");
            ImageUrl = node.GetString("image-url");
            CustomerId = node.GetString("customer-id");

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }
        }
Example #52
0
        internal CreditCard(NodeWrapper node, BraintreeService service)
        {
            if (node == null) return;

            Bin = node.GetString("bin");
            CardholderName = node.GetString("cardholder-name");
            CardType = (CreditCardCardType)CollectionUtil.Find(CreditCardCardType.ALL, node.GetString("card-type"), CreditCardCardType.UNRECOGNIZED);
            CustomerId = node.GetString("customer-id");
            IsDefault = node.GetBoolean("default");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            IsExpired = node.GetBoolean("expired");
            CustomerLocation = (CreditCardCustomerLocation)CollectionUtil.Find(CreditCardCustomerLocation.ALL, node.GetString("customer-location"), CreditCardCustomerLocation.UNRECOGNIZED);
            LastFour = node.GetString("last-4");
            Token = node.GetString("token");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");
            BillingAddress = new Address(node.GetNode("billing-address"));

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], service);
            }
        }
Example #53
0
        internal Transaction(NodeWrapper node, BraintreeService service)
        {
            Service = service;

            if (node == null) return;

            Id = node.GetString("id");
            Amount = node.GetDecimal("amount");
            AvsErrorResponseCode = node.GetString("avs-error-response-code");
            AvsPostalCodeResponseCode = node.GetString("avs-postal-code-response-code");
            AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code");
            GatewayRejectionReason = (TransactionGatewayRejectionReason)CollectionUtil.Find(
                TransactionGatewayRejectionReason.ALL,
                node.GetString("gateway-rejection-reason"),
                null
            );
            OrderId = node.GetString("order-id");
            Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);

            List<NodeWrapper> statusNodes = node.GetList("status-history/status-event");
            StatusHistory = new StatusEvent[statusNodes.Count];
            for (int i = 0; i < statusNodes.Count; i++)
            {
                StatusHistory[i] = new StatusEvent(statusNodes[i]);
            }

            Type = (TransactionType)CollectionUtil.Find(TransactionType.ALL, node.GetString("type"), TransactionType.UNRECOGNIZED);
            MerchantAccountId = node.GetString("merchant-account-id");
            ProcessorAuthorizationCode = node.GetString("processor-authorization-code");
            ProcessorResponseCode = node.GetString("processor-response-code");
            ProcessorResponseText = node.GetString("processor-response-text");
            PurchaseOrderNumber = node.GetString("purchase-order-number");
            RefundedTransactionId = node.GetString("refunded-transaction-id");

            #pragma warning disable 0618
            RefundId = node.GetString("refund-id");
            #pragma warning restore 0618

            RefundIds = node.GetStrings("refund-ids/*");
            SettlementBatchId = node.GetString("settlement-batch-id");
            SubscriptionId = node.GetString("subscription-id");
            TaxAmount = node.GetDecimal("tax-amount");
            TaxExempt = node.GetBoolean("tax-exempt");
            CustomFields = node.GetDictionary("custom-fields");
            CreditCard = new CreditCard(node.GetNode("credit-card"), service);
            Subscription = new Subscription(node.GetNode("subscription"), service);
            Customer = new Customer(node.GetNode("customer"), service);
            CurrencyIsoCode = node.GetString("currency-iso-code");
            CvvResponseCode = node.GetString("cvv-response-code");
            Descriptor = new Descriptor(node.GetNode("descriptor"));

            BillingAddress = new Address(node.GetNode("billing"));
            ShippingAddress = new Address(node.GetNode("shipping"));

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            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));
            }
        }
Example #54
0
        protected internal CreditCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (node == null) return;

            Bin = node.GetString("bin");
            CardholderName = node.GetString("cardholder-name");
            CardType = (CreditCardCardType)CollectionUtil.Find(CreditCardCardType.ALL, node.GetString("card-type"), CreditCardCardType.UNRECOGNIZED);
            CustomerId = node.GetString("customer-id");
            IsDefault = node.GetBoolean("default");
            IsVenmoSdk = node.GetBoolean("venmo-sdk");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear = node.GetString("expiration-year");
            IsExpired = node.GetBoolean("expired");
            CustomerLocation = (CreditCardCustomerLocation)CollectionUtil.Find(CreditCardCustomerLocation.ALL, node.GetString("customer-location"), CreditCardCustomerLocation.UNRECOGNIZED);
            LastFour = node.GetString("last-4");
            UniqueNumberIdentifier = node.GetString("unique-number-identifier");
            Token = node.GetString("token");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");
            BillingAddress = new Address(node.GetNode("billing-address"));
            Prepaid = (CreditCardPrepaid)CollectionUtil.Find(CreditCardPrepaid.ALL, node.GetString("prepaid"), CreditCardPrepaid.UNKNOWN);
            Payroll = (CreditCardPayroll)CollectionUtil.Find(CreditCardPayroll.ALL, node.GetString("payroll"), CreditCardPayroll.UNKNOWN);
            DurbinRegulated = (CreditCardDurbinRegulated)CollectionUtil.Find(CreditCardDurbinRegulated.ALL, node.GetString("durbin-regulated"), CreditCardDurbinRegulated.UNKNOWN);
            Debit = (CreditCardDebit)CollectionUtil.Find(CreditCardDebit.ALL, node.GetString("debit"), CreditCardDebit.UNKNOWN);
            Commercial = (CreditCardCommercial)CollectionUtil.Find(CreditCardCommercial.ALL, node.GetString("commercial"), CreditCardCommercial.UNKNOWN);
            Healthcare = (CreditCardHealthcare)CollectionUtil.Find(CreditCardHealthcare.ALL, node.GetString("healthcare"), CreditCardHealthcare.UNKNOWN);
            _CountryOfIssuance = node.GetString("country-of-issuance");
            _IssuingBank = node.GetString("issuing-bank");
            ImageUrl = node.GetString("image-url");

            var subscriptionXmlNodes = node.GetList("subscriptions/subscription");
            Subscriptions = new Subscription[subscriptionXmlNodes.Count];
            for (int i = 0; i < subscriptionXmlNodes.Count; i++)
            {
                Subscriptions[i] = new Subscription(subscriptionXmlNodes[i], gateway);
            }

            var verificationNodes = node.GetList("verifications/verification");
            Verification = FindLatestVerification(verificationNodes, gateway);
        }
        private List<Customer> FetchCustomers(CustomerSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/customers/advanced_search", query));

            var customers = new List<Customer>();
            foreach (var node in response.GetList("customer"))
            {
                customers.Add(new Customer(node, gateway));
            }
            return customers;
        }
        private List<Transaction> FetchTransactions(TransactionSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/transactions/advanced_search", query));

            var transactions = new List<Transaction>();
            foreach (var node in response.GetList("transaction"))
            {
                transactions.Add(new Transaction(node, gateway));
            }
            return transactions;
        }
Example #57
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));
            }
        }
        private List<Subscription> FetchSubscriptions(SubscriptionSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/subscriptions/advanced_search", query));

            var subscriptions = new List<Subscription>();
            foreach (var node in response.GetList("subscription"))
            {
                subscriptions.Add(new Subscription(node, gateway));
            }
            return subscriptions;
        }
        protected internal Customer(NodeWrapper node, BraintreeGateway gateway)
        {
            if (node == null) return;

            Id = node.GetString("id");
            FirstName = node.GetString("first-name");
            LastName = node.GetString("last-name");
            Company = node.GetString("company");
            Email = node.GetString("email");
            Phone = node.GetString("phone");
            Fax = node.GetString("fax");
            Website = node.GetString("website");
            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            var creditCardXmlNodes = node.GetList("credit-cards/credit-card");
            CreditCards = new CreditCard[creditCardXmlNodes.Count];
            for (int i = 0; i < creditCardXmlNodes.Count; i++)
            {
                CreditCards[i] = new CreditCard(creditCardXmlNodes[i], gateway);
            }

            var paypalXmlNodes = node.GetList("paypal-accounts/paypal-account");
            PayPalAccounts = new PayPalAccount[paypalXmlNodes.Count];
            for (int i = 0; i < paypalXmlNodes.Count; i++)
            {
                PayPalAccounts[i] = new PayPalAccount(paypalXmlNodes[i], gateway);
            }

            var applePayXmlNodes = node.GetList("apple-pay-cards/apple-pay-card");
            ApplePayCards = new ApplePayCard[applePayXmlNodes.Count];
            for (int i = 0; i < applePayXmlNodes.Count; i++)
            {
                ApplePayCards[i] = new ApplePayCard(applePayXmlNodes[i], gateway);
            }

            var androidPayCardXmlNodes = node.GetList("android-pay-cards/android-pay-card");
            AndroidPayCards = new AndroidPayCard[androidPayCardXmlNodes.Count];
            for (int i = 0; i < androidPayCardXmlNodes.Count; i++)
            {
                AndroidPayCards[i] = new AndroidPayCard(androidPayCardXmlNodes[i], gateway);
            }

            var amexExpressCheckoutCardXmlNodes = node.GetList("amex-express-checkout-cards/amex-express-checkout-card");
            AmexExpressCheckoutCards = new AmexExpressCheckoutCard[amexExpressCheckoutCardXmlNodes.Count];
            for (int i = 0; i < amexExpressCheckoutCardXmlNodes.Count; i++)
            {
                AmexExpressCheckoutCards[i] = new AmexExpressCheckoutCard(amexExpressCheckoutCardXmlNodes[i], gateway);
            }

            var coinbaseXmlNodes = node.GetList("coinbase-accounts/coinbase-account");
            CoinbaseAccounts = new CoinbaseAccount[coinbaseXmlNodes.Count];
            for (int i = 0; i < coinbaseXmlNodes.Count; i++)
            {
                CoinbaseAccounts[i] = new CoinbaseAccount(coinbaseXmlNodes[i], gateway);
            }

            var venmoAccountXmlNodes = node.GetList("venmo-accounts/venmo-account");
            VenmoAccounts = new VenmoAccount[venmoAccountXmlNodes.Count];
            for (int i = 0; i < venmoAccountXmlNodes.Count; i++)
            {
                VenmoAccounts[i] = new VenmoAccount(venmoAccountXmlNodes[i], gateway);
            }

            PaymentMethods = new PaymentMethod[
                CreditCards.Length
                + PayPalAccounts.Length
                + ApplePayCards.Length
                + CoinbaseAccounts.Length
                + AndroidPayCards.Length
                + AmexExpressCheckoutCards.Length
                + VenmoAccounts.Length
            ];

            CreditCards.CopyTo(PaymentMethods, 0);
            PayPalAccounts.CopyTo(PaymentMethods, CreditCards.Length);
            ApplePayCards.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length);
            CoinbaseAccounts.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length);
            AndroidPayCards.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length);
            AmexExpressCheckoutCards.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length + AndroidPayCards.Length);
            VenmoAccounts.CopyTo(PaymentMethods, CreditCards.Length + PayPalAccounts.Length + ApplePayCards.Length + CoinbaseAccounts.Length + AndroidPayCards.Length + AmexExpressCheckoutCards.Length);

            var addressXmlNodes = node.GetList("addresses/address");
            Addresses = new Address[addressXmlNodes.Count];
            for (int i = 0; i < addressXmlNodes.Count; i++)
            {
                Addresses[i] = new Address(addressXmlNodes[i]);
            }

            CustomFields = node.GetDictionary("custom-fields");
        }
Example #60
0
        protected internal Transaction(NodeWrapper node, BraintreeGateway gateway)
        {
            Gateway = gateway;

            if (node == null) return;

            Id = node.GetString("id");
            Amount = node.GetDecimal("amount");
            AvsErrorResponseCode = node.GetString("avs-error-response-code");
            AvsPostalCodeResponseCode = node.GetString("avs-postal-code-response-code");
            AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code");
            GatewayRejectionReason = (TransactionGatewayRejectionReason)CollectionUtil.Find(
                TransactionGatewayRejectionReason.ALL,
                node.GetString("gateway-rejection-reason"),
                TransactionGatewayRejectionReason.UNRECOGNIZED
            );
            PaymentInstrumentType = (PaymentInstrumentType)CollectionUtil.Find(
                PaymentInstrumentType.ALL,
                node.GetString("payment-instrument-type"),
                PaymentInstrumentType.UNKNOWN
            );
            Channel = node.GetString("channel");
            OrderId = node.GetString("order-id");
            Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);
            EscrowStatus = (TransactionEscrowStatus)CollectionUtil.Find(
                    TransactionEscrowStatus.ALL,
                    node.GetString("escrow-status"),
                    TransactionEscrowStatus.UNRECOGNIZED
            );

            List<NodeWrapper> statusNodes = node.GetList("status-history/status-event");
            StatusHistory = new StatusEvent[statusNodes.Count];
            for (int i = 0; i < statusNodes.Count; i++)
            {
                StatusHistory[i] = new StatusEvent(statusNodes[i]);
            }

            Type = (TransactionType)CollectionUtil.Find(TransactionType.ALL, node.GetString("type"), TransactionType.UNRECOGNIZED);
            MerchantAccountId = node.GetString("merchant-account-id");
            ProcessorAuthorizationCode = node.GetString("processor-authorization-code");
            ProcessorResponseCode = node.GetString("processor-response-code");
            ProcessorResponseText = node.GetString("processor-response-text");
            ProcessorSettlementResponseCode = node.GetString("processor-settlement-response-code");
            ProcessorSettlementResponseText = node.GetString("processor-settlement-response-text");
            AdditionalProcessorResponse = node.GetString("additional-processor-response");
            VoiceReferralNumber = node.GetString("voice-referral-number");
            PurchaseOrderNumber = node.GetString("purchase-order-number");
            Recurring = node.GetBoolean("recurring");
            RefundedTransactionId = node.GetString("refunded-transaction-id");

            #pragma warning disable 0618
            RefundId = node.GetString("refund-id");
            #pragma warning restore 0618

            RefundIds = node.GetStrings("refund-ids/*");
            PartialSettlementTransactionIds = node.GetStrings("partial-settlement-transaction-ids/*");
            AuthorizedTransactionId = node.GetString("authorized-transaction-id");
            SettlementBatchId = node.GetString("settlement-batch-id");
            PlanId = node.GetString("plan-id");
            SubscriptionId = node.GetString("subscription-id");
            TaxAmount = node.GetDecimal("tax-amount");
            TaxExempt = node.GetBoolean("tax-exempt");
            CustomFields = node.GetDictionary("custom-fields");
            CreditCard = new CreditCard(node.GetNode("credit-card"), gateway);
            Subscription = new Subscription(node.GetNode("subscription"), gateway);
            Customer = new Customer(node.GetNode("customer"), gateway);
            CurrencyIsoCode = node.GetString("currency-iso-code");
            CvvResponseCode = node.GetString("cvv-response-code");
            Descriptor = new Descriptor(node.GetNode("descriptor"));
            ServiceFeeAmount = node.GetDecimal("service-fee-amount");
            DisbursementDetails = new DisbursementDetails(node.GetNode("disbursement-details"));
            var paypalNode = node.GetNode("paypal");
            if (paypalNode != null)
            {
                PayPalDetails = new PayPalDetails(paypalNode);
            }
            var coinbaseNode = node.GetNode("coinbase-account");
            if (coinbaseNode != null)
            {
                CoinbaseDetails = new CoinbaseDetails(coinbaseNode);
            }
            var applePayNode = node.GetNode("apple-pay");
            if (applePayNode != null)
            {
                ApplePayDetails = new ApplePayDetails(applePayNode);
            }
            var androidPayNode = node.GetNode("android-pay-card");
            if (androidPayNode != null)
            {
                AndroidPayDetails = new AndroidPayDetails(androidPayNode);
            }

            BillingAddress = new Address(node.GetNode("billing"));
            ShippingAddress = new Address(node.GetNode("shipping"));

            CreatedAt = node.GetDateTime("created-at");
            UpdatedAt = node.GetDateTime("updated-at");

            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));
            }

            Disputes = new List<Dispute>();
            foreach (var dispute in node.GetList("disputes/dispute")) {
                Disputes.Add(new Dispute(dispute));
            }

            var riskDataNode = node.GetNode("risk-data");
            if (riskDataNode != null){
                RiskData = new RiskData(riskDataNode);
            }

            var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
            if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty()){
                ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
            }
        }