Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
0
 protected internal CoinbaseDetails(NodeWrapper node)
 {
     UserId = node.GetString("user-id");
     UserEmail = node.GetString("user-email");
     UserName = node.GetString("user-name");
     Token = node.GetString("token");
 }
Ejemplo n.º 3
0
        public Result<PaymentMethod> Create(PaymentMethodRequest request)
        {
            NodeWrapper response = new NodeWrapper(service.Post("/payment_methods", request));

            if (response.GetName() == "paypal-account")
            {
                return new ResultImpl<PayPalAccount>(response, service);
            }
            else if (response.GetName() == "credit-card")
            {
                return new ResultImpl<CreditCard>(response, service);
            }
            else if (response.GetName() == "apple-pay-card")
            {
                return new ResultImpl<ApplePayCard>(response, service);
            }
            else if (response.GetName() == "android-pay-card")
            {
                return new ResultImpl<AndroidPayCard>(response, service);
            }
            else if (response.GetName() == "coinbase-account")
            {
                return new ResultImpl<CoinbaseAccount>(response, service);
            }
            else
            {
                return new ResultImpl<UnknownPaymentMethod>(response, service);
            }
        }
 protected internal MerchantAccountBusinessDetails(NodeWrapper node)
 {
     DbaName = node.GetString("dba-name");
     LegalName = node.GetString("legal-name");
     TaxId = node.GetString("tax-id");
     Address = new Address(node.GetNode("address"));
 }
 public UnknownPaymentMethod(NodeWrapper node)
 {
     Token = node.GetString("token");
     IsDefault = node.GetBoolean("default");
     ImageUrl = "https://assets.braintreegateway.com/payment_method_logo/unknown.png";
     CustomerId = node.GetString("customer-id");
 }
Ejemplo n.º 6
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));
     }
 }
Ejemplo n.º 7
0
 protected internal Descriptor(NodeWrapper node)
 {
     if (node != null) {
         Name = node.GetString("name");
         Phone = node.GetString("phone");
     }
 }
        public PaymentMethod Find(string token)
        {
            if(token == null || token.Trim().Equals(""))
                throw new NotFoundException();

            var response = new NodeWrapper(service.Get(service.MerchantPath() + "/payment_methods/any/" + token));

            if (response.GetName() == "paypal-account")
            {
                return new PayPalAccount(response, gateway);
            }
            else if (response.GetName() == "credit-card")
            {
                return new CreditCard(response, gateway);
            }
            else if (response.GetName() == "apple-pay-card")
            {
                return new ApplePayCard(response, gateway);
            }
            else if (response.GetName() == "android-pay-card")
            {
                return new AndroidPayCard(response, gateway);
            }
            else if (response.GetName() == "coinbase-account")
            {
                return new CoinbaseAccount(response, gateway);
            }
            else
            {
                return new UnknownPaymentMethod(response);
            }
        }
        public Result<PaymentMethod> Update(string token, PaymentMethodRequest request)
        {
            var response = new NodeWrapper(service.Put(service.MerchantPath() + "/payment_methods/any/" + token, request));

            if (response.GetName() == "paypal-account")
            {
                return new ResultImpl<PayPalAccount>(response, gateway);
            }
            else if (response.GetName() == "credit-card")
            {
                return new ResultImpl<CreditCard>(response, gateway);
            }
            else if (response.GetName() == "apple-pay-card")
            {
                return new ResultImpl<ApplePayCard>(response, gateway);
            }
            else if (response.GetName() == "android-pay-card")
            {
                return new ResultImpl<AndroidPayCard>(response, gateway);
            }
            else
            {
                return new ResultImpl<UnknownPaymentMethod>(response, gateway);
            }
        }
