public CreditCardVerification(NodeWrapper node, IBraintreeGateway 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);
            }
        }
        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);
            }
        }
        private IBraintreeGateway GetGateway()
        {
            if (gateway == null)
            {
                gateway = CreateGateway();
            }

            return(gateway);
        }
Beispiel #4
0
        public IBraintreeGateway GetGateway()
        {
            if (brainTreeGateWay == null)
            {
                brainTreeGateWay = CreateGateway();
            }

            return(brainTreeGateWay);
        }
        /// <summary>
        /// Get Braintree Gateway
        /// </summary>
        /// <param name="environment">Braintree enviornment Sandbox/Production</param>
        /// <param name="merchantId">merchant ID is the unique identifier for your entire gateway account</param>
        /// <param name="publicKey">user-specific public identifier</param>
        /// <param name="privateKey">user-specific private identifier</param>
        /// <returns></returns>
        public IBraintreeGateway GetGateway(string environment, string merchantId, string publicKey, string privateKey)
        {
            if (BraintreeGateway == null)
            {
                BraintreeGateway = CreateGateway(environment, merchantId, publicKey, privateKey);
            }

            return(BraintreeGateway);
        }
        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 (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("account-updater-daily-report") != null)
            {
                AccountUpdaterDailyReport = new AccountUpdaterDailyReport(WrapperNode.GetNode("account-updater-daily-report"));
            }

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

            if (WrapperNode.GetNode("message") != null)
            {
                Message = WrapperNode.GetString("message");
            }
        }
Beispiel #7
0
        public Subscription(NodeWrapper node, IBraintreeGateway gateway)
        {
            Balance                = node.GetDecimal("balance");
            BillingDayOfMonth      = node.GetInteger("billing-day-of-month");
            BillingPeriodEndDate   = node.GetDateTime("billing-period-end-date");
            BillingPeriodStartDate = node.GetDateTime("billing-period-start-date");
            CurrentBillingCycle    = node.GetInteger("current-billing-cycle");
            DaysPastDue            = node.GetInteger("days-past-due");
            Descriptor             = new Descriptor(node.GetNode("descriptor"));
            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));
            }
        }
        public IBraintreeGateway GetGateway()
        {
            if (BraintreeGateway == null)
            {
                BraintreeGateway = CreateGateway();
            }

            return(BraintreeGateway);
        }
        protected internal PaymentMethodNonce(NodeWrapper node, IBraintreeGateway 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);
            }
        }
Beispiel #10
0
        protected internal RevokedPaymentMethodMetadata(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (node.GetChildren().Count == 0)
            {
                throw new UnexpectedException();
            }

            RevokedPaymentMethod = PaymentMethodParser.ParsePaymentMethod(node.GetChildren()[0], gateway);
            CustomerId           = RevokedPaymentMethod.CustomerId;
            Token = RevokedPaymentMethod.Token;
        }
        public BraintreeService(IConfiguration configuration, IUnitOfWork unitOfWork)
        {
            _braintreeGateway = new BraintreeGateway
            {
                Environment = Braintree.Environment.ParseEnvironment(configuration["Braintree:Environment"]),
                MerchantId  = configuration["Braintree:MerchantId"],
                PublicKey   = configuration["Braintree:PublicKey"],
                PrivateKey  = configuration["Braintree:PrivateKey"]
            };

            _unitOfWork = unitOfWork;
        }
        protected internal PaymentMethodNonce(NodeWrapper node, IBraintreeGateway 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);
            }
        }
Beispiel #13
0
        protected internal LocalPaymentCompleted(NodeWrapper node, IBraintreeGateway gateway)
        {
            PaymentId          = node.GetString("payment-id");
            PayerId            = node.GetString("payer-id");
            PaymentMethodNonce = node.GetString("payment-method-nonce");

            var transactionNode = node.GetNode("transaction");

            if (transactionNode != null)
            {
                Transaction = new Transaction(transactionNode, gateway);
            }
        }
