Client Token
Client Token: Generate
Returns a string which contains all authorization and configuration information your client needs to initialize the client SDK to communicate with Braintree.
- Python
client_token = gateway.client_token.generate()
Parameters
Only applies to the Drop-in UI; not needed when generating client tokens for custom integrations.
A string value representing an existing customer in your Vault. Passing this option allows customers to manage their vaulted payment methods via the Drop-in UI; see Drop-in Customization for details.
Specify the merchant account ID that you want to use to generate the client token. If no merchant account ID is specified, or if the merchant account ID does not match any of your merchant accounts, we will use your default merchant account.
Depending on its settings, the merchant account you use will determine:
- whether the PayPal button should be displayed
- whether the 3D Secure authentication flow can be invoked
If this option is passed and the same payment method has already been added to the Vault for any customer, the request will fail. This can only be passed if a customer_id is passed as well. If the check fails, this option will stop the Drop-in from returning a payment_method_nonce. This option will be ignored for PayPal, Pay with Venmo, Apple Pay, Google Pay, Samsung Pay and ACH payment methods.
If this option is passed and the same payment method has already been added to the Vault for the customer, the request will fail. This can only be passed if a customer_id is passed as well. If the check fails, this option will stop the Drop-in from returning a payment_method_nonce. This option will be ignored for PayPal, Pay with Venmo, Apple Pay, Google Pay, Samsung Pay and ACH payment methods.
'make_default'
bool'verify_card'
boolIf the payment method is a credit card, this option prompts the gateway to verify the card's number and expiration date. It also verifies the AVS and CVV information if you've enabled AVS and CVV rules. This option can only be passed if a customer_id is passed as well. If the verification fails, this option will stop the Drop-in from returning a payment_method_nonce.
In some cases, cardholders may see a temporary authorization on their account after their card has been verified. The authorization will fall off the cardholder's account within a few days and will never settle.
'version'
str2
. Current supported versions are 1
, 2
, and 3
. Please check your client-side SDKs in use before changing this value.Examples
Specify a customer ID
The Drop-in UI supports presenting returning customers with their saved payment methods. To generate a token for a customer in your vault provide the customer's ID.
- Python
# pass client_token to your front-end
client_token = gateway.client_token.generate({
"customer_id": a_customer_id
})
If the customer can't be found, it will raise a ValueError
.