Ejemplo n.º 10
0
 protected internal MerchantAccount(NodeWrapper node)
 {
   Id = node.GetString("id");
   CurrencyIsoCode = node.GetString("currency-iso-code");
   Status = (MerchantAccountStatus) CollectionUtil.Find(MerchantAccountStatus.ALL, node.GetString("status"), null);
   NodeWrapper masterNode = node.GetNode("master-merchant-account");
   if (masterNode != null)
       MasterMerchantAccount = new MerchantAccount(masterNode);
   else
       MasterMerchantAccount = null;
   NodeWrapper individualNode = node.GetNode("individual");
   if (individualNode != null)
       IndividualDetails = new MerchantAccountIndividualDetails(individualNode);
   else
       IndividualDetails = null;
   NodeWrapper businessNode = node.GetNode("business");
   if (businessNode != null)
       BusinessDetails = new MerchantAccountBusinessDetails(businessNode);
   else
       BusinessDetails = null;
   NodeWrapper fundingNode = node.GetNode("funding");
   if (fundingNode != null)
       FundingDetails = new MerchantAccountFundingDetails(fundingNode);
   else
       FundingDetails = null;
 }
        public CreditCardVerification(NodeWrapper node, BraintreeGateway gateway)
        {
            if (node == null) return;

            AvsErrorResponseCode = node.GetString("avs-error-response-code");
            AvsPostalCodeResponseCode = node.GetString("avs-postal-code-response-code");
            AvsStreetAddressResponseCode = node.GetString("avs-street-address-response-code");
            CvvResponseCode = node.GetString("cvv-response-code");
            GatewayRejectionReason = (TransactionGatewayRejectionReason)CollectionUtil.Find(
                TransactionGatewayRejectionReason.ALL,
                node.GetString("gateway-rejection-reason"),
                null
            );
            ProcessorResponseCode = node.GetString("processor-response-code");
            ProcessorResponseText = node.GetString("processor-response-text");
            MerchantAccountId = node.GetString("merchant-account-id");
            Status = (VerificationStatus)CollectionUtil.Find(VerificationStatus.ALL, node.GetString("status"), VerificationStatus.UNRECOGNIZED);
            Id = node.GetString("id");
            BillingAddress = new Address(node.GetNode("billing"));
            CreditCard = new CreditCard(node.GetNode("credit-card"), gateway);
            CreatedAt = node.GetDateTime("created-at");

            var riskDataNode = node.GetNode("risk-data");
            if (riskDataNode != null) {
                RiskData = new RiskData(riskDataNode);
            }
        }
 public virtual WebhookNotification Parse(string signature, string payload)
 {
     ValidateSignature(signature, payload);
     var xmlPayload = Encoding.Default.GetString(Convert.FromBase64String(payload));
     var node = new NodeWrapper(service.StringToXmlNode(xmlPayload));
     return new WebhookNotification(node, gateway);
 }
Ejemplo n.º 13
0
        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);
            }
        }
 protected internal VenmoAccountDetails(NodeWrapper node)
 {
     Token = node.GetString("token");
     Username = node.GetString("username");
     VenmoUserId = node.GetString("venmo-user-id");
     ImageUrl = node.GetString("image-url");
     SourceDescription = node.GetString("source-description");
 }
Ejemplo n.º 15
0
        public RiskData(NodeWrapper node)
        {
            if (node == null)
                return;

            id = node.GetString("id");
            decision = node.GetString("decision");
        }
Ejemplo n.º 16
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");
 }
Ejemplo n.º 17
0
        public virtual ResourceCollection<Customer> Search(CustomerSearchRequest query)
        {
            NodeWrapper response = new NodeWrapper(Service.Post("/customers/advanced_search_ids", query));

            return new ResourceCollection<Customer>(response, delegate(String[] ids) {
                return FetchCustomers(query, ids);
            });
        }
Ejemplo n.º 18
0
 protected internal PartnerMerchant(NodeWrapper node)
 {
     MerchantPublicId = node.GetString("merchant-public-id");
     PublicKey = node.GetString("public-key");
     PrivateKey = node.GetString("private-key");
     PartnerMerchantId = node.GetString("partner-merchant-id");
     ClientSideEncryptionKey = node.GetString("client-side-encryption-key");
 }
        public virtual ResourceCollection<CreditCardVerification> Search(CreditCardVerificationSearchRequest query)
        {
            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/verifications/advanced_search_ids", query));

            return new ResourceCollection<CreditCardVerification>(response, delegate(string[] ids) {
                return FetchCreditCardVerifications(query, ids);
            });
        }