Beispiel #14
0
 public DonationController(
     IRepository <Donation> donationRepository,
     DonationRequestRepository donationRequestRepository,
     IRepository <Organisation> organisationRepository,
     IRepository <Mission> missionRepository,
     IBraintreeGateway gateway)
 {
     _donationRepository        = donationRepository;
     _donationRequestRepository = donationRequestRepository;
     _missionRepository         = missionRepository;
     _organisationRepository    = organisationRepository;
     _gateway = gateway;
 }
Beispiel #15
0
        public async Task <IActionResult> Payment(CreatePaymentViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            PaymentDetails paymentDetails = _db.GetDetails(model.PayKey);

            if (paymentDetails == null)
            {
                _logger.LogWarning("Payment details are null.");
                return(RedirectToArcadier(model.InvoiceNo));
            }

            IBraintreeGateway gateway = _braintreeConfig.GetGateway();

            decimal adminFee = paymentDetails.Amount * _arcadierSettings.Value.Commission / 100;
            decimal amount   = paymentDetails.Amount - adminFee;

            var request = new TransactionRequest
            {
                Amount             = amount,
                PaymentMethodNonce = model.PaymentMethodNonce,
                Options            = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Result <Transaction> result = await gateway.Transaction.SaleAsync(request);

            paymentDetails.TransactionStatus = Models.TransactionStatus.Success;
            if (!result.IsSuccess() && result.Transaction == null)
            {
                paymentDetails.TransactionStatus = Models.TransactionStatus.Failure;
            }

            string statusText      = paymentDetails.TransactionStatus == Models.TransactionStatus.Success ? Success : Failure;
            bool   arcadierSuccess = await SetArcadierTransactionStatusAsync(statusText, paymentDetails);

            paymentDetails.ArcadierTransactionStatus = Models.TransactionStatus.Success;
            if (!arcadierSuccess)
            {
                paymentDetails.ArcadierTransactionStatus = Models.TransactionStatus.Failure;
            }

            _db.SaveDetails(model.PayKey, paymentDetails);
            return(RedirectToArcadier(paymentDetails.InvoiceNo));
        }
Beispiel #16
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);
        }
Beispiel #17
0
        public CheckoutController()
        {
            _braintreeGateway = new BraintreeGateway
            {
                Environment = Braintree.Environment.SANDBOX,
                MerchantId  = ConfigurationManager.AppSettings["Braintree.MerchantId"],
                PublicKey   = ConfigurationManager.AppSettings["Braintree.PublicKey"],
                PrivateKey  = ConfigurationManager.AppSettings["Braintree.PrivateKey"]
            };
            _emailService = new SendGridEmailService(ConfigurationManager.AppSettings["SendGrid.ApiKey"]);

            _smsService = new TwilioSmsService(
                ConfigurationManager.AppSettings["Twilio.AccountSid"],
                ConfigurationManager.AppSettings["Twilio.AuthToken"],
                ConfigurationManager.AppSettings["Twilio.FromNumber"]);
        }
Beispiel #18
0
        public CustomerDetails(NodeWrapper node, IBraintreeGateway 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");
        }
 public static PaymentMethod ParsePaymentMethod(NodeWrapper response, IBraintreeGateway gateway)
 {
     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 if (response.GetName() == "samsung-pay-card")
     {
         return(new SamsungPayCard(response, gateway));
     }
     else
     {
         return(new UnknownPaymentMethod(response));
     }
 }
 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;
 }
Beispiel #21
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;
 }
        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);
            }
        }
        protected internal PayPalAccount(NodeWrapper node, IBraintreeGateway 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);
            }
        }
        protected internal PayPalAccount(NodeWrapper node, IBraintreeGateway 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);
            }
        }
        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 (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("errors") != null) {
                Errors = new ValidationErrors(WrapperNode.GetNode("errors"));
            }

            if (WrapperNode.GetNode("message") != null) {
                Message = WrapperNode.GetString("message");
            }
        }
        protected internal SamsungPayCard(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (node == null)
            {
                return;
            }

            Bin                    = node.GetString("bin");
            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");
            SourceCardLastFour     = node.GetString("source-card-last-4");
            UniqueNumberIdentifier = node.GetString("unique-number-identifier");
            Token                  = node.GetString("token");
            CreatedAt              = node.GetDateTime("created-at");
            UpdatedAt              = node.GetDateTime("updated-at");
            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");
            BillingAddress         = new Address(node.GetNode("billing-address"));
            CardholderName         = node.GetString("cardholder-name");

            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);
            }
        }
