public virtual RequestBuilder BuildRequest(string root)
        {
#if netcore
            CultureInfo originalCulture = CultureInfo.CurrentCulture;
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
#else
            CultureInfo originalCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
#endif

            var builder = new RequestBuilder(root);
            builder.AddElement("settlement-date", SettlementDate.ToString("d"));

#if netcore
            CultureInfo.CurrentCulture = originalCulture;
#else
            Thread.CurrentThread.CurrentCulture = originalCulture;
#endif

            if (GroupByCustomField != null)
            {
                builder.AddElement("group-by-custom-field", GroupByCustomField);
            }
            return builder;
        }
        public virtual RequestBuilder BuildRequest(String root)
        {
            var builder = new RequestBuilder(root);

            builder.AddElement("billing-day-of-month", BillingDayOfMonth);
            builder.AddElement("descriptor", Descriptor);
            builder.AddElement("first-billing-date", FirstBillingDate);
            builder.AddElement("payment-method-token", PaymentMethodToken);
            if (HasTrialPeriod.HasValue)
            {
                builder.AddElement("trial-period", HasTrialPeriod.Value);

                if (HasTrialPeriod.Value)
                {
                    if (TrialDuration != 0) builder.AddElement("trial-duration", TrialDuration.ToString());
                    builder.AddElement("trial-duration-unit", TrialDurationUnit.ToString().ToLower());
                }
            }
            builder.AddElement("merchant-account-id", MerchantAccountId);
            if (NumberOfBillingCycles.HasValue) {
                builder.AddElement("number-of-billing-cycles", NumberOfBillingCycles.Value);
            }
            if (NeverExpires.HasValue) {
                builder.AddElement("never-expires", NeverExpires.Value);
            }
            builder.AddElement("id", Id);
            builder.AddElement("plan-id", PlanId);
            if (Price != 0) builder.AddElement("price", Price);

            builder.AddElement("add-ons", AddOns);
            builder.AddElement("discounts", Discounts);
            builder.AddElement("options", Options);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(String root)
        {
            RequestBuilder builder = new RequestBuilder(root);

            if (Amount != 0) builder.AddElement("amount", Amount);
            builder.AddElement("customer-id", CustomerId);
            builder.AddElement("order-id", OrderId);
            builder.AddElement("payment-method-token", PaymentMethodToken);
            builder.AddElement("purchase-order-number", PurchaseOrderNumber);
            builder.AddElement("shipping-address-id", ShippingAddressId);
            if (TaxAmount != 0) builder.AddElement("tax-amount", TaxAmount);
            if (TaxExempt.HasValue) {
                builder.AddElement("tax-exempt", TaxExempt);
            }
            builder.AddElement("merchant-account-id", MerchantAccountId);

            if (Type != null) builder.AddElement("type", Type.ToString().ToLower());

            if (CustomFields.Count != 0) builder.AddElement("custom-fields", CustomFields);

            builder.AddElement("credit-card", CreditCard);
            builder.AddElement("customer", Customer);
            builder.AddElement("descriptor", Descriptor);
            builder.AddElement("billing", BillingAddress);
            builder.AddElement("shipping", ShippingAddress);
            builder.AddElement("options", Options);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);
            builder.AddElement("credit-card", CreditCard);
            builder.AddElement("options", Options);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(String root)
        {
            RequestBuilder builder = new RequestBuilder(root);
            builder.AddElement("amount", Amount);
            builder.AddElement("options", Options);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);
            builder.AddElement("amount", Amount);
            builder.AddElement("merchant-account-id", MerchantAccountId);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);
            builder.AddElement("amount", Amount);
            builder.AddElement("channel", Channel);
            builder.AddElement("options", Options);

            return builder;
        }
 protected virtual RequestBuilder BuildRequest(string root)
 {
     var builder = new RequestBuilder(root);
     builder.AddElement("make-default", MakeDefault);
     builder.AddElement("verification-merchant-account-id", VerificationMerchantAccountId);
     builder.AddElement("verify-card", VerifyCard);
     builder.AddElement("fail-on-duplicate-payment-method", FailOnDuplicatePaymentMethod);
     return builder;
 }