Ejemplo n.º 20
0
        public virtual ResourceCollection<Customer> All()
        {
            NodeWrapper response = new NodeWrapper(Service.Post("/customers/advanced_search_ids"));

            return new ResourceCollection<Customer>(response, delegate(String[] ids) {
                return FetchCustomers(ids);
            });
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Search for subscriptions based on PlanId, DaysPastDue and Status
        /// </summary>
        /// <example>
        /// Quick Start Example:
        /// </example>
        /// <code>
        /// BraintreeGateway gateway = new BraintreeGateway(...);
        /// gateway.Subscription.Search(delegate(SubscriptionSearchRequest search) {
        ///     search.PlanId().StartsWith("abc");
        ///     search.DaysPastDue().Is("30");
        ///     search.Status().IncludedIn(Subscription.Status.ACTIVE, Subscription.Status.CANCELED);
        /// });
        /// </code>
        public virtual ResourceCollection<Subscription> Search(SubscriptionSearchRequest query)
        {
            NodeWrapper response = new NodeWrapper(Service.Post("/subscriptions/advanced_search_ids", query));

            return new ResourceCollection<Subscription>(response, delegate(String[] ids) {
                return FetchSubscriptions(query, ids);
            });
        }
Ejemplo n.º 22
0
        public ThreeDSecureInfo(NodeWrapper node)
        {
            if (node == null) return;

            Enrolled = node.GetString("enrolled");
            Status = node.GetString("status");
            LiabilityShifted = node.GetBoolean("liability-shifted");
            LiabilityShiftPossible = node.GetBoolean("liability-shift-possible");
        }
Ejemplo n.º 23
0
 protected internal DisbursementDetails(NodeWrapper node)
 {
     SettlementAmount = node.GetDecimal("settlement-amount");
     SettlementCurrencyIsoCode = node.GetString("settlement-currency-iso-code");
     SettlementCurrencyExchangeRate = node.GetString("settlement-currency-exchange-rate");
     FundsHeld = node.GetBoolean("funds-held");
     Success = node.GetBoolean("success");
     DisbursementDate = node.GetDateTime("disbursement-date");
 }
Ejemplo n.º 24
0
 protected internal ApplePayDetails(NodeWrapper node)
 {
     CardType = node.GetString("card-type");
     PaymentInstrumentName = node.GetString("payment-instrument-name");
     CardholderName = node.GetString("cardholder-name");
     ExpirationMonth = node.GetString("expiration-month");
     ExpirationYear = node.GetString("expiration-year");
     Token = node.GetString("token");
 }
        public virtual ResourceCollection<Customer> All()
        {
            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/customers/advanced_search_ids"));
            var query = new CustomerSearchRequest();

            return new ResourceCollection<Customer>(response, delegate(string[] ids) {
                return FetchCustomers(query, ids);
            });
        }
        protected internal SettlementBatchSummary (NodeWrapper node)
        {
            records = new List<IDictionary<String, String>>();

            foreach (var record in node.GetList("records/record"))
            {
                records.Add(record.GetDictionary("."));
            }
        }
Ejemplo n.º 27
0
        public OAuthCredentials(NodeWrapper node)
        {
            if (node == null) return;

            AccessToken = node.GetString("access-token");
            RefreshToken = node.GetString("refresh-token");
            TokenType = node.GetString("token-type");
            ExpiresAt = node.GetDateTime("expires-at");
        }
 protected internal MerchantAccountIndividualDetails(NodeWrapper node)
 {
     FirstName = node.GetString("first-name");
     LastName = node.GetString("last-name");
     Email = node.GetString("email");
     Phone = node.GetString("phone");
     DateOfBirth = node.GetString("date-of-birth");
     SsnLastFour = node.GetString("ssn-last-4");
     Address = new Address(node.GetNode("address"));
 }
Ejemplo n.º 29
0
        protected internal PaymentMethodNonce(NodeWrapper node, BraintreeGateway gateway)
        {
            Nonce = node.GetString("nonce");
            Type = node.GetString("type");

            var threeDSecureInfoNode = node.GetNode("three-d-secure-info");
            if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty()){
                ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
            }
        }
