### Generate Client Token in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ClientTokenGateway.md Basic and customer-specific token generation examples. ```csharp // Basic client token string clientToken = gateway.ClientToken.Generate(); // Client token for specific customer var request = new ClientTokenRequest { CustomerId = "customer_id" }; string clientToken = gateway.ClientToken.Generate(request); ``` -------------------------------- ### Initialize BraintreeGateway and Process a Transaction Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Demonstrates the standard setup for the BraintreeGateway and executing a basic sale transaction. Ensure valid sandbox credentials are provided before execution. ```csharp using System; using Braintree; namespace BraintreeExample { class Program { static void Main(string[] args) { var gateway = new BraintreeGateway { Environment = Environment.SANDBOX, MerchantId = "the_merchant_id", PublicKey = "a_public_key", PrivateKey = "a_private_key" }; var request = new TransactionRequest { Amount = 100.00M, PaymentMethodNonce = "nonce_from_client" }; Result result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Console.WriteLine("Success! Transaction ID: " + result.Target.Id); } else { Console.WriteLine("Error: " + result.Message); } } } } ``` -------------------------------- ### Quick Start: Braintree Gateway Transaction Sale Source: https://github.com/braintree/braintree_dotnet/blob/master/README.md This example demonstrates how to initialize the Braintree Gateway in sandbox mode and process a transaction sale using a payment method nonce. It includes error handling for successful transactions and various failure scenarios. ```csharp using System; using Braintree; namespace BraintreeExample { class Program { static void Main(string[] args) { var gateway = new BraintreeGateway { Environment = Braintree.Environment.SANDBOX, MerchantId = "the_merchant_id", PublicKey = "a_public_key", PrivateKey = "a_private_key" }; TransactionRequest request = new TransactionRequest { Amount = 1000.00M, PaymentMethodNonce = nonceFromTheClient, Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; Result result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Transaction transaction = result.Target; Console.WriteLine("Success!: " + transaction.Id); } else if (result.Transaction != null) { Transaction transaction = result.Transaction; Console.WriteLine("Error processing transaction:"); Console.WriteLine(" Status: " + transaction.Status); Console.WriteLine(" Code: " + transaction.ProcessorResponseCode); Console.WriteLine(" Text: " + transaction.ProcessorResponseText); } else { foreach (ValidationError error in result.Errors.DeepAll()) { Console.WriteLine("Attribute: " + error.Attribute); Console.WriteLine(" Code: " + error.Code); Console.WriteLine(" Message: " + error.Message); } } } } } ``` -------------------------------- ### Install Braintree NuGet Package Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Use the .NET CLI to add the Braintree package to your project. ```bash dotnet add package Braintree ``` -------------------------------- ### Search Credit Cards Usage Example Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CreditCardGateway.md Demonstrates searching for credit cards by customer ID and expiration date, then iterating through the results. ```csharp var cards = gateway.CreditCard.Search(search => { search.CustomerId().Is("customer_id"); search.ExpirationDate().Is("12/2025"); }); foreach (CreditCard card in cards.Fetch(0, 25)) { Console.WriteLine(card.MaskedNumber); } ``` -------------------------------- ### SubmitForSettlement Usage Example Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Demonstrates submitting a transaction for settlement and checking the result status. ```csharp Result result = gateway.Transaction.SubmitForSettlement("transaction_id"); if (result.IsSuccess()) { Console.WriteLine("Status: " + result.Target.Status); } ``` -------------------------------- ### Perform 3D Secure Lookup Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ThreeDSecureGateway.md Example of initiating a lookup request and handling the result to check if authentication is required. ```csharp var request = new ThreeDSecureLookupRequest { Amount = 100.00M, Nonce = "payment_method_nonce" }; Result result = gateway.ThreeDSecure.Lookup(request); if (result.IsSuccess()) { ThreeDSecureLookup lookup = result.Target; if (lookup.Threaded) { Console.WriteLine("3DS authentication required"); // Redirect user to authentication } } ``` -------------------------------- ### SubmitForPartialSettlement Usage Example Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Demonstrates submitting a partial settlement using a TransactionRequest object. ```csharp var request = new TransactionRequest { Amount = 50.00M }; Result result = gateway.Transaction.SubmitForPartialSettlement("txn_id", request); ``` -------------------------------- ### AdjustAuthorization Usage Example Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Demonstrates adjusting the authorized amount of a transaction. ```csharp Result result = gateway.Transaction.AdjustAuthorization("txn_id", 150.00M); ``` -------------------------------- ### Initialize Configuration with Environment and Keys Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Creates a configuration using an explicit Environment object and API keys. ```csharp public Configuration( Environment environment, string merchantId, string publicKey, string privateKey ) ``` -------------------------------- ### Build and Test with .NET CLI on Windows Source: https://github.com/braintree/braintree_dotnet/blob/master/DEVELOPMENT.md Restore dependencies, build the project, and run tests using the dotnet CLI on a Windows environment. ```bash dotnet restore dotnet build dotnet test . ``` -------------------------------- ### Configure Gateway with API Keys Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Initializes the gateway using explicit environment, merchant ID, public key, and private key. ```csharp var configuration = new Configuration( Environment.SANDBOX, "your_merchant_id", "your_public_key", "your_private_key" ); var gateway = new BraintreeGateway(configuration); ``` -------------------------------- ### Initialize Configuration with String Environment Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Creates a configuration using a string-based environment name and API keys. ```csharp public Configuration( string environment, string merchantId, string publicKey, string privateKey ) ``` -------------------------------- ### Configure Gateway with String Environment Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Initializes the gateway using a string representation for the environment. ```csharp var configuration = new Configuration( "sandbox", "your_merchant_id", "your_public_key", "your_private_key" ); var gateway = new BraintreeGateway(configuration); ``` -------------------------------- ### Retrieve and Paginate Plans Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Demonstrates how to fetch all plans and iterate through them using pagination with the Fetch method. ```csharp var plans = gateway.Plan.All(); // Fetch first 25 plans foreach (Plan plan in plans.Fetch(0, 25)) { // Process plan } // Fetch plans 25-50 foreach (Plan plan in plans.Fetch(25, 50)) { // Process plan } ``` -------------------------------- ### Initialize BraintreeGateway with Environment and Keys Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a gateway instance using explicit environment and API credential parameters. ```csharp public BraintreeGateway(Environment environment, string merchantId, string publicKey, string privateKey) ``` ```csharp var gateway = new BraintreeGateway( Environment.SANDBOX, "your_merchant_id", "your_public_key", "your_private_key" ); ``` -------------------------------- ### Configure Gateway with Client Credentials Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Initializes the gateway using client ID and client secret. ```csharp var configuration = new Configuration("client_id", "client_secret"); var gateway = new BraintreeGateway(configuration); ``` -------------------------------- ### List Available Plans in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Retrieves all plans from the gateway and iterates through them to display basic plan information and trial details. ```csharp var plans = gateway.Plan.All(); Console.WriteLine("Available Plans:"); foreach (Plan plan in plans.Fetch(0, 50)) { Console.WriteLine($"- {plan.Name}: ${plan.Price}/month"); if (plan.TrialPeriod == true) { Console.WriteLine($" Trial: {plan.TrialDuration} {plan.TrialDurationUnit}(s)"); } } ``` -------------------------------- ### Initialize Configuration with Client Credentials Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Creates a configuration using OAuth 2.0 client ID and client secret. ```csharp public Configuration(string clientId, string clientSecret) ``` -------------------------------- ### Initialize Configuration with Access Token Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Creates a configuration using an OAuth 2.0 access token, which automatically parses the merchant ID and environment. ```csharp public Configuration(string accessToken) ``` -------------------------------- ### Create Subscription with Add-ons and Discounts in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Creates a subscription request that includes specific add-ons and discounts by their inherited IDs. ```csharp var request = new SubscriptionRequest { PaymentMethodToken = "token", PlanId = "plan_id" }; // Add add-ons var addOns = new List(); addOns.Add(new AddAddOnRequest { InheritedFromId = "addon_id_1" }); addOns.Add(new AddAddOnRequest { InheritedFromId = "addon_id_2" }); request.AddOns = addOns; // Add discounts var discounts = new List(); discounts.Add(new AddDiscountRequest { InheritedFromId = "discount_id" }); request.Discounts = discounts; Result result = gateway.Subscription.Create(request); ``` -------------------------------- ### Initialize Configuration with Default Constructor Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Creates an empty configuration instance requiring manual property assignment. ```csharp public Configuration() ``` -------------------------------- ### Initialize BraintreeGateway with API Keys Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Use this method for standard server-side integration using sandbox or production credentials. ```csharp new BraintreeGateway(Environment.SANDBOX, merchantId, publicKey, privateKey) ``` -------------------------------- ### Configure Gateway with Access Token Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Initializes the gateway using an access token for authentication. ```csharp var configuration = new Configuration("access_token_value"); var gateway = new BraintreeGateway(configuration); ``` -------------------------------- ### Initialize BraintreeGateway with Configuration Object Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a gateway instance from an existing Configuration object. ```csharp public BraintreeGateway(Configuration configuration) ``` -------------------------------- ### Manage Subscription in .NET Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Demonstrates how to retrieve subscription details, check status, retry failed charges, update subscription attributes, and cancel an existing subscription. ```csharp // Find subscription Subscription subscription = gateway.Subscription.Find("subscription_id"); // Check status if (subscription.Status == "Active") { Console.WriteLine("Subscription is active"); } else if (subscription.DaysPastDue > 0) { Console.WriteLine("Subscription is " + subscription.DaysPastDue + " days past due"); // Retry failed payment Result retryResult = gateway.Subscription.RetryCharge("subscription_id"); } // Update subscription var updateRequest = new SubscriptionRequest { Price = 39.99M // New price }; Result updateResult = gateway.Subscription.Update("subscription_id", updateRequest); // Cancel subscription Result cancelResult = gateway.Subscription.Cancel("subscription_id"); ``` -------------------------------- ### Build Docker Image with .NET Core 3.1 Source: https://github.com/braintree/braintree_dotnet/blob/master/DEVELOPMENT.md Use this command to build a Docker image with .NET Core 3.1 for development. ```bash make core3 ``` -------------------------------- ### Initialize BraintreeGateway with Environment Variables Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Retrieves Braintree credentials from system environment variables to avoid hardcoding sensitive information. Throws a ConfigurationException if required variables are missing. ```csharp var environment = System.Environment.GetEnvironmentVariable("BRAINTREE_ENV") ?? "sandbox"; var merchantId = System.Environment.GetEnvironmentVariable("BRAINTREE_MERCHANT_ID"); var publicKey = System.Environment.GetEnvironmentVariable("BRAINTREE_PUBLIC_KEY"); var privateKey = System.Environment.GetEnvironmentVariable("BRAINTREE_PRIVATE_KEY"); if (string.IsNullOrEmpty(merchantId) || string.IsNullOrEmpty(publicKey) || string.IsNullOrEmpty(privateKey)) { throw new ConfigurationException("Missing required Braintree credentials in environment variables"); } var gateway = new BraintreeGateway(environment, merchantId, publicKey, privateKey); ``` -------------------------------- ### Create Subscription in .NET Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Requires a customer ID and a vaulted payment method token. The process involves creating a customer, vaulting their credit card, and then initiating the subscription request. ```csharp // Step 1: Create customer var customerRequest = new CustomerRequest { FirstName = "Jane", LastName = "Smith", Email = "jane@example.com" }; Result customerResult = gateway.Customer.Create(customerRequest); string customerId = customerResult.Target.Id; // Step 2: Vault payment method var cardRequest = new CreditCardRequest { CustomerId = customerId, Number = "4111111111111111", ExpirationDate = "12/2025" }; Result cardResult = gateway.CreditCard.Create(cardRequest); string cardToken = cardResult.Target.Token; // Step 3: Create subscription var subscriptionRequest = new SubscriptionRequest { CustomerId = customerId, PaymentMethodToken = cardToken, PlanId = "plan_id", Price = 29.99M }; Result subResult = gateway.Subscription.Create(subscriptionRequest); if (subResult.IsSuccess()) { Subscription subscription = subResult.Target; Console.WriteLine("Subscription ID: " + subscription.Id); Console.WriteLine("Status: " + subscription.Status); Console.WriteLine("Next billing: " + subscription.NextBillingDate); } ``` -------------------------------- ### Initialize BraintreeGateway with Default Constructor Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a new gateway instance with an empty configuration that requires manual property assignment. ```csharp public BraintreeGateway() ``` ```csharp var gateway = new BraintreeGateway { Environment = Environment.SANDBOX, MerchantId = "merchant_id", PublicKey = "public_key", PrivateKey = "private_key" }; ``` -------------------------------- ### Create a customer in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CustomerGateway.md Initializes a CustomerRequest object and submits it to the gateway to create a new customer record. ```csharp var request = new CustomerRequest { FirstName = "John", LastName = "Doe", Email = "john@example.com", Phone = "555-1234", Company = "Acme Corp" }; Result result = gateway.Customer.Create(request); if (result.IsSuccess()) { Console.WriteLine("Customer ID: " + result.Target.Id); } ``` -------------------------------- ### Initialize BraintreeGateway with direct properties Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Configures the gateway instance using direct property assignment for environment and API credentials. ```csharp var gateway = new BraintreeGateway { Environment = Environment.SANDBOX, MerchantId = "merchant_id", PublicKey = "public_key", PrivateKey = "private_key" }; ``` -------------------------------- ### Configure Braintree Gateway Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Initialize the BraintreeGateway with your sandbox or production credentials. ```csharp using Braintree; var gateway = new BraintreeGateway { Environment = Environment.SANDBOX, MerchantId = "your_merchant_id", PublicKey = "your_public_key", PrivateKey = "your_private_key" }; ``` -------------------------------- ### Create Subscription from Plan in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Creates a new subscription using a plan ID, with an optional override for the plan price. ```csharp Plan plan = gateway.Plan.Find("annual_plan"); var request = new SubscriptionRequest { PaymentMethodToken = "credit_card_token", PlanId = plan.Id, Price = plan.Price // Can override plan price if needed }; Result result = gateway.Subscription.Create(request); if (result.IsSuccess()) { Subscription subscription = result.Target; Console.WriteLine("Subscription created: " + subscription.Id); Console.WriteLine("Next billing: " + subscription.NextBillingDate); } ``` -------------------------------- ### Configure Gateway Environment Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Sets the execution environment to either SANDBOX or PRODUCTION. ```csharp public virtual Environment Environment { get; set; } ``` -------------------------------- ### Initialize BraintreeGateway with String Environment Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a gateway instance using a string-based environment identifier. ```csharp public BraintreeGateway(string environment, string merchantId, string publicKey, string privateKey) ``` -------------------------------- ### Initialize BraintreeGateway with Client Credentials Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a gateway instance using OAuth 2.0 client ID and secret. ```csharp public BraintreeGateway(string clientId, string clientSecret) ``` -------------------------------- ### Transaction Search Usage Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Demonstrates how to configure search criteria using a delegate and iterate through the resulting paginated collection. ```csharp var transactions = gateway.Transaction.Search(search => { search.Id().Is("transaction_id"); search.Status().IncludedIn(TransactionStatus.SETTLED); search.CreatedAt().Between(startDate, endDate); }); foreach (Transaction txn in transactions.Fetch(0, 50)) { Console.WriteLine(txn.Id); } ``` -------------------------------- ### All() Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Retrieves all billing plans with pagination support. ```APIDOC ## All() ### Description Retrieves all billing plans with pagination support. ### Method public virtual ResourceCollection All() ### Returns ResourceCollection - Paginated collection of all plans ### Usage Example var plans = gateway.Plan.All(); foreach (Plan plan in plans.Fetch(0, 100)) { Console.WriteLine("Plan ID: " + plan.Id); Console.WriteLine("Price: $" + plan.Price); Console.WriteLine("Billing Frequency: " + plan.BillingFrequency + " months"); } ``` -------------------------------- ### Construct development environment URL Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Retrieves gateway host and port from environment variables with fallback defaults for local development. ```csharp var host = System.Environment.GetEnvironmentVariable("GATEWAY_HOST") ?? "localhost"; var port = System.Environment.GetEnvironmentVariable("GATEWAY_PORT") ?? "3000"; var url = $"http://{host}:{port}"; ``` -------------------------------- ### Create a Transaction Sale in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Executes an immediate charge using a payment method nonce. Ensure SubmitForSettlement is set to true if the transaction should be captured immediately. ```csharp var request = new TransactionRequest { Amount = 100.00M, PaymentMethodNonce = "nonce_from_client", Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; Result result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Console.WriteLine("Transaction ID: " + result.Target.Id); } ``` -------------------------------- ### Display Plan Details with Add-ons and Discounts in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Finds a specific plan by ID and iterates through its associated add-ons and discounts to display their details. ```csharp Plan plan = gateway.Plan.Find("standard_plan"); Console.WriteLine("Plan: " + plan.Name); Console.WriteLine("Price: $" + plan.Price); Console.WriteLine("Billing Frequency: Every " + plan.BillingFrequency + " months"); if (plan.AddOns != null && plan.AddOns.Length > 0) { Console.WriteLine("Available Add-ons:"); foreach (AddOn addOn in plan.AddOns) { Console.WriteLine($" + {addOn.Name}: ${addOn.Amount}"); } } if (plan.Discounts != null && plan.Discounts.Length > 0) { Console.WriteLine("Available Discounts:"); foreach (Discount discount in plan.Discounts) { Console.WriteLine($" - {discount.Name}: ${discount.Amount}"); if (discount.NumberOfBillingCycles.HasValue) { Console.WriteLine($" (Applies for {discount.NumberOfBillingCycles} cycles)"); } } } ``` -------------------------------- ### Initialize BraintreeGateway with Access Token Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Creates a gateway instance using an OAuth 2.0 access token. ```csharp public BraintreeGateway(string accessToken) ``` ```csharp var gateway = new BraintreeGateway("access_token_value"); ``` -------------------------------- ### Create Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/AddressGateway.md Creates a new address for a specified customer. ```APIDOC ## Create ### Description Creates a new address for a customer. ### Signature `public virtual Result
Create(string customerId, AddressRequest request)` ### Parameters - **customerId** (string) - Required - Customer identifier - **request** (AddressRequest) - Required - Address details ### Returns `Result
` - Result containing the created address or validation errors ### Throws - `NotFoundException` if customer not found ``` -------------------------------- ### Create Subscription in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/SubscriptionGateway.md Initializes a new subscription using a SubscriptionRequest object. Check the Result object for success before accessing the target subscription. ```csharp var request = new SubscriptionRequest { PaymentMethodToken = "credit_card_token", PlanId = "plan_id", Price = 29.99M }; Result result = gateway.Subscription.Create(request); if (result.IsSuccess()) { Console.WriteLine("Subscription ID: " + result.Target.Id); Console.WriteLine("Status: " + result.Target.Status); } ``` -------------------------------- ### Handle ConfigurationException Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/errors.md Catch errors related to invalid or incomplete gateway configuration settings. ```csharp try { var gateway = new BraintreeGateway( "invalid_env", "merchant_id", "public_key", "private_key" ); } catch (ConfigurationException ex) { Console.WriteLine("Configuration error: " + ex.Message); // Verify configuration properties } ``` -------------------------------- ### Generate Token with Verification Options Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ClientTokenGateway.md Configuring card verification and default payment method settings during token generation. ```csharp var request = new ClientTokenRequest { CustomerId = "customer_id", Options = new ClientTokenOptionsRequest { VerifyCard = true, MakeDefault = true } }; string clientToken = gateway.ClientToken.Generate(request); ``` -------------------------------- ### Manage Payment Methods Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/QUICK_REFERENCE.md Handle credit card creation and payment method lifecycle management. ```csharp // Create credit card Result result = gateway.CreditCard.Create(new CreditCardRequest { CustomerId = "customer_id", Number = "4111111111111111", ExpirationDate = "12/2025" }); // Find payment method PaymentMethod method = gateway.PaymentMethod.Find("token"); // Update payment method Result update = gateway.PaymentMethod.Update("token", new PaymentMethodRequest { Options = new PaymentMethodOptionsRequest { MakeDefault = true } }); // Delete payment method Result delete = gateway.PaymentMethod.Delete("token"); ``` -------------------------------- ### gateway.Plan.All() Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Retrieves a list of all available plans configured in the Braintree control panel. ```APIDOC ## gateway.Plan.All() ### Description Retrieves a collection of all plans available in the Braintree environment. ### Usage ```csharp var plans = gateway.Plan.All(); foreach (Plan plan in plans.Fetch(0, 50)) { Console.WriteLine($"- {plan.Name}: ${plan.Price}/month"); } ``` ``` -------------------------------- ### Build Docker Image with Mono Source: https://github.com/braintree/braintree_dotnet/blob/master/DEVELOPMENT.md Use this command to build a Docker image that includes Mono for development. ```bash make mono ``` -------------------------------- ### Client-Side Integration Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ClientTokenGateway.md Initializing the Braintree client using the generated token. ```html ``` -------------------------------- ### All Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CustomerGateway.md Retrieves all customers (with pagination support). ```APIDOC ## All ### Description Retrieves all customers (with pagination support). ### Returns - **ResourceCollection** - Paginated collection of all customers ``` -------------------------------- ### Execute a Transaction Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Create a sale transaction using a payment method nonce. ```csharp var request = new TransactionRequest { Amount = 100.00M, PaymentMethodNonce = "nonce_from_client" }; Result result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Console.WriteLine("Success! Transaction ID: " + result.Target.Id); } ``` -------------------------------- ### Configuration Check Methods Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Methods to check the current authentication configuration state. ```APIDOC ## IsClientCredentials ### Description Returns true if configured with OAuth 2.0 client credentials. ## IsAccessToken ### Description Returns true if configured with OAuth 2.0 access token. ``` -------------------------------- ### Implement Async Operations for Transactions and Customers Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Demonstrates handling asynchronous gateway calls with retry logic for timeouts and conditional creation of customer records. ```csharp public async Task ProcessTransactionAsync(TransactionRequest request) { try { Result result = await gateway.Transaction.SaleAsync(request); if (result.IsSuccess()) { Console.WriteLine("Transaction: " + result.Target.Id); } } catch (GatewayTimeoutException) { // Retry logic await Task.Delay(1000); await ProcessTransactionAsync(request); } } public async Task GetOrCreateCustomerAsync(string email) { try { // Attempt to find existing customer var customers = gateway.Customer.Search(s => s.Email().Is(email)); var existing = customers.Fetch(0, 1).FirstOrDefault(); if (existing != null) { return existing; } } catch (NotFoundException) { // Not found - create new } var request = new CustomerRequest { Email = email }; Result result = await gateway.Customer.CreateAsync(request); return result.Target; } ``` -------------------------------- ### Import Braintree Namespaces Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Include these namespaces to access the main SDK functionality and exception handling types. ```csharp using Braintree; // Main SDK using Braintree.Exceptions; // Exception types ``` -------------------------------- ### Retrieve all billing plans Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Fetches a paginated collection of all available billing plans. ```csharp public virtual ResourceCollection All() ``` ```csharp var plans = gateway.Plan.All(); foreach (Plan plan in plans.Fetch(0, 100)) { Console.WriteLine("Plan ID: " + plan.Id); Console.WriteLine("Price: $" + plan.Price); Console.WriteLine("Billing Frequency: " + plan.BillingFrequency + " months"); } ``` -------------------------------- ### Create Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/SubscriptionGateway.md Creates a new subscription using the provided request details. ```APIDOC ## Create ### Description Creates a new subscription. ### Method SubscriptionGateway.Create(SubscriptionRequest request) ### Parameters - **request** (SubscriptionRequest) - Required - Subscription details including plan ID and payment method ### Returns Result - Result containing the created subscription or validation errors ``` -------------------------------- ### Create Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CustomerGateway.md Creates a new customer record in the vault. ```APIDOC ## Create ### Description Creates a new customer record in the vault. ### Parameters #### Parameters - **request** (CustomerRequest) - Optional - Customer details ### Returns - **Result** - Result containing the created customer or validation errors ``` -------------------------------- ### Generate Token for New Customer Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ClientTokenGateway.md Standard token generation for a new customer session. ```csharp string clientToken = gateway.ClientToken.Generate(); // Pass token to client-side JavaScript/mobile app ``` -------------------------------- ### Handle AuthenticationException Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/errors.md Catch authentication errors resulting from invalid credentials or environment mismatches. ```csharp try { var transaction = gateway.Transaction.Find("txn_id"); } catch (AuthenticationException ex) { Console.WriteLine("Authentication failed: " + ex.Message); // Check credentials and environment configuration } ``` -------------------------------- ### Configuration Constructors Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Methods to initialize the Braintree Configuration object for SDK connectivity. ```APIDOC ## Configuration Constructors ### Description Initializes a new instance of the Configuration class to establish a connection to the Braintree gateway. ### Constructors #### Default Constructor `public Configuration()` Creates an empty configuration object. #### OAuth Access Token `public Configuration(string accessToken)` Creates configuration from an OAuth 2.0 access token. - **accessToken** (string) - Required - OAuth 2.0 access token. #### Client Credentials `public Configuration(string clientId, string clientSecret)` Creates configuration from OAuth 2.0 client credentials. - **clientId** (string) - Required - OAuth 2.0 client ID. - **clientSecret** (string) - Required - OAuth 2.0 client secret. #### Environment and Keys `public Configuration(Environment environment, string merchantId, string publicKey, string privateKey)` Creates configuration with explicit environment and API keys. - **environment** (Environment) - Required - Gateway environment instance. - **merchantId** (string) - Required - Merchant account ID. - **publicKey** (string) - Required - Public API key. - **privateKey** (string) - Required - Private API key. #### String Environment `public Configuration(string environment, string merchantId, string publicKey, string privateKey)` Creates configuration with environment specified as a string. - **environment** (string) - Required - Environment name: "sandbox", "production", "qa", or "development". - **merchantId** (string) - Required - Merchant account ID. - **publicKey** (string) - Required - Public API key. - **privateKey** (string) - Required - Private API key. ``` -------------------------------- ### Create Payment Method from Nonce Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PaymentMethodGateway.md Creates a new payment method for a customer using a nonce and optional configuration settings. ```csharp var request = new PaymentMethodRequest { CustomerId = "customer_id", PaymentMethodNonce = "nonce_from_client", Options = new PaymentMethodOptionsRequest { MakeDefault = true, VerifyCard = true } }; Result result = gateway.PaymentMethod.Create(request); if (result.IsSuccess()) { var method = result.Target; Console.WriteLine("Created: " + method.Token); } ``` -------------------------------- ### Manage Customers Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/QUICK_REFERENCE.md Create, retrieve, update, and delete customer records. ```csharp // Create customer Result result = gateway.Customer.Create(new CustomerRequest { FirstName = "John", LastName = "Doe", Email = "john@example.com" }); // Find customer Customer customer = gateway.Customer.Find("customer_id"); // Update customer Result update = gateway.Customer.Update("customer_id", new CustomerRequest { Email = "newemail@example.com" }); // Delete customer Result delete = gateway.Customer.Delete("customer_id"); ``` -------------------------------- ### Retrieve all customers in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CustomerGateway.md Fetches a paginated collection of all customers stored in the vault. ```csharp var customers = gateway.Customer.All(); foreach (Customer customer in customers.Fetch(0, 50)) { Console.WriteLine(customer.FirstName + " " + customer.LastName); } ``` -------------------------------- ### Generate Client Tokens Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/QUICK_REFERENCE.md Generate tokens for client-side SDK initialization, optionally scoped to a specific customer. ```csharp // Generate client token string clientToken = gateway.ClientToken.Generate(); // With customer string token = gateway.ClientToken.Generate(new ClientTokenRequest { CustomerId = "customer_id" }); ``` -------------------------------- ### Create Credit Card in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CreditCardGateway.md Initializes a CreditCardRequest object and submits it to the gateway to create a new payment method. ```csharp var request = new CreditCardRequest { Number = "4111111111111111", ExpirationDate = "12/2025", CVV = "123", CardholderName = "John Doe", CustomerId = "customer_id" }; Result result = gateway.CreditCard.Create(request); if (result.IsSuccess()) { Console.WriteLine("Token: " + result.Target.Token); Console.WriteLine("Masked Number: " + result.Target.MaskedNumber); } ``` -------------------------------- ### Parse Environment by Name Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Use ParseEnvironment to retrieve an Environment instance from a string. Throws a ConfigurationException if the provided name is invalid. ```csharp public static Environment ParseEnvironment(string environment) ``` -------------------------------- ### Search Credit Card Methods Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CreditCardGateway.md Synchronous and asynchronous method signatures for searching credit cards using a search delegate. ```csharp public virtual ResourceCollection Search(SearchDelegate searchDelegate) public virtual async Task> SearchAsync(SearchDelegate searchDelegate) ``` -------------------------------- ### gateway.Plan.All() Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Retrieves a collection of all plans associated with the merchant account. The returned collection supports pagination via the Fetch method. ```APIDOC ## gateway.Plan.All() ### Description Retrieves a collection of all plans defined in the control panel. The returned ResourceCollection allows for paginated access to the plans. ### Method Method call ### Parameters None ### Returns - **ResourceCollection** - A collection of plan objects that can be iterated or paginated using the Fetch(int, int) method. ### Example ```csharp var plans = gateway.Plan.All(); // Fetch first 25 plans foreach (Plan plan in plans.Fetch(0, 25)) { // Process plan } ``` ``` -------------------------------- ### Check configuration status properties Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md Boolean properties to determine if the gateway is configured via client credentials or an access token. ```csharp public bool IsClientCredentials { get; } ``` ```csharp public bool IsAccessToken { get; } ``` -------------------------------- ### Create Address Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/AddressGateway.md Creates a new address for a customer using an AddressRequest object. Throws a NotFoundException if the specified customer does not exist. ```csharp public virtual Result
Create(string customerId, AddressRequest request) public virtual async Task> CreateAsync(string customerId, AddressRequest request) ``` ```csharp var request = new AddressRequest { FirstName = "John", LastName = "Doe", StreetAddress = "123 Main St", ExtendedAddress = "Suite 100", Locality = "Chicago", Region = "IL", PostalCode = "60622", CountryCodeAlpha2 = "US" }; Result
result = gateway.Address.Create("customer_id", request); if (result.IsSuccess()) { Console.WriteLine("Address ID: " + result.Target.Id); } ``` -------------------------------- ### Configure OAuth 2.0 Credentials Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/BraintreeGateway.md Properties for OAuth 2.0 authentication. Setting the AccessToken automatically populates MerchantId and Environment. ```csharp public virtual string AccessToken { get; set; } ``` ```csharp public virtual string ClientId { get; set; } ``` ```csharp public virtual string ClientSecret { get; set; } ``` -------------------------------- ### Search Resources Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/QUICK_REFERENCE.md Use search criteria builders to query transactions, customers, or subscriptions. ```csharp // Search transactions var transactions = gateway.Transaction.Search(search => { search.Status().Is(TransactionStatus.SETTLED); search.CreatedAt().Between(start, end); }); // Search customers var customers = gateway.Customer.Search(search => { search.Email().Is("email@example.com"); }); // Search subscriptions var subscriptions = gateway.Subscription.Search(search => { search.Status().Is("Active"); search.DaysPastDue().Min(0); }); ``` -------------------------------- ### gateway.Plan.Find(string planId) Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PlanGateway.md Retrieves the details of a specific plan by its unique identifier, including its associated add-ons and discounts. ```APIDOC ## gateway.Plan.Find(string planId) ### Description Fetches a single plan object by its ID. This object contains metadata such as price, billing frequency, and lists of available add-ons and discounts. ### Parameters - **planId** (string) - Required - The unique identifier of the plan to retrieve. ### Usage ```csharp Plan plan = gateway.Plan.Find("standard_plan"); Console.WriteLine("Plan: " + plan.Name); ``` ``` -------------------------------- ### Vault Customer and Execute Transaction Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Creates a customer, adds a credit card, and processes a transaction using the vaulted payment method token. ```csharp // Step 1: Create customer var customerRequest = new CustomerRequest { FirstName = "John", LastName = "Doe", Email = "john@example.com" }; Result customerResult = gateway.Customer.Create(customerRequest); if (!customerResult.IsSuccess()) { foreach (ValidationError error in customerResult.Errors.DeepAll()) { Console.WriteLine(error.Message); } return; } string customerId = customerResult.Target.Id; // Step 2: Create payment method for customer var cardRequest = new CreditCardRequest { CustomerId = customerId, Number = "4111111111111111", ExpirationDate = "12/2025", CVV = "123" }; Result cardResult = gateway.CreditCard.Create(cardRequest); string cardToken = cardResult.Target.Token; // Step 3: Use vaulted card for transaction var transactionRequest = new TransactionRequest { Amount = 100.00M, PaymentMethodToken = cardToken, Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; Result txnResult = gateway.Transaction.Sale(transactionRequest); ``` -------------------------------- ### Create Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CreditCardGateway.md Creates a new credit card payment method in the vault. ```APIDOC ## Create ### Description Creates a new credit card payment method. ### Method public virtual Result Create(CreditCardRequest request) ### Parameters - **request** (CreditCardRequest) - Required - Credit card details ### Returns Result - Result containing the created credit card or validation errors ``` -------------------------------- ### Create Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PaymentMethodGateway.md Creates a new payment method in the vault. ```APIDOC ## Create ### Description Creates a new payment method (credit card, PayPal, etc.). ### Signature `public virtual Result Create(PaymentMethodRequest request)` `public virtual async Task> CreateAsync(PaymentMethodRequest request)` ### Parameters - **request** (PaymentMethodRequest) - Required - Payment method details ### Returns `Result` - Result containing the created payment method or validation errors ``` -------------------------------- ### Define Braintree Environments Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/configuration.md The Environment class provides static instances for Sandbox, Production, QA, and Development environments. ```csharp public static class Environment { public static Environment SANDBOX = new Environment( "sandbox", "https://api.sandbox.braintreegateway.com:443", "https://auth.sandbox.venmo.com", "https://payments.sandbox.braintree-api.com/graphql" ); public static Environment PRODUCTION = new Environment( "production", "https://api.braintreegateway.com:443", "https://auth.venmo.com", "https://payments.braintree-api.com/graphql" ); public static Environment QA = new Environment( "qa", "https://gateway.qa.braintreepayments.com", "https://auth.qa.venmo.com", "https://payments-qa.dev.braintree-api.com/graphql" ); public static Environment DEVELOPMENT = new Environment( "development", "http://localhost:3000", // Uses GATEWAY_HOST and GATEWAY_PORT env vars "http://auth.venmo.dev:9292", "http://graphql.bt.local:8080/graphql" ); } ``` -------------------------------- ### Restore Dependencies for .NET Core 3.1 Tests Source: https://github.com/braintree/braintree_dotnet/blob/master/DEVELOPMENT.md Restore project dependencies before running tests on a Unix-like system with .NET Core 3.1. ```bash dotnet restore dotnet test . -f netcoreapp3.1 ``` -------------------------------- ### gateway.PaymentMethod.Create(PaymentMethodRequest request) Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PaymentMethodGateway.md Creates a new payment method for a customer using a nonce. ```APIDOC ## gateway.PaymentMethod.Create(PaymentMethodRequest request) ### Description Creates a new payment method in the vault using a payment method nonce. Requires a PaymentMethodRequest object. ### Parameters - **request** (PaymentMethodRequest) - Required - The request object containing CustomerId, PaymentMethodNonce, and optional configuration. ### Response - **Result** (object) - A result object containing the created payment method or error details. ``` -------------------------------- ### Iterating Validation Errors in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/errors.md Demonstrates how to check for operation failure and iterate through all validation errors using DeepAll(). ```csharp var request = new CustomerRequest { Email = "invalid_email" }; Result result = gateway.Customer.Create(request); if (!result.IsSuccess()) { foreach (ValidationError error in result.Errors.DeepAll()) { Console.WriteLine("Field: " + error.Attribute); Console.WriteLine("Code: " + error.Code); Console.WriteLine("Message: " + error.Message); } } ``` -------------------------------- ### Search for customers in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/CustomerGateway.md Uses a search delegate to filter customers based on specific criteria like name or creation date. ```csharp var customers = gateway.Customer.Search(search => { search.FirstName().StartsWith("John"); search.CreatedAt().Between(startDate, endDate); }); foreach (Customer customer in customers.Fetch(0, 100)) { Console.WriteLine(customer.Id); } ``` -------------------------------- ### Create a Credit Transaction in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Issues a refund to a customer's original payment method. ```csharp var request = new TransactionRequest { Amount = 50.00M, PaymentMethodNonce = "nonce_from_client" }; Result result = gateway.Transaction.Credit(request); ``` -------------------------------- ### Search and Paginate Resources Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/README.md Search for resources and iterate through paginated results using ResourceCollection. ```csharp var transactions = gateway.Transaction.Search(search => { search.Status().Is(TransactionStatus.SETTLED); }); foreach (Transaction txn in transactions.Fetch(0, 50)) { // Process transaction } ``` -------------------------------- ### Search and Paginate Transactions Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Shows how to filter transactions using search criteria and iterate through paginated results. ```csharp // Search transactions var transactions = gateway.Transaction.Search(search => { search.Status().Is(TransactionStatus.SETTLED); search.CreatedAt().Between( DateTime.Now.AddMonths(-1), DateTime.Now ); search.Amount().Between(100M, 500M); }); // Paginate results int pageSize = 100; int totalProcessed = 0; foreach (Transaction txn in transactions.Fetch(0, pageSize)) { Console.WriteLine(txn.Id + ": $" + txn.Amount); totalProcessed++; } Console.WriteLine("Processed " + totalProcessed + " transactions"); ``` -------------------------------- ### Iterate Over ResourceCollection Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/types.md Use the Fetch method to retrieve specific pages of items from a resource collection. ```csharp var customers = gateway.Customer.All(); foreach (Customer customer in customers.Fetch(0, 100)) { Console.WriteLine(customer.Id); } ``` -------------------------------- ### Lookup Method Signatures Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/ThreeDSecureGateway.md Synchronous and asynchronous method signatures for performing a 3D Secure lookup. ```csharp public virtual Result Lookup(ThreeDSecureLookupRequest request) public virtual async Task> LookupAsync(ThreeDSecureLookupRequest request) ``` -------------------------------- ### Find Payment Method Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/PaymentMethodGateway.md Retrieves a payment method by its token. Throws a NotFoundException if the token does not exist. ```csharp public virtual PaymentMethod Find(string token) public virtual async Task FindAsync(string token) ``` ```csharp PaymentMethod method = gateway.PaymentMethod.Find("payment_method_token"); Console.WriteLine("Type: " + method.GetType().Name); ``` -------------------------------- ### Authorize and Settle Transactions in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Workflow for capturing funds after an initial authorization. Useful for scenarios where settlement must wait for order fulfillment. ```csharp // Step 1: Authorize transaction (does not charge yet) var authRequest = new TransactionRequest { Amount = 100.00M, PaymentMethodNonce = "nonce", Options = new TransactionOptionsRequest { SubmitForSettlement = false // Just authorize, don't settle yet } }; Result authResult = gateway.Transaction.Sale(authRequest); if (!authResult.IsSuccess()) { // Handle authorization failure return; } string transactionId = authResult.Target.Id; Console.WriteLine("Authorized: " + transactionId); // Step 2: Perform some operation (prepare shipment, etc.) // ... // Step 3: Submit for settlement (after shipment) Result settleResult = gateway.Transaction.SubmitForSettlement(transactionId); if (settleResult.IsSuccess()) { Console.WriteLine("Settled: " + settleResult.Target.Status); } ``` -------------------------------- ### Execute Sale with Payment Nonce in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/workflow-patterns.md Standard flow for processing a transaction using a client-side generated nonce. Requires a client token generated on the server and optional device data for fraud protection. ```csharp // Server: Create client token string clientToken = gateway.ClientToken.Generate(); // Send clientToken to client // Client: Generate payment nonce via JavaScript SDK // var nonce = result.nonce; // from Drop-in UI or Hosted Fields // Server: Create transaction with nonce var request = new TransactionRequest { Amount = 100.00M, PaymentMethodNonce = "nonce_from_client", Options = new TransactionOptionsRequest { SubmitForSettlement = true // Automatically submit for settlement }, DeviceData = "device_data_from_client", // Optional fraud tools data OrderId = "order_123" }; Result result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Transaction transaction = result.Target; Console.WriteLine("Transaction ID: " + transaction.Id); Console.WriteLine("Status: " + transaction.Status); // Transaction is settled if SubmitForSettlement was true } else if (result.Transaction != null) { // Processor declined or gateway rejected Console.WriteLine("Status: " + result.Transaction.Status); Console.WriteLine("Code: " + result.Transaction.ProcessorResponseCode); Console.WriteLine("Text: " + result.Transaction.ProcessorResponseText); } else { // Validation errors foreach (ValidationError error in result.Errors.DeepAll()) { Console.WriteLine(error.Attribute + ": " + error.Message); } } ``` -------------------------------- ### Verify(string challenge) Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/WebhookNotificationGateway.md Verifies a webhook challenge string and returns the verification response. ```APIDOC ## Verify(string challenge) ### Description Verifies a webhook challenge string and returns the verification response. ### Parameters - **challenge** (string) - Required - Challenge string from Braintree (hex-encoded, 20-32 chars) ### Returns - **string** - Challenge response in format "public_key|digest" ### Throws - **InvalidChallengeException** - if challenge format is invalid ``` -------------------------------- ### SubmitForSettlement Method Signatures Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/TransactionGateway.md Defines the synchronous and asynchronous methods for submitting authorized transactions for settlement. ```csharp public virtual Result SubmitForSettlement(string id) public virtual Result SubmitForSettlement(string id, decimal amount) public virtual Result SubmitForSettlement(string id, TransactionRequest request) public virtual async Task> SubmitForSettlementAsync(string id) public virtual async Task> SubmitForSettlementAsync(string id, decimal amount) public virtual async Task> SubmitForSettlementAsync(string id, TransactionRequest request) ``` -------------------------------- ### ReleaseFromEscrow Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/SubscriptionGateway.md Releases a subscription payment from escrow. ```APIDOC ## ReleaseFromEscrow(string id) ### Description Releases a subscription payment from escrow. ### Parameters - **id** (string) - Required - Subscription identifier ### Returns - **Result** - Result containing the subscription ``` -------------------------------- ### Manage Subscriptions Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/QUICK_REFERENCE.md Create, find, update, and cancel recurring billing subscriptions. ```csharp // Create subscription Result result = gateway.Subscription.Create(new SubscriptionRequest { PlanId = "plan_id", PaymentMethodToken = "token" }); // Find subscription Subscription sub = gateway.Subscription.Find("subscription_id"); // Update subscription Result update = gateway.Subscription.Update("subscription_id", new SubscriptionRequest { Price = 39.99M }); // Cancel subscription Result cancel = gateway.Subscription.Cancel("subscription_id"); ``` -------------------------------- ### Search Subscriptions in C# Source: https://github.com/braintree/braintree_dotnet/blob/master/_autodocs/api-reference/SubscriptionGateway.md Queries subscriptions based on specific criteria using a search delegate. Returns a paginated collection of results. ```csharp var subscriptions = gateway.Subscription.Search(search => { search.PlanId().Is("plan_id"); search.Status().IncludedIn( Subscription.Status.ACTIVE, Subscription.Status.PENDING ); search.DaysPastDue().Min(0); }); foreach (Subscription sub in subscriptions.Fetch(0, 50)) { Console.WriteLine("ID: " + sub.Id + ", Status: " + sub.Status); } ```