Esempio n. 9
0
      protected virtual RequestBuilder BuildRequest(String root)
      {
        RequestBuilder builder = new RequestBuilder(root);

        builder.AddElement("dba-name", DbaName);
        builder.AddElement("legal-name", LegalName);
        builder.AddElement("address", Address);
        builder.AddElement("tax-id", TaxId);
        return builder;
      }
        protected virtual RequestBuilder BuildRequest(String root)
        {
            RequestBuilder builder = new RequestBuilder(root);

            if (Amount != 0) builder.AddElement("amount", Amount);
            builder.AddElement("subscription-id", SubscriptionId);
            builder.AddElement("type", TransactionType.SALE.ToString().ToLower());

            return builder;
        }
        private RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root).
                AddElement("description", Description).
                AddElement("custom-field", CustomField).
                AddElement("payee-email", PayeeEmail);

            if(SupplementaryData.Count != 0) builder.AddElement("supplementary-data", SupplementaryData);

            return builder;
        }
        protected virtual RequestBuilder BuildRequest(String root)
        {
            RequestBuilder builder = new RequestBuilder(root);

            builder.AddElement("make-default", MakeDefault);
            builder.AddElement("verification-merchant-account-id", VerificationMerchantAccountId);
            builder.AddElement("verify-card", VerifyCard);
            builder.AddElement("update-existing-token", UpdateExistingToken);

            return builder;
        }
Esempio n. 13
0
        protected virtual RequestBuilder BuildRequest(String root)
        {
            RequestBuilder builder = new RequestBuilder(root);

            if (CustomerId != null) builder.AddElement("customer-id", CustomerId);
            if (Version != 0) builder.AddElement("version", Version);
            if (MerchantAccountId != null) builder.AddElement("merchant-account-id", MerchantAccountId);
            if (Options != null) builder.AddElement("options", Options);

            return builder;
        }
      protected virtual RequestBuilder BuildRequest(string root)
      {
        var builder = new RequestBuilder(root);

        builder.AddElement("destination", Destination);
        builder.AddElement("email", Email);
        builder.AddElement("mobile-phone", MobilePhone);
        builder.AddElement("routing-number", RoutingNumber);
        builder.AddElement("account-number", AccountNumber);
        builder.AddElement("descriptor", Descriptor);
        return builder;
      }
    protected virtual RequestBuilder BuildRequest(String root)
    {
      RequestBuilder builder = new RequestBuilder(root);

      builder.AddElement("id", Id);
      builder.AddElement("applicant-details", ApplicantDetails);
      builder.AddElement("individual", Individual);
      builder.AddElement("funding", Funding);
      builder.AddElement("business", Business);
      builder.AddElement("tos-accepted", TosAccepted);
      builder.AddElement("master-merchant-account-id", MasterMerchantAccountId);
      return builder;
    }