Ejemplo n.º 30
0
        public StatusEvent(NodeWrapper node)
        {
            if (node == null) return;

            Amount = node.GetDecimal("amount");
            Status = (TransactionStatus)CollectionUtil.Find(TransactionStatus.ALL, node.GetString("status"), TransactionStatus.UNRECOGNIZED);
            Timestamp = node.GetDateTime("timestamp");
            Source = (TransactionSource)CollectionUtil.Find(TransactionSource.ALL, node.GetString("transaction-source"), TransactionSource.UNRECOGNIZED);
            User = node.GetString("user");
        }
        public CreditCardVerification(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (node == null)
            {
                return;
            }

            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");
            CurrencyIsoCode        = node.GetString("currency-iso-code");
            CvvResponseCode        = node.GetString("cvv-response-code");
            GatewayRejectionReason = (TransactionGatewayRejectionReason)CollectionUtil.Find(
                TransactionGatewayRejectionReason.ALL,
                node.GetString("gateway-rejection-reason"),
                null
                );
            ProcessorResponseCode = node.GetString("processor-response-code");
            ProcessorResponseText = node.GetString("processor-response-text");
            ProcessorResponseType = (ProcessorResponseType)CollectionUtil.Find(ProcessorResponseType.ALL, node.GetString("processor-response-type"), ProcessorResponseType.UNRECOGNIZED);
            NetworkResponseCode   = node.GetString("network-response-code");
            NetworkResponseText   = node.GetString("network-response-text");
            NetworkTransactionId  = node.GetString("network-transaction-id");
            MerchantAccountId     = node.GetString("merchant-account-id");
            Status         = (VerificationStatus)CollectionUtil.Find(VerificationStatus.ALL, node.GetString("status"), VerificationStatus.UNRECOGNIZED);
            GraphQLId      = node.GetString("global-id");
            Id             = node.GetString("id");
            BillingAddress = new Address(node.GetNode("billing"));
            CreditCard     = new CreditCard(node.GetNode("credit-card"), gateway);
            CreatedAt      = node.GetDateTime("created-at");

            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);
            }
        }
Ejemplo n.º 32
0
        public ThreeDSecureInfo(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }

            Enrolled               = node.GetString("enrolled");
            Status                 = node.GetString("status");
            LiabilityShifted       = node.GetBoolean("liability-shifted");
            LiabilityShiftPossible = node.GetBoolean("liability-shift-possible");
            Cavv                = node.GetString("cavv");
            Xid                 = node.GetString("xid");
            DsTransactionId     = node.GetString("ds-transaction-id");
            EciFlag             = node.GetString("eci-flag");
            ThreeDSecureVersion = node.GetString("three-d-secure-version");
        }
Ejemplo n.º 33
0
        protected internal MerchantAccount(NodeWrapper node)
        {
            Id = node.GetString("id");
            CurrencyIsoCode = node.GetString("currency-iso-code");
            Status          = (MerchantAccountStatus)CollectionUtil.Find(MerchantAccountStatus.ALL, node.GetString("status"), null);
            NodeWrapper masterNode = node.GetNode("master-merchant-account");

            if (masterNode != null)
            {
                MasterMerchantAccount = new MerchantAccount(masterNode);
            }
            else
            {
                MasterMerchantAccount = null;
            }
            NodeWrapper individualNode = node.GetNode("individual");

            if (individualNode != null)
            {
                IndividualDetails = new MerchantAccountIndividualDetails(individualNode);
            }
            else
            {
                IndividualDetails = null;
            }
            NodeWrapper businessNode = node.GetNode("business");

            if (businessNode != null)
            {
                BusinessDetails = new MerchantAccountBusinessDetails(businessNode);
            }
            else
            {
                BusinessDetails = null;
            }
            NodeWrapper fundingNode = node.GetNode("funding");

            if (fundingNode != null)
            {
                FundingDetails = new MerchantAccountFundingDetails(fundingNode);
            }
            else
            {
                FundingDetails = null;
            }
        }
Ejemplo n.º 34
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));
        }
Ejemplo n.º 35
0
        protected internal IdealPayment(NodeWrapper node)
        {
            Id = node.GetString("id");
            IdealTransactionId = node.GetString("ideal-transaction-id");
            ImageUrl           = node.GetString("image-url");
            Currency           = node.GetString("currency");
            Status             = node.GetString("status");
            Amount             = (decimal)node.GetDecimal("amount");
            OrderId            = node.GetString("order-id");
            Issuer             = node.GetString("issuer");
            ApprovalUrl        = node.GetString("approval-url");

            if (node.GetNode("iban-bank-account") != null)
            {
                IbanBankAccount = new IbanBankAccount(node.GetNode("iban-bank-account"));
            }
        }
Ejemplo n.º 36
0
 public Disbursement(NodeWrapper node, IBraintreeGateway 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;
 }
Ejemplo n.º 37
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");
            _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);
        }
