Exemple #1
0
        public WebhookNotification(NodeWrapper node, IBraintreeGateway gateway)
        {
            Timestamp = node.GetDateTime("timestamp");
            Kind      = (WebhookKind)CollectionUtil.Find(WebhookKind.ALL, node.GetString("kind"), WebhookKind.UNRECOGNIZED);

            NodeWrapper WrapperNode = node.GetNode("subject");

            if (node.GetString("source-merchant-id") != null)
            {
                SourceMerchantId = node.GetString("source-merchant-id");
            }

            if (WrapperNode.GetNode("api-error-response") != null)
            {
                WrapperNode = WrapperNode.GetNode("api-error-response");
            }

            if (WrapperNode.GetNode("subscription") != null)
            {
                Subscription = new Subscription(WrapperNode.GetNode("subscription"), gateway);
            }

            if (WrapperNode.GetNode("merchant-account") != null)
            {
                MerchantAccount = new MerchantAccount(WrapperNode.GetNode("merchant-account"));
            }

            if (WrapperNode.GetNode("dispute") != null)
            {
                Dispute = new Dispute(WrapperNode.GetNode("dispute"));
            }

            if (WrapperNode.GetNode("transaction") != null)
            {
                Transaction = new Transaction(WrapperNode.GetNode("transaction"), gateway);
            }

            if (WrapperNode.GetNode("disbursement") != null)
            {
                Disbursement = new Disbursement(WrapperNode.GetNode("disbursement"), gateway);
            }

            if (WrapperNode.GetNode("partner-merchant") != null)
            {
                PartnerMerchant = new PartnerMerchant(WrapperNode.GetNode("partner-merchant"));
            }

            if (WrapperNode.GetNode("connected-merchant-status-transitioned") != null)
            {
                ConnectedMerchantStatusTransitioned = new ConnectedMerchantStatusTransitioned(WrapperNode.GetNode("connected-merchant-status-transitioned"));
            }

            if (WrapperNode.GetNode("connected-merchant-paypal-status-changed") != null)
            {
                ConnectedMerchantPayPalStatusChanged = new ConnectedMerchantPayPalStatusChanged(WrapperNode.GetNode("connected-merchant-paypal-status-changed"));
            }

            if (WrapperNode.GetNode("account-updater-daily-report") != null)
            {
                AccountUpdaterDailyReport = new AccountUpdaterDailyReport(WrapperNode.GetNode("account-updater-daily-report"));
            }

            if (WrapperNode.GetNode("ideal-payment") != null)
            {
                IdealPayment = new IdealPayment(WrapperNode.GetNode("ideal-payment"));
            }

            if (WrapperNode.GetNode("granted-payment-instrument-update") != null)
            {
                GrantedPaymentInstrumentUpdate = new GrantedPaymentInstrumentUpdate(WrapperNode.GetNode("granted-payment-instrument-update"));
            }

            if (WrapperNode.GetNode("errors") != null)
            {
                Errors = new ValidationErrors(WrapperNode.GetNode("errors"));
            }

            if (WrapperNode.GetNode("message") != null)
            {
                Message = WrapperNode.GetString("message");
            }
        }
