Fastlane

Server-side

Step 1: Generate client tokenAnchorIcon

To get started, generate a client token. If you use Braintree's GraphQL API on your server, refer to the GraphQL Documentation.
Using Braintree SDK

Important

You must include your root domain in the client token request. Omitting the root domain will cause Fastlane to malfunction and will prevent it from working entirely.

  1. Java
package com.fastlane.braintreesdksample.sample;
import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.ClientTokenRequest;
import com.braintreegateway.Environment;
public class GenerateClientTokenExample {
    private final BraintreeGateway gateway;
    public GenerateClientTokenExample() {
        // Initialize the Braintree gateway with your credentials
        this.gateway = new BraintreeGateway(
            Environment.SANDBOX,
            "<BRAINTREE_MERCHANT_ID>",
            "<BRAINTREE_PUBLIC_KEY>",
            "<BRAINTREE_PRIVATE_KEY>"
        );
    }
    public static void main(String[] args) {
        ClientTokenRequest clientTokenRequest = new ClientTokenRequest().domains(domains);
        String clientToken = gateway.clientToken().generate(clientTokenRequest);
        System.out.println("Generated Client Token: " + clientToken);
    }
}
Using Braintree GraphQL
  1. Graphql
mutation ($input: CreateClientTokenInput) {
    createClientToken(input: $input) {
        clientToken
    }
}
  1. Graphql
{
    "input": {
        "clientToken": {
            "domains": [
                "example.com"
            ]
        }
    }
}
  • Restrictions on Domain Names:
    • No Subdomains: Do not specify subdomains (for example, "sub.example.com").
    • No Wildcards: Do not use wildcard characters (for example, "*.example.com").
    • No Protocols: Do not include HTTP or HTTPS protocols in the domain name (for example, "https://example.com/")
  • Error Handling: If you specify subdomains, wildcards, or protocols, the system will generate an error.

Step 2: Update Fastlane with Consumer's shipping addressAnchorIcon

After generating a Fastlane token, if you're processing a payment, make sure to include the customer's shipping address in the request.This ensures the address is saved to their Fastlane profile for future use.

Field nameDescriptionLink
shipping The shipping address collected for a customer's order. Link


  1. Java
package com.fastlane.braintreesdksample.sample;

import com.braintreegateway.BraintreeGateway;
import com.braintreegateway.Environment;
import com.braintreegateway.Result;
import com.braintreegateway.Transaction;
import com.braintreegateway.TransactionAddressRequest.ShippingMethod;
import com.braintreegateway.TransactionRequest;

public class MakeTransactionExample {

    private final BraintreeGateway gateway;

    public GenerateClientTokenExample() {
        // Initialize the Braintree gateway with your credentials
        this.gateway = new BraintreeGateway(
            Environment.SANDBOX,
            "<BRAINTREE_MERCHANT_ID>",
            "<BRAINTREE_PUBLIC_KEY>",
            "<BRAINTREE_PRIVATE_KEY>"
        );
    }

    public static void main(String[] args) {
        TransactionRequest request = new TransactionRequest()
                .amount(new BigDecimal(10))
                .paymentMethodNonce("...")
                .deviceData("...")
                .customer()
                .email("...")
                .firstName("...")
                .lastName("...")
                .done()
                .billingAddress()
                .streetAddress("...")
                .extendedAddress("...")
                .locality("...")
                .region("...")
                .postalCode("...")
                .countryCodeAlpha2("...")
                .done()
                .shippingAddress()
                .streetAddress("...")
                .extendedAddress("...")
                .locality("...")
                .region("...")
                .postalCode("...")
                .countryCodeAlpha2("...")
                .shippingMethod(ShippingMethod.GROUND)
                .done()
                .options()
                .submitForSettlement(true)
                .done();

        Result<Transaction> result = gateway.transaction().sale(request);
        
        if (!result.isSuccess()) {
            System.out.println("Transaction failed: " + result.getMessage());
        } else {
            Transaction transaction = result.getTarget();
            System.out.println("Transaction successful! ID: " + transaction.getId());
        }
    }
}
Using Braintree GraphQL
  1. Graphql
mutation ($input: ChargeCreditCardInput!) {
    chargeCreditCard(input: $input) {
        transaction {
            id
            status
        }
    }
}
  1. Graphql
mutation ($input: ChargeCreditCardInput!) {
    chargeCreditCard(input: $input) {
        transaction {
            id
            status
        }
    }
}
Next step: Test your integration