Ejemplo n.º 38
0
 protected internal PayPalDetails(NodeWrapper node)
 {
     PayerEmail             = node.GetString("payer-email");
     PaymentId              = node.GetString("payment-id");
     AuthorizationId        = node.GetString("authorization-id");
     Token                  = node.GetString("token");
     ImageUrl               = node.GetString("image-url");
     DebugId                = node.GetString("debug-id");
     PayeeEmail             = node.GetString("payee-email");
     CustomField            = node.GetString("custom-field");
     PayerId                = node.GetString("payer-id");
     PayerFirstName         = node.GetString("payer-first-name");
     PayerLastName          = node.GetString("payer-last-name");
     SellerProtectionStatus = node.GetString("seller-protection-status");
     CaptureId              = node.GetString("capture-id");
     RefundId               = node.GetString("refund-id");
 }
Ejemplo n.º 39
0
        public BinData(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }

            Commercial         = (CreditCardCommercial)CollectionUtil.Find(CreditCardCommercial.ALL, node.GetString("commercial"), CreditCardCommercial.UNKNOWN);
            Debit              = (CreditCardDebit)CollectionUtil.Find(CreditCardDebit.ALL, node.GetString("debit"), CreditCardDebit.UNKNOWN);
            DurbinRegulated    = (CreditCardDurbinRegulated)CollectionUtil.Find(CreditCardDurbinRegulated.ALL, node.GetString("durbin-regulated"), CreditCardDurbinRegulated.UNKNOWN);
            Healthcare         = (CreditCardHealthcare)CollectionUtil.Find(CreditCardHealthcare.ALL, node.GetString("healthcare"), CreditCardHealthcare.UNKNOWN);
            Payroll            = (CreditCardPayroll)CollectionUtil.Find(CreditCardPayroll.ALL, node.GetString("payroll"), CreditCardPayroll.UNKNOWN);
            Prepaid            = (CreditCardPrepaid)CollectionUtil.Find(CreditCardPrepaid.ALL, node.GetString("prepaid"), CreditCardPrepaid.UNKNOWN);
            _CountryOfIssuance = node.GetString("country-of-issuance");
            _IssuingBank       = node.GetString("issuing-bank");
            _ProductId         = node.GetString("product-id");
        }
Ejemplo n.º 40
0
        protected internal PayPalAccount(NodeWrapper node, BraintreeService service)
        {
            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], service);
            }
        }
Ejemplo n.º 41
0
        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;
            }));
        }
Ejemplo n.º 42
0
        public RiskData(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }

            id                   = node.GetString("id");
            decision             = node.GetString("decision");
            fraudServiceProvider = node.GetString("fraud-service-provider");
            deviceDataCaptured   = node.GetBoolean("device-data-captured");
            TransactionRiskScore = node.GetString("transaction-risk-score");
            DecisionReasons      = new List <string>();
            foreach (var stringNode in node.GetList("decision-reasons/item"))
            {
                DecisionReasons.Add(stringNode.GetString("."));
            }
        }
Ejemplo n.º 43
0
        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;
            }));
        }
 private PaymentMethod ExtractPaymentMethodFromResponse(NodeWrapper response)
 {
     if (response.GetName() == "paypal-account")
     {
         return(new PayPalAccount(response, gateway));
     }
     else if (response.GetName() == "us-bank-account")
     {
         return(new UsBankAccount(response));
     }
     else if (response.GetName() == "credit-card")
     {
         return(new CreditCard(response, gateway));
     }
     else if (response.GetName() == "apple-pay-card")
     {
         return(new ApplePayCard(response, gateway));
     }
     else if (response.GetName() == "android-pay-card")
     {
         return(new AndroidPayCard(response, gateway));
     }
     else if (response.GetName() == "coinbase-account")
     {
         return(new CoinbaseAccount(response, gateway));
     }
     else if (response.GetName() == "venmo-account")
     {
         return(new VenmoAccount(response, gateway));
     }
     else if (response.GetName() == "visa-checkout-card")
     {
         return(new VisaCheckoutCard(response, gateway));
     }
     else if (response.GetName() == "masterpass-card")
     {
         return(new MasterpassCard(response, gateway));
     }
     else
     {
         return(new UnknownPaymentMethod(response));
     }
 }
