Add the Drop-in UI with a few lines of code to get a full-featured checkout with credit card and PayPal payments.
Accept more payment types with your existing checkout form by adding buttons for PayPal, Apple Pay, Google Pay, and Venmo.
Rolling your own checkout UI? Use credit card tokenization to save customer card information.
These instructions are for version 3.x of our iOS SDK. We recommend using the latest version of our SDK; use the selector near the top of this page.
For additional requirements and installation options, see the iOS Client SDK Guide.
Your server is responsible for generating a client token, which contains the authorization and configuration details that your client needs to initialize the client SDK.
Your app should request a client token from your server. This example uses our sample integration server; please adapt it to use your own backend API.
// As an example, you may wish to present our Drop-in UI at this point.
You should obtain a new client token often, at least as often as your app restarts. For the best experience, you should kick off this network operation before it would block a user interaction.
You must generate a client token on your server once per user checkout session. The endpoint we provide in this example is for demonstration purposes only.
We generated a demo client token for you so you can jump right in. This is for testing purposes only!
The above demo client token is for temporary use. You must change this client token in order to process payments with your Braintree sandbox or production account.
At this point, you are ready to collect payment information from your customer.
Drop-in is the easiest way to get started. It provides a fully fledged payments experience out of the box. You can also choose to create a custom UI and then tokenize the payment information directly.
Declare a class that conforms to the BTDropInViewControllerDelegate protocol to receive the user's payment method.
In your implementation, use the client token obtained from your server to initialize the Braintree SDK. Then, create a BTDropInViewController.
// If you haven't already, create and retain a `Braintree` instance with the client token.
// Typically, you only need to do this once per session.
// The way you present your BTDropInViewController instance is up to you.