Esempio n. 16
0
      protected virtual RequestBuilder BuildRequest(String root)
      {
        RequestBuilder builder = new RequestBuilder(root);

        builder.AddElement("first-name", FirstName);
        builder.AddElement("last-name", LastName);
        builder.AddElement("email", Email);
        builder.AddElement("phone", Phone);
        builder.AddElement("address", Address);
        builder.AddElement("date-of-birth", DateOfBirth);
        builder.AddElement("ssn", Ssn);
        return builder;
      }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);

            builder.AddElement("make-default", MakeDefault);
            builder.AddElement("verification-merchant-account-id", VerificationMerchantAccountId);
            builder.AddElement("verify-card", VerifyCard);
            builder.AddElement("verification-amount", VerificationAmount);
            builder.AddElement("fail-on-duplicate-payment-method", FailOnDuplicatePaymentMethod);
            builder.AddElement("update-existing-token", UpdateExistingToken);
            builder.AddElement("venmo-sdk-session", VenmoSdkSession);

            return builder;
        }
        public virtual RequestBuilder BuildRequest(String root)
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            var builder = new RequestBuilder(root);
            builder.AddElement("settlement-date", SettlementDate.ToShortDateString());
            
            Thread.CurrentThread.CurrentCulture = originalCulture;

            if (GroupByCustomField != null)
            {
                builder.AddElement("group-by-custom-field", GroupByCustomField);
            }
            return builder;
        }
 public override string ToQueryString(string root)
 {
     var builder = new RequestBuilder("user"); // ignore the root as it is wrong
     builder.AddElement("country", Country);
     builder.AddElement("email", Email);
     builder.AddElement("first_name", FirstName);
     builder.AddElement("last_name", LastName);
     builder.AddElement("phone", Phone);
     builder.AddElement("dob_year", DobYear);
     builder.AddElement("dob_month", DobMonth);
     builder.AddElement("dob_day", DobDay);
     builder.AddElement("street_address", StreetAddress);
     builder.AddElement("locality", Locality);
     builder.AddElement("region", Region);
     builder.AddElement("postal_code", PostalCode);
     return builder.ToQueryString();
 }
        public override string ToQueryString()
        {
            var builder = new RequestBuilder();
            builder.AddTopLevelElement("merchant_id", MerchantId);
            builder.AddTopLevelElement("redirect_uri", RedirectUri);
            builder.AddTopLevelElement("scope", Scope);
            builder.AddTopLevelElement("state", State);
            builder.AddTopLevelElement("client_id", ClientId);

            foreach (var paymentMethod in PaymentMethods) {
                builder.AddTopLevelElement("payment_methods[]", paymentMethod);
            }

            builder.AddElement("user", User);
            builder.AddElement("business", Business);
            return builder.ToQueryString();
        }
      protected virtual RequestBuilder BuildRequest(string root)
      {
        var builder = new RequestBuilder(root);

        builder.AddElement("company-name", CompanyName);
        builder.AddElement("first-name", FirstName);
        builder.AddElement("last-name", LastName);
        builder.AddElement("email", Email);
        builder.AddElement("phone", Phone);
        builder.AddElement("address", Address);
        builder.AddElement("date-of-birth", DateOfBirth);
        builder.AddElement("ssn", Ssn);
        builder.AddElement("tax-id", TaxId);
        builder.AddElement("routing-number", RoutingNumber);
        builder.AddElement("account-number", AccountNumber);
        return builder;
      }
 public override string ToQueryString(string root)
 {
     var builder = new RequestBuilder("business");  // ignore the root as it is wrong
     builder.AddElement("name", Name);
     builder.AddElement("registered_as", RegisteredAs);
     builder.AddElement("industry", Industry);
     builder.AddElement("description", Description);
     builder.AddElement("street_address", StreetAddress);
     builder.AddElement("locality", Locality);
     builder.AddElement("region", Region);
     builder.AddElement("postal_code", PostalCode);
     builder.AddElement("country", Country);
     builder.AddElement("annual_volume_amount", AnnualVolumeAmount);
     builder.AddElement("average_transaction_amount", AverageTransactionAmount);
     builder.AddElement("maximum_transaction_amount", MaximumTransactionAmount);
     builder.AddElement("ship_physical_goods", ShipPhysicalGoods);
     builder.AddElement("fulfillment_completed_in", FulfillmentCompletedIn);
     builder.AddElement("currency", Currency);
     builder.AddElement("website", Website);
     return builder.ToQueryString();
 }
Esempio n. 23
0
    public static string GenerateUnlockedNonce(BraintreeGateway gateway, string creditCardNumber, string customerId)
    {
      var clientToken = "";
      if (customerId ==  null) {
        clientToken = TestHelper.GenerateDecodedClientToken(gateway);
      } else {
        clientToken = TestHelper.GenerateDecodedClientToken(gateway, new ClientTokenRequest
          {
            CustomerId = customerId
          }
        );
      }
      var authorizationFingerprint  = extractParamFromJson("authorizationFingerprint", clientToken);
      RequestBuilder builder = new RequestBuilder("");
      builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
        AddTopLevelElement("shared_customer_identifier_type", "testing").
        AddTopLevelElement("shared_customer_identifier", "test-identifier").
        AddTopLevelElement("credit_card[number]", creditCardNumber).
        AddTopLevelElement("share", "true").
        AddTopLevelElement("credit_card[expiration_month]", "11").
        AddTopLevelElement("credit_card[expiration_year]", "2099");

      HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());
      StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
      string responseBody = reader.ReadToEnd();

      Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\"");
      Match match = regex.Match(responseBody);
      return match.Groups["nonce"].Value;
    }