Ejemplo n.º 45
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");
            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));
            }

            StatusHistory = new List <DisputeStatusHistory>();
            foreach (var historyStatusResponse in node.GetList("status-history/status-history"))
            {
                StatusHistory.Add(new DisputeStatusHistory(historyStatusResponse));
            }
        }
Ejemplo n.º 46
0
        protected internal PayPalAccount(NodeWrapper node, BraintreeGateway gateway)
        {
            Email = node.GetString("email");
            BillingAgreementId = node.GetString("billing-agreement-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);
            }
        }
Ejemplo n.º 47
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"));
        }
        protected internal PaymentMethodNonceDetails(NodeWrapper node)
        {
            IsNetworkTokenized = node.GetBoolean("is-network-tokenized");
            Bin             = node.GetString("bin");
            CardType        = node.GetString("card-type");
            ExpirationMonth = node.GetString("expiration-month");
            ExpirationYear  = node.GetString("expiration-year");
            LastFour        = node.GetString("last-four");
            LastTwo         = node.GetString("last-two");
            Username        = node.GetString("username");
            VenmoUserId     = node.GetString("venmo-user-id");

            var payerInfoNode = node.GetNode("payer-info");

            if (payerInfoNode != null)
            {
                PayerInfo = new PaymentMethodNonceDetailsPayerInfo(payerInfoNode);
            }
        }
        public UsBankAccountVerification(NodeWrapper node)
        {
            if (node == null)
            {
                return;
            }

            VerificationMethod       = node.GetEnum("verification-method", UsBankAccountVerificationMethod.UNRECOGNIZED);
            VerificationDeterminedAt = node.GetDateTime("verification-determined-at");
            GatewayRejectionReason   = null;
            ProcessorResponseCode    = node.GetString("processor-response-code");
            ProcessorResponseText    = node.GetString("processor-response-text");
            MerchantAccountId        = node.GetString("merchant-account-id");
            Status = node.GetEnum("status", UsBankAccountVerificationStatus.UNRECOGNIZED);
            Id     = node.GetString("id");

            UsBankAccount = new UsBankAccount(node.GetNode("us-bank-account"));
            CreatedAt     = node.GetDateTime("created-at");
        }
Ejemplo n.º 50
0
        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;
            }));
        }
Ejemplo n.º 51
0
        protected internal PaymentMethodNonce(NodeWrapper node, IBraintreeGateway gateway)
        {
            IsDefault = node.GetBoolean("default");
            Nonce     = node.GetString("nonce");
            Type      = node.GetString("type");

            var detailsNode = node.GetNode("details");

            if (detailsNode != null && !detailsNode.IsEmpty())
            {
                Details = new PaymentMethodNonceDetails(detailsNode);
            }

            var threeDSecureInfoNode = node.GetNode("three-d-secure-info");

            if (threeDSecureInfoNode != null && !threeDSecureInfoNode.IsEmpty())
            {
                ThreeDSecureInfo = new ThreeDSecureInfo(threeDSecureInfoNode);
            }
        }
Ejemplo n.º 52
0
        public virtual ResourceCollection <CreditCard> ExpiringBetween(DateTime start, DateTime end)
        {
            string queryString = $"start={start:MMyyyy}&end={end:MMyyyy}";

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

            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/expiring?" + queryString, query));

                var creditCards = new List <CreditCard>();
                foreach (var node in fetchResponse.GetList("credit-card"))
                {
                    creditCards.Add(new CreditCard(node, gateway));
                }
                return creditCards;
            }));
        }
Ejemplo n.º 53
0
        private List <Transaction> FetchTransactions(TransactionSearchRequest query, string[] ids)
        {
            query.Ids.IncludedIn(ids);

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

            if (response.GetName() == "credit-card-transactions")
            {
                var transactions = new List <Transaction>();
                foreach (var node in response.GetList("transaction"))
                {
                    transactions.Add(new Transaction(node, gateway));
                }
                return(transactions);
            }
            else
            {
                throw new DownForMaintenanceException();
            }
        }
Ejemplo n.º 54
0
        public virtual async Task <ResourceCollection <CreditCard> > ExpiringBetweenAsync(DateTime start, DateTime end)
        {
            string queryString = string.Format("start={0:MMyyyy}&end={1:MMyyyy}", start, end);

            var response = new NodeWrapper(await service.PostAsync(service.MerchantPath() + "/payment_methods/all/expiring_ids?" + queryString).ConfigureAwait(false));

            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/expiring?" + queryString, query));

                var creditCards = new List <CreditCard>();
                foreach (var node in fetchResponse.GetList("credit-card"))
                {
                    creditCards.Add(new CreditCard(node, gateway));
                }
                return creditCards;
            }));
        }