Beispiel #27
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);
            }
        }
        public StripePaymentServiceTests()
        {
            _transactionRepository = Substitute.For <ITransactionRepository>();
            _userRepository        = Substitute.For <IUserRepository>();
            _appleIapService       = Substitute.For <IAppleIapService>();
            _globalSettings        = new GlobalSettings();
            _logger            = Substitute.For <ILogger <StripePaymentService> >();
            _taxRateRepository = Substitute.For <ITaxRateRepository>();
            _stripeAdapter     = Substitute.For <IStripeAdapter>();
            _braintreeGateway  = Substitute.For <IBraintreeGateway>();

            _sut = new StripePaymentService(
                _transactionRepository,
                _userRepository,
                _appleIapService,
                _logger,
                _taxRateRepository,
                _stripeAdapter,
                _braintreeGateway
                );
        }
        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);
            }
        }
Beispiel #30
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);
            }
        }
Beispiel #31
0
        public IActionResult Payment(string invoiceNo, string paykey)
        {
            PaymentDetails paymentDetails = _db.GetDetails(paykey);

            if (paymentDetails == null)
            {
                _logger.LogWarning("Payment details are null.");
                return(RedirectToArcadier(invoiceNo));
            }

            IBraintreeGateway gateway = _braintreeConfig.GetGateway();

            var model = new PaymentViewModel
            {
                InvoiceNo   = paymentDetails.InvoiceNo,
                PayKey      = paykey,
                Amount      = paymentDetails.Amount,
                Currency    = paymentDetails.Currency,
                ClientToken = gateway.ClientToken.Generate()
            };

            return(View(model));
        }
        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);
            }
        }
        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 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);
            }
        }
        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"));
            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));
            }
        }
Beispiel #36
0
 protected internal TransactionGateway(IBraintreeGateway gateway)
 {
     gateway.Configuration.AssertHasAccessTokenOrKeys();
     this.gateway = gateway;
     service      = new BraintreeService(gateway.Configuration);
 }