Exemple #2
0
        protected internal Transaction(NodeWrapper node, IBraintreeGateway 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);
            }
            var amexExpressCheckoutNode = node.GetNode("amex-express-checkout-card");
            if (amexExpressCheckoutNode != null)
            {
                AmexExpressCheckoutDetails = new AmexExpressCheckoutDetails(amexExpressCheckoutNode);
            }
            var venmoAccountNode = node.GetNode("venmo-account");
            if (venmoAccountNode != null)
            {
                VenmoAccountDetails = new VenmoAccountDetails(venmoAccountNode);
            }

            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);
            }
        }
        public WebhookNotification(NodeWrapper node, IBraintreeGateway gateway)
        {
            Timestamp = node.GetDateTime("timestamp");
            Kind      = (WebhookKind)CollectionUtil.Find(WebhookKind.ALL, node.GetString("kind"), WebhookKind.UNRECOGNIZED);

            NodeWrapper WrapperNode = node.GetNode("subject");

            if (node.GetString("source-merchant-id") != null)
            {
                SourceMerchantId = node.GetString("source-merchant-id");
            }

            if (WrapperNode.GetNode("api-error-response") != null)
            {
                WrapperNode = WrapperNode.GetNode("api-error-response");
            }

            if (WrapperNode.GetNode("subscription") != null)
            {
                Subscription = new Subscription(WrapperNode.GetNode("subscription"), gateway);
            }

            if (WrapperNode.GetNode("merchant-account") != null)
            {
                MerchantAccount = new MerchantAccount(WrapperNode.GetNode("merchant-account"));
            }

            if (WrapperNode.GetNode("dispute") != null)
            {
                Dispute = new Dispute(WrapperNode.GetNode("dispute"));
            }

            if (WrapperNode.GetNode("transaction") != null)
            {
                Transaction = new Transaction(WrapperNode.GetNode("transaction"), gateway);
            }

            if (WrapperNode.GetNode("disbursement") != null)
            {
                Disbursement = new Disbursement(WrapperNode.GetNode("disbursement"), gateway);
            }

            if (WrapperNode.GetNode("partner-merchant") != null)
            {
                PartnerMerchant = new PartnerMerchant(WrapperNode.GetNode("partner-merchant"));
            }

            if (WrapperNode.GetNode("oauth-application-revocation") != null)
            {
                OAuthAccessRevocation = new OAuthAccessRevocation(WrapperNode.GetNode("oauth-application-revocation"));
            }

            if (WrapperNode.GetNode("connected-merchant-status-transitioned") != null)
            {
                ConnectedMerchantStatusTransitioned = new ConnectedMerchantStatusTransitioned(WrapperNode.GetNode("connected-merchant-status-transitioned"));
            }

            if (WrapperNode.GetNode("connected-merchant-paypal-status-changed") != null)
            {
                ConnectedMerchantPayPalStatusChanged = new ConnectedMerchantPayPalStatusChanged(WrapperNode.GetNode("connected-merchant-paypal-status-changed"));
            }

            if (WrapperNode.GetNode("account-updater-daily-report") != null)
            {
                AccountUpdaterDailyReport = new AccountUpdaterDailyReport(WrapperNode.GetNode("account-updater-daily-report"));
            }

            // NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
            // DEPRECATED If you're looking to accept iDEAL as a payment method contact [email protected] for a solution.
            if (WrapperNode.GetNode("ideal-payment") != null)
            {
                IdealPayment = new IdealPayment(WrapperNode.GetNode("ideal-payment"));
            }

            if (WrapperNode.GetNode("granted-payment-instrument-update") != null)
            {
                GrantedPaymentInstrumentUpdate = new GrantedPaymentInstrumentUpdate(WrapperNode.GetNode("granted-payment-instrument-update"));
            }

            if (Kind == WebhookKind.GRANTED_PAYMENT_METHOD_REVOKED || Kind == WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER)
            {
                RevokedPaymentMethodMetadata = new RevokedPaymentMethodMetadata(WrapperNode, gateway);
            }

            if (WrapperNode.GetNode("errors") != null)
            {
                Errors = new ValidationErrors(WrapperNode.GetNode("errors"));
            }

            if (WrapperNode.GetNode("message") != null)
            {
                Message = WrapperNode.GetString("message");
            }

            if (WrapperNode.GetNode("local-payment") != null)
            {
                LocalPaymentCompleted = new LocalPaymentCompleted(WrapperNode.GetNode("local-payment"), gateway);
            }
        }
        protected internal Transaction(NodeWrapper node, IBraintreeGateway 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");
            GraphQLId    = node.GetString("global-id");
            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");
            ProcessorResponseType           = (ProcessorResponseType)CollectionUtil.Find(ProcessorResponseType.ALL, node.GetString("processor-response-type"), ProcessorResponseType.UNRECOGNIZED);
            ProcessorSettlementResponseCode = node.GetString("processor-settlement-response-code");
            ProcessorSettlementResponseText = node.GetString("processor-settlement-response-text");
            NetworkResponseCode             = node.GetString("network-response-code");
            NetworkResponseText             = node.GetString("network-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");

            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");
            var creditCardNode = node.GetNode("credit-card");

            if (creditCardNode != null)
            {
                CreditCard = new CreditCard(creditCardNode, gateway);
            }
            var subscriptionNode = node.GetNode("subscription");

            if (subscriptionNode != null)
            {
                SubscriptionDetails = new SubscriptionDetails(subscriptionNode);
            }
            var customerNode = node.GetNode("customer");

            if (customerNode != null)
            {
                CustomerDetails = new CustomerDetails(customerNode, gateway);
            }
            CurrencyIsoCode = node.GetString("currency-iso-code");
            CvvResponseCode = node.GetString("cvv-response-code");
            var descriptorNode = node.GetNode("descriptor");

            if (descriptorNode != null)
            {
                Descriptor = new Descriptor(descriptorNode);
            }
            ServiceFeeAmount = node.GetDecimal("service-fee-amount");
            var disbursementDetailsNode = node.GetNode("disbursement-details");

            if (disbursementDetailsNode != null)
            {
                DisbursementDetails = new DisbursementDetails(disbursementDetailsNode);
            }
            var paypalNode = node.GetNode("paypal");

            if (paypalNode != null)
            {
                PayPalDetails = new PayPalDetails(paypalNode);
            }
            var paypalHereNode = node.GetNode("paypal-here");

            if (paypalHereNode != null)
            {
                PayPalHereDetails = new PayPalHereDetails(paypalHereNode);
            }
            var localPaymentNode = node.GetNode("local-payment");

            if (localPaymentNode != null)
            {
                LocalPaymentDetails = new LocalPaymentDetails(localPaymentNode);
            }
            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);
            }
            var amexExpressCheckoutNode = node.GetNode("amex-express-checkout-card");

            if (amexExpressCheckoutNode != null)
            {
                AmexExpressCheckoutDetails = new AmexExpressCheckoutDetails(amexExpressCheckoutNode);
            }
            var venmoAccountNode = node.GetNode("venmo-account");

            if (venmoAccountNode != null)
            {
                VenmoAccountDetails = new VenmoAccountDetails(venmoAccountNode);
            }
            var usBankAccountNode = node.GetNode("us-bank-account");

            if (usBankAccountNode != null)
            {
                UsBankAccountDetails = new UsBankAccountDetails(usBankAccountNode);
            }
            // NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
            // DEPRECATED If you're looking to accept iDEAL as a payment method contact [email protected] for a solution.
            var idealPaymentNode = node.GetNode("ideal-payment");

            if (idealPaymentNode != null)
            {
                IdealPaymentDetails = new IdealPaymentDetails(idealPaymentNode);
            }
            var visaCheckoutNode = node.GetNode("visa-checkout-card");

            if (visaCheckoutNode != null)
            {
                VisaCheckoutCardDetails = new VisaCheckoutCardDetails(visaCheckoutNode);
            }
            var masterpassNode = node.GetNode("masterpass-card");

            if (masterpassNode != null)
            {
                MasterpassCardDetails = new MasterpassCardDetails(masterpassNode);
            }
            var samsungPayNode = node.GetNode("samsung-pay-card");

            if (samsungPayNode != null)
            {
                SamsungPayCardDetails = new SamsungPayCardDetails(samsungPayNode);
            }

            var billingAddressNode = node.GetNode("billing");

            if (billingAddressNode != null)
            {
                BillingAddress = new Address(billingAddressNode);
            }
            var shippingAddressNode = node.GetNode("shipping");

            if (shippingAddressNode != null)
            {
                ShippingAddress = new Address(shippingAddressNode);
            }

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

            AuthorizationAdjustments = new List <AuthorizationAdjustment>();
            foreach (var authorizationAdjustment in node.GetList("authorization-adjustments/authorization-adjustment"))
            {
                AuthorizationAdjustments.Add(new AuthorizationAdjustment(authorizationAdjustment));
            }

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

            var facilitatedDetailsNode = node.GetNode("facilitated-details");

            if (facilitatedDetailsNode != null && !facilitatedDetailsNode.IsEmpty())
            {
                FacilitatedDetails = new FacilitatedDetails(facilitatedDetailsNode);
            }

            var facilitatorDetailsNode = node.GetNode("facilitator-details");

            if (facilitatorDetailsNode != null && !facilitatorDetailsNode.IsEmpty())
            {
                FacilitatorDetails = new FacilitatorDetails(facilitatorDetailsNode);
            }

            DiscountAmount      = node.GetDecimal("discount-amount");
            ShippingAmount      = node.GetDecimal("shipping-amount");
            ShipsFromPostalCode = node.GetString("ships-from-postal-code");

            NetworkTransactionId = node.GetString("network-transaction-id");

            AuthorizationExpiresAt = node.GetDateTime("authorization-expires-at");
        }
Exemple #5
0
 public DisputeStatusHistory(NodeWrapper node)
 {
     EffectiveDate = node.GetDateTime("effective-date");
     Timestamp     = node.GetDateTime("timestamp");
     Status        = (DisputeStatus)CollectionUtil.Find(DisputeStatus.ALL, node.GetString("status"), DisputeStatus.UNRECOGNIZED);
 }