Ejemplo n.º 55
0
        public Result <PaymentMethod> Create(PaymentMethodRequest request)
        {
            var response = new NodeWrapper(service.Post(service.MerchantPath() + "/payment_methods", request));

            if (response.GetName() == "paypal-account")
            {
                return(new ResultImpl <PayPalAccount>(response, gateway));
            }
            else if (response.GetName() == "us-bank-account")
            {
                return(new ResultImpl <UsBankAccount>(response, gateway));
            }
            else if (response.GetName() == "credit-card")
            {
                return(new ResultImpl <CreditCard>(response, gateway));
            }
            else if (response.GetName() == "apple-pay-card")
            {
                return(new ResultImpl <ApplePayCard>(response, gateway));
            }
            else if (response.GetName() == "android-pay-card")
            {
                return(new ResultImpl <AndroidPayCard>(response, gateway));
            }
            else if (response.GetName() == "amex-express-checkout-card")
            {
                return(new ResultImpl <AmexExpressCheckoutCard>(response, gateway));
            }
            else if (response.GetName() == "coinbase-account")
            {
                return(new ResultImpl <CoinbaseAccount>(response, gateway));
            }
            else if (response.GetName() == "venmo-account")
            {
                return(new ResultImpl <VenmoAccount>(response, gateway));
            }
            else
            {
                return(new ResultImpl <UnknownPaymentMethod>(response, gateway));
            }
        }
        public Result <PaymentMethod> Update(string token, PaymentMethodRequest request)
        {
            var response = new NodeWrapper(service.Put("/payment_methods/any/" + token, request));

            if (response.GetName() == "paypal-account")
            {
                return(new ResultImpl <PayPalAccount>(response, service));
            }
            else if (response.GetName() == "credit-card")
            {
                return(new ResultImpl <CreditCard>(response, service));
            }
            else if (response.GetName() == "apple-pay-card")
            {
                return(new ResultImpl <ApplePayCard>(response, service));
            }
            else
            {
                return(new ResultImpl <UnknownPaymentMethod>(response, service));
            }
        }
Ejemplo n.º 57
0
        private void PopulateErrors(NodeWrapper node)
        {
            if (node.GetName() == "api-error-response")
            {
                node = node.GetNode("errors");
            }

            List <NodeWrapper> errorResponses = node.GetChildren();

            foreach (var errorResponse in errorResponses)
            {
                if (errorResponse.GetName() != "errors")
                {
                    nestedErrors[errorResponse.GetName()] = new ValidationErrors(errorResponse);
                }
                else
                {
                    PopulateTopLevelErrors(errorResponse.GetList("error"));
                }
            }
        }
Ejemplo n.º 58
0
        protected internal CoinbaseAccount(NodeWrapper node, BraintreeGateway gateway)
        {
            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], gateway);
            }
        }
Ejemplo n.º 59
0
 protected internal PayPalDetails(NodeWrapper node)
 {
     PayerEmail                    = node.GetString("payer-email");
     PaymentId                     = node.GetString("payment-id");
     AuthorizationId               = node.GetString("authorization-id");
     Token                         = node.GetString("token");
     ImageUrl                      = node.GetString("image-url");
     DebugId                       = node.GetString("debug-id");
     PayeeEmail                    = node.GetString("payee-email");
     CustomField                   = node.GetString("custom-field");
     PayerId                       = node.GetString("payer-id");
     PayerFirstName                = node.GetString("payer-first-name");
     PayerLastName                 = node.GetString("payer-last-name");
     PayerStatus                   = node.GetString("payer-status");
     SellerProtectionStatus        = node.GetString("seller-protection-status");
     CaptureId                     = node.GetString("capture-id");
     RefundId                      = node.GetString("refund-id");
     TransactionFeeAmount          = node.GetString("transaction-fee-amount");
     TransactionFeeCurrencyIsoCode = node.GetString("transaction-fee-currency-iso-code");
     Description                   = node.GetString("description");
 }
Ejemplo n.º 60
0
        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);
            }
        }