Beispiel #37
0
 /*==========================================================================================================================
 | GET GATEWAY
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Looks up the currently configured Braintree payments gateway. If the gateway is not currently available, it is
 ///   manually created.
 /// </summary>
 /// <returns>The configured Braintree payments gateway.</returns>
 public IBraintreeGateway GetGateway() {
   if (_braintreeGateway is null) {
     _braintreeGateway = CreateGateway();
   }
   return _braintreeGateway;
 }
Beispiel #38
0
 protected internal CreditCardGateway(IBraintreeGateway gateway)
 {
     gateway.Configuration.AssertHasAccessTokenOrKeys();
     this.gateway = gateway;
     service      = gateway.Service;
 }
 public AddOnGateway(IBraintreeGateway gateway)
 {
     gateway.Configuration.AssertHasAccessTokenOrKeys();
     Service = new BraintreeService(gateway.Configuration);
 }
 protected internal CreditCardGateway(IBraintreeGateway gateway)
 {
     gateway.Configuration.AssertHasAccessTokenOrKeys();
     this.gateway = gateway;
     service = new BraintreeService(gateway.Configuration);
 }
        private CreditCardVerification FindLatestVerification(List<NodeWrapper> verificationNodes, IBraintreeGateway gateway) {
            if(verificationNodes.Count > 0)
            {
                verificationNodes.Sort(delegate(NodeWrapper first, NodeWrapper second) {
                    DateTime time1 = (DateTime)first.GetDateTime("created-at");
                    DateTime time2 = (DateTime)second.GetDateTime("created-at");

                    return DateTime.Compare(time2, time1);
                });

                return new CreditCardVerification(verificationNodes[0], gateway);
            }

            return null;
        }
        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);
        }
Beispiel #43
0
        protected internal Customer(NodeWrapper node, IBraintreeGateway 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");
        }
        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);
            }
            var usBankAccountNode = node.GetNode("us-bank-account");
            if (usBankAccountNode != null)
            {
                UsBankAccountDetails = new UsBankAccountDetails(usBankAccountNode);
            }

            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);
            }
        }
Beispiel #45
0
        private T newInstanceFromResponse(NodeWrapper node, IBraintreeGateway gateway)
        {
            if (typeof(T) == typeof(Address))
            {
                return new Address(node) as T;
            }
            else if (typeof(T) == typeof(ApplePayCard))
            {
                return new ApplePayCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(AndroidPayCard))
            {
                return new AndroidPayCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(AmexExpressCheckoutCard))
            {
                return new AmexExpressCheckoutCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(CreditCard))
            {
                return new CreditCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(CreditCardVerification))
            {
                return new CreditCardVerification(node, gateway) as T;
            }
            else if (typeof(T) == typeof(CoinbaseAccount))
            {
                return new CoinbaseAccount(node, gateway) as T;
            }
            else if (typeof(T) == typeof(VenmoAccount))
            {
                return new VenmoAccount(node, gateway) as T;
            }
            else if (typeof(T) == typeof(Customer))
            {
                return new Customer(node, gateway) as T;
            }
            else if (typeof(T) == typeof(Dispute))
            {
                return new Dispute(node) as T;
            }
            else if (typeof(T) == typeof(DisputeEvidence))
            {
                return new DisputeEvidence(node) as T;
            }
            else if (typeof(T) == typeof(DocumentUpload))
            {
                return new DocumentUpload(node) as T;
            }
            else if (typeof(T) == typeof(Transaction))
            {
                return new Transaction(node, gateway) as T;
            }
            else if (typeof(T) == typeof(Subscription))
            {
                return new Subscription(node, gateway) as T;
            }
            else if (typeof(T) == typeof(SettlementBatchSummary))
            {
                return new SettlementBatchSummary(node) as T;
            }
            else if (typeof(T) == typeof(MerchantAccount))
            {
                return new MerchantAccount(node) as T;
            }
            else if (typeof(T) == typeof(PayPalAccount))
            {
                return new PayPalAccount(node, gateway) as T;
            }
            else if (typeof(T) == typeof(UsBankAccount))
            {
                return new UsBankAccount(node) as T;
            }
            else if (typeof(T) == typeof(VisaCheckoutCard))
            {
                return new VisaCheckoutCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(MasterpassCard))
            {
                return new MasterpassCard(node, gateway) as T;
            }
            else if (typeof(T) == typeof(UnknownPaymentMethod))
            {
                return new UnknownPaymentMethod(node) as T;
            }
            else if (typeof(T) == typeof(PaymentMethodNonce))
            {
                return new PaymentMethodNonce(node, gateway) as T;
            }
            else if (typeof(T) == typeof(OAuthCredentials))
            {
                return new OAuthCredentials(node) as T;
            }
            else if (typeof(T) == typeof(OAuthResult))
            {
                return new OAuthResult(node) as T;
            }
            else if (typeof(T) == typeof(Merchant))
            {
                return new Merchant(node) as T;
            }

            throw new Exception("Unknown T: " + typeof(T).ToString());
        }
Beispiel #46
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("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"));
            }

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

            if (WrapperNode.GetNode("local-payment") != null)
            {
                LocalPaymentCompleted = new LocalPaymentCompleted(WrapperNode.GetNode("local-payment"));
            }
        }
 protected internal AddressGateway(IBraintreeGateway gateway)
 {
     gateway.Configuration.AssertHasAccessTokenOrKeys();
     Gateway = gateway;
     Service = new BraintreeService(gateway.Configuration);
 }