Esempio n. 24
0
        public void Generate_GatewayRespectsMakeDefault()
        {
            BraintreeGateway gateway = new BraintreeGateway
            {
                Environment = Environment.DEVELOPMENT,
                MerchantId = "integration_merchant_id",
                PublicKey = "integration_public_key",
                PrivateKey = "integration_private_key"
            };
            Result<Customer> result = gateway.Customer.Create(new CustomerRequest());
            Assert.IsTrue(result.IsSuccess());
            string customerId = result.Target.Id;

            var request = new CreditCardRequest
            {
                CustomerId = customerId,
                Number = "5105105105105100",
                ExpirationDate = "05/2099"
            };
            Result<CreditCard> creditCardResult = gateway.CreditCard.Create(request);
            Assert.IsTrue(creditCardResult.IsSuccess());

            var clientToken = TestHelper.GenerateDecodedClientToken(gateway,
                new ClientTokenRequest
                {
                    CustomerId = customerId,
                    Options = new ClientTokenOptionsRequest
                    {
                        MakeDefault = true
                    }
                }
            );
            var authorizationFingerprint = TestHelper.extractParamFromJson("authorizationFingerprint", clientToken);

            RequestBuilder builder = new RequestBuilder("");
            builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
                AddTopLevelElement("shared_customer_identifier_type", "testing").
                AddTopLevelElement("shared_customer_identifier", "test-identifier").
                AddTopLevelElement("credit_card[number]", "4111111111111111").
                AddTopLevelElement("credit_card[expiration_month]", "11").
                AddTopLevelElement("credit_card[expiration_year]", "2099");

            HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/credit_cards.json", builder.ToQueryString());
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            response.Close();

            Customer customer = gateway.Customer.Find(customerId);
            Assert.AreEqual(2, customer.CreditCards.Length);
            foreach (CreditCard creditCard in customer.CreditCards)
            {
                if (creditCard.LastFour == "1111") {
                    Assert.IsTrue(creditCard.IsDefault.Value);
                }
            }
        }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);

            if (Amount != 0)
            {
                builder.AddElement("amount", Amount);
            }
            builder.AddElement("device-data", DeviceData);
            builder.AddElement("customer-id", CustomerId);
            builder.AddElement("order-id", OrderId);
            builder.AddElement("product-sku", ProductSku);
            builder.AddElement("channel", Channel);
// Remove this pragma warning when we remove DeviceSessionId, FraudMerchantId, and Recurring.
// We have this so we can build the SDK without obsolete error messages
#pragma warning disable 618
            builder.AddElement("device-session-id", DeviceSessionId);
            builder.AddElement("fraud-merchant-id", FraudMerchantId);
            if (Recurring.HasValue)
            {
                builder.AddElement("recurring", Recurring);
            }
#pragma warning restore 618
            builder.AddElement("transaction-source", TransactionSource);
            builder.AddElement("payment-method-token", PaymentMethodToken);
            builder.AddElement("payment-method-nonce", PaymentMethodNonce);
            builder.AddElement("purchase-order-number", PurchaseOrderNumber);
            builder.AddElement("shipping-address-id", ShippingAddressId);
            builder.AddElement("billing-address-id", BillingAddressId);
            if (TaxAmount.HasValue)
            {
                builder.AddElement("tax-amount", TaxAmount);
            }
            if (TaxExempt.HasValue)
            {
                builder.AddElement("tax-exempt", TaxExempt);
            }
            builder.AddElement("merchant-account-id", MerchantAccountId);
            if (ServiceFeeAmount.HasValue)
            {
                builder.AddElement("service-fee-amount", ServiceFeeAmount);
            }

            if (Type != null)
            {
                builder.AddElement("type", Type.GetDescription());
            }

            if (CustomFields.Count != 0)
            {
                builder.AddElement("custom-fields", CustomFields);
            }

            builder.AddElement("currency-iso-code", CurrencyIsoCode);
            builder.AddElement("credit-card", CreditCard);
            builder.AddElement("customer", Customer);
            builder.AddElement("descriptor", Descriptor);
            builder.AddElement("industry", Industry);
            builder.AddElement("billing", BillingAddress);
            builder.AddElement("shipping", ShippingAddress);
            builder.AddElement("paypal-account", PayPalAccount);
            builder.AddElement("options", Options);
            builder.AddElement("three-d-secure-pass-thru", ThreeDSecurePassThru);
            builder.AddElement("three-d-secure-authentication-id", ThreeDSecureAuthenticationId);
            builder.AddElement("venmo-sdk-payment-method-code", VenmoSdkPaymentMethodCode);
            builder.AddElement("sca-exemption", ScaExemption);
            builder.AddElement("shared-payment-method-token", SharedPaymentMethodToken);
            builder.AddElement("shared-payment-method-nonce", SharedPaymentMethodNonce);
            builder.AddElement("shared-customer-id", SharedCustomerId);
            builder.AddElement("shared-shipping-address-id", SharedShippingAddressId);
            builder.AddElement("shared-billing-address-id", SharedBillingAddressId);
            if (_threeDSecureTransaction)
            {
                builder.AddElement("three-d-secure-token", ThreeDSecureToken ?? "");
            }
            builder.AddElement("risk-data", RiskData);
            if (ShippingAmount.HasValue)
            {
                builder.AddElement("shipping-amount", ShippingAmount);
            }
            if (DiscountAmount.HasValue)
            {
                builder.AddElement("discount-amount", DiscountAmount);
            }
            builder.AddElement("ships-from-postal-code", ShipsFromPostalCode);
            if (LineItems != null)
            {
                builder.AddElement("line-items", LineItems);
            }
            if (ExternalVault != null)
            {
                builder.AddElement("external-vault", ExternalVault);
            }
            if (AndroidPayCard != null)
            {
                builder.AddElement("android-pay-card", AndroidPayCard);
            }
            if (ApplePayCard != null)
            {
                builder.AddElement("apple-pay-card", ApplePayCard);
            }
            if (InstallmentRequest != null)
            {
                builder.AddElement("installments", InstallmentRequest);
            }
            return(builder);
        }
Esempio n. 26
0
 internal virtual string BuildXMLElement(string name, object value)
 {
     return(RequestBuilder.BuildXMLElement(name, value));
 }
 protected virtual RequestBuilder BuildRequest(String root)
 {
     RequestBuilder builder = new RequestBuilder(root);
     builder.AddElement("make-default", MakeDefault);
     return builder;
 }
Esempio n. 28
0
 protected virtual String ParentBracketChildString(String parent, String child)
 {
     return(RequestBuilder.ParentBracketChildString(parent, child));
 }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);

            if (Amount != 0) builder.AddElement("amount", Amount);
            builder.AddElement("device-data", DeviceData);
            builder.AddElement("customer-id", CustomerId);
            builder.AddElement("order-id", OrderId);
            builder.AddElement("channel", Channel);
            builder.AddElement("device-session-id", DeviceSessionId);
            builder.AddElement("fraud-merchant-id", FraudMerchantId);
            if (Recurring.HasValue) builder.AddElement("recurring", Recurring);
            builder.AddElement("payment-method-token", PaymentMethodToken);
            builder.AddElement("payment-method-nonce", PaymentMethodNonce);
            builder.AddElement("purchase-order-number", PurchaseOrderNumber);
            builder.AddElement("shipping-address-id", ShippingAddressId);
            builder.AddElement("billing-address-id", BillingAddressId);
            if (TaxAmount != 0) builder.AddElement("tax-amount", TaxAmount);
            if (TaxExempt.HasValue) {
                builder.AddElement("tax-exempt", TaxExempt);
            }
            builder.AddElement("merchant-account-id", MerchantAccountId);
            if (ServiceFeeAmount.HasValue) builder.AddElement("service-fee-amount", ServiceFeeAmount);

            if (Type != null) builder.AddElement("type", Type.ToString().ToLower());

            if (CustomFields.Count != 0) builder.AddElement("custom-fields", CustomFields);

            builder.AddElement("credit-card", CreditCard);
            builder.AddElement("customer", Customer);
            builder.AddElement("descriptor", Descriptor);
            builder.AddElement("industry", Industry);
            builder.AddElement("billing", BillingAddress);
            builder.AddElement("shipping", ShippingAddress);
            builder.AddElement("paypal-account", PayPalAccount);
            builder.AddElement("options", Options);
            builder.AddElement("venmo-sdk-payment-method-code", VenmoSdkPaymentMethodCode);
            if (_threeDSecureTransaction) {
                builder.AddElement("three-d-secure-token", ThreeDSecureToken ?? "");
            }
            return builder;
        }
Esempio n. 30
0
    public static string GetNonceForNewPaymentMethod(BraintreeGateway gateway, Params @params, bool isCreditCard)
    {
        var clientToken = GenerateDecodedClientToken(gateway);
        var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken);

        var paymentMethodType = isCreditCard ? "credit_card" : "paypal_account";
        var paymentMethodTypePlural = paymentMethodType + "s";
        var builder = new RequestBuilder();
        builder.
            AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
            AddTopLevelElement("shared_customer_identifier", "test-identifier").
            AddTopLevelElement("shared_customer_identifier_type", "testing");
        foreach (var param in @params)
            builder.AddTopLevelElement(string.Format("{0}[{1}]", paymentMethodType, param.Key), param.Value.ToString());

        var response = new BraintreeTestHttpService().Post(
            gateway.MerchantId,
            "v1/payment_methods/" + paymentMethodTypePlural,
            builder.ToQueryString());

        return extractParamFromJson("nonce", response);
    }
Esempio n. 31
0
    public static string GetNonceForNewCreditCard(BraintreeGateway gateway, Params creditCardDetails, string customerId = null)
    {
        var clientToken = TestHelper.GenerateDecodedClientToken(
            gateway,
            customerId == null ? null : new ClientTokenRequest { CustomerId = customerId });

        var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken);

        var builder = new RequestBuilder();
        builder.
            AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
            AddTopLevelElement("shared_customer_identifier", "test-identifier").
            AddTopLevelElement("shared_customer_identifier_type", "testing");

        foreach (var param in creditCardDetails) {
            var nested = param.Value as Params;
            if (null != nested) {
                foreach (var nestedParam in nested) {
                    builder.AddTopLevelElement(string.Format("credit_card[{0}][{1}]", param.Key, nestedParam.Key), nestedParam.Value.ToString());
                }
            } else
                builder.AddTopLevelElement(string.Format("credit_card[{0}]", param.Key), param.Value.ToString());
        }

        var response = new BraintreeTestHttpService().Post(
            gateway.MerchantId,
            "v1/payment_methods/credit_cards",
            builder.ToQueryString());

        return extractParamFromJson("nonce", response);
    }
Esempio n. 32
0
    public static string GenerateFuturePaymentPayPalNonce(BraintreeGateway gateway)
    {
        var clientToken = TestHelper.GenerateDecodedClientToken(gateway);
        var authorizationFingerprint  = extractParamFromJson("authorizationFingerprint", clientToken);
        RequestBuilder builder = new RequestBuilder("");
        builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint).
            AddTopLevelElement("shared_customer_identifier_type", "testing").
            AddTopLevelElement("shared_customer_identifier", "test-identifier").
            AddTopLevelElement("paypal_account[consent_code]", "consent").
            AddTopLevelElement("paypal_account[correlation_id]", System.Guid.NewGuid().ToString()).
            AddTopLevelElement("paypal_account[options][validate]", "false");

        HttpWebResponse response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/paypal_accounts", builder.ToQueryString());
        StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
        string responseBody = reader.ReadToEnd();

        Regex regex = new Regex("nonce\":\"(?<nonce>[a-f0-9\\-]+)\"");
        Match match = regex.Match(responseBody);
        return match.Groups["nonce"].Value;
    }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root);

            if (Amount != 0)
            {
                builder.AddElement("amount", Amount);
            }
            builder.AddElement("device-data", DeviceData);
            builder.AddElement("customer-id", CustomerId);
            builder.AddElement("order-id", OrderId);
            builder.AddElement("channel", Channel);
            builder.AddElement("device-session-id", DeviceSessionId);
            builder.AddElement("fraud-merchant-id", FraudMerchantId);
            if (Recurring.HasValue)
            {
                builder.AddElement("recurring", Recurring);
            }
            builder.AddElement("payment-method-token", PaymentMethodToken);
            builder.AddElement("payment-method-nonce", PaymentMethodNonce);
            builder.AddElement("purchase-order-number", PurchaseOrderNumber);
            builder.AddElement("shipping-address-id", ShippingAddressId);
            builder.AddElement("billing-address-id", BillingAddressId);
            if (TaxAmount != 0)
            {
                builder.AddElement("tax-amount", TaxAmount);
            }
            if (TaxExempt.HasValue)
            {
                builder.AddElement("tax-exempt", TaxExempt);
            }
            builder.AddElement("merchant-account-id", MerchantAccountId);
            if (ServiceFeeAmount.HasValue)
            {
                builder.AddElement("service-fee-amount", ServiceFeeAmount);
            }

            if (Type != null)
            {
                builder.AddElement("type", Type.ToString().ToLower());
            }

            if (CustomFields.Count != 0)
            {
                builder.AddElement("custom-fields", CustomFields);
            }

            builder.AddElement("credit-card", CreditCard);
            builder.AddElement("customer", Customer);
            builder.AddElement("descriptor", Descriptor);
            builder.AddElement("industry", Industry);
            builder.AddElement("billing", BillingAddress);
            builder.AddElement("shipping", ShippingAddress);
            builder.AddElement("paypal-account", PayPalAccount);
            builder.AddElement("options", Options);
            builder.AddElement("venmo-sdk-payment-method-code", VenmoSdkPaymentMethodCode);
            builder.AddElement("shared-payment-method-token", SharedPaymentMethodToken);
            builder.AddElement("shared-customer-id", SharedCustomerId);
            builder.AddElement("shared-shipping-address-id", SharedShippingAddressId);
            builder.AddElement("shared-billing-address-id", SharedBillingAddressId);
            if (_threeDSecureTransaction)
            {
                builder.AddElement("three-d-secure-token", ThreeDSecureToken ?? "");
            }
            return(builder);
        }
Esempio n. 34
0
    public static string GetNonceForPayPalAccount(BraintreeGateway gateway, Params paypalAccountDetails)
    {
        var clientToken = GenerateDecodedClientToken(gateway);
        var authorizationFingerprint = extractParamFromJson("authorizationFingerprint", clientToken);
        var builder = new RequestBuilder();
        builder.AddTopLevelElement("authorization_fingerprint", authorizationFingerprint);
        foreach (var param in paypalAccountDetails)
            builder.AddTopLevelElement(string.Format("paypal_account[{0}]", param.Key), param.Value.ToString());

        var response = new BraintreeTestHttpService().Post(gateway.MerchantId, "v1/payment_methods/paypal_accounts", builder.ToQueryString());
        return extractParamFromJson("nonce", response);
    }
        protected virtual RequestBuilder BuildRequest(string root)
        {
            var builder = new RequestBuilder(root).
                          AddElement("folio-number", FolioNumber).
                          AddElement("check-in-date", CheckInDate).
                          AddElement("check-out-date", CheckOutDate).
                          AddElement("travel-package", TravelPackage).
                          AddElement("departure-date", DepartureDate).
                          AddElement("lodging-check-in-date", LodgingCheckInDate).
                          AddElement("lodging-check-out-date", LodgingCheckOutDate).
                          AddElement("lodging-name", LodgingName).
                          AddElement("passenger-first-name", PassengerFirstName).
                          AddElement("passenger-last-name", PassengerLastName).
                          AddElement("passenger-middle-initial", PassengerMiddleInitial).
                          AddElement("passenger-title", PassengerTitle).
                          AddElement("travel-agency-name", TravelAgencyName).
                          AddElement("travel-agency-code", TravelAgencyCode).
                          AddElement("ticket-number", TicketNumber).
                          AddElement("issuing-carrier-code", IssuingCarrierCode).
                          AddElement("customer-code", CustomerCode).
                          AddElement("property-phone", PropertyPhone);

            if (RoomRate != null)
            {
                builder.AddElement("room-rate", RoomRate.ToString());
            }
            if (RoomTax != null)
            {
                builder.AddElement("room-tax", RoomTax.ToString());
            }
            if (IssuedDate != null)
            {
                builder.AddElement("issued-date", IssuedDate);
            }
            if (FareAmount != null)
            {
                builder.AddElement("fare-amount", FareAmount);
            }
            if (FeeAmount != null)
            {
                builder.AddElement("fee-amount", FeeAmount);
            }
            if (TaxAmount != null)
            {
                builder.AddElement("tax-amount", TaxAmount);
            }
            if (RestrictedTicket != null)
            {
                builder.AddElement("restricted-ticket", RestrictedTicket);
            }
            if (NoShow != null)
            {
                builder.AddElement("no-show", NoShow);
            }
            if (AdvancedDeposit != null)
            {
                builder.AddElement("advanced-deposit", AdvancedDeposit);
            }
            if (FireSafe != null)
            {
                builder.AddElement("fire-safe", FireSafe);
            }
            if (Legs != null)
            {
                builder.AddElement("legs", Legs);
            }
            if (AdditionalCharges != null)
            {
                builder.AddElement("additional-charges", AdditionalCharges);
            }
            return(builder);
        }