PayPal
Vaulted Payments
Vaulted payments with PayPal account will allow you to charge the account in the future without requiring your customer to be present during the transaction or re-authenticate with PayPal when they are present during the transaction.
Vaulting creates a PayPal pre-approved payment between you and the customer, displayed in the customer's account profile on PayPal.com.
The Vault is used to process payments with our recurring billing feature, and is also used for non-recurring transactions so that your customers don't need to re-enter their information each time they make a purchase from you.
Vaulted payments with PayPal account allows you to charge the account in the future without requiring your customer’s presence during the transaction.
The vaulted payment flow lets the user:
- Select or add shipping addresses in the PayPal account
- Select or add funding instruments in the PayPal account
- Two-factor authentication support (currently only for US, UK, CA, DE, AT, and AU)
Typical use cases for the vaulted payment flow:
- Faster payments for repeat customers
- Subscriptions
- Recurring billing (e.g. automatic top-up or usage based charges)
Invoking the Vault flow
First, make sure you have defined your URL scheme. Next, create a BraintreeClient with a ClientTokenProvider
or Tokenization Key. Construct a PayPalClient and implement a PayPalListener to receive results. Call PayPalClient#tokenizePayPalAccount to launch the PayPal flow. An example integration might look like this:
- Java
- Kotlin
public class MyActivity extends AppCompatActivity implements PayPalListener {
private BraintreeClient braintreeClient;
private PayPalClient payPalClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
braintreeClient = new BraintreeClient(this, new ExampleClientTokenProvider());
payPalClient = new PayPalClient(this, braintreeClient);
dataCollector = new DataCollector(braintreeClient);
payPalClient.setListener(this);
}
private void myTokenizePayPalAccountWithVaultMethod() {
PayPalVaultRequest request = new PayPalVaultRequest();
request.setBillingAgreementDescription("Your agreement description");
payPalClient.tokenizePayPalAccount(this, request)
}
@Override
public void onPayPalSuccess(@NonNull PayPalAccountNonce payPalAccountNonce) {
// send payPalAccountNonce.getString() to server
}
@Override
public void onPayPalFailure(@NonNull Exception error) {
if (error instanceof UserCanceledException) {
// user canceled
} else {
// handle error
}
}
}
- Java
- Kotlin
public class MyActivity extends AppCompatActivity {
@Override
protected void onNewIntent(Intent newIntent) {
super.onNewIntent(newIntent);
setIntent(newIntent);
}
}
When you receive a result via onPayPalSuccess
, you can query the PayPalAccountNonce
result for specific customer information.
If you are using using an Activity and your Activity's launch mode is singleTop, singleTask, or singleInstance you will also need to override onNewIntent:
public class MyActivity extends AppCompatActivity {
@Override
protected void onNewIntent(Intent newIntent) {
super.onNewIntent(newIntent);
setIntent(newIntent);
}
}
- Kotlin
class MyActivity : AppCompatActivity() {
override fun onNewIntent(newIntent: Intent?) {
super.onNewIntent(newIntent)
intent = newIntent
}
}
Collecting device data
Collecting device data from your customers is required when initiating non-recurring transactions from Vault records. Collecting and passing this data with transactions will help reduce decline rates.
DataCollector enables you to collect data about a customer's device and correlate it with a session identifier on your server.
Shipping address
Shipping addresses may or may not be collected during the PayPal Vault flow. However, if you choose to collect shipping addresses yourself, it can be passed along with the server side Transaction.Sale call. Look at the Server-side page for more information.
Country and language support
PayPal is available to merchants in all countries that we support and to customers in 140+ countries.
Currency presentment
In the Vault flow itself, the transaction currency and amount are not displayed to the customer. It is up to you to display these details in your checkout flow somewhere (e.g. cart page, order review page, etc.). Our Server-Side guide outlines which currencies are supported for PayPal transactions.
Next Page: Recurring Payments →