Choose an integration method

You can set up your client-side either with our Drop-in UI or with a custom integration.

Drop-in integration

Our Drop-in UI is the fastest way to set up your client-side integration.

To launch Drop-in, create a valid DropInRequest and startActivityForResult using a REQUEST_CODE of your choosing.

Java
public void onCheckout(View v) {
  DropInRequest dropInRequest = new DropInRequest()
    .clientToken(clientToken)
    .collectDeviceData(true);

  // REQUEST_CODE is arbitrary and is only used within this activity.
  startActivityForResult(dropInRequest.getIntent(this), REQUEST_CODE);
}

For full details, see Drop-in Setup and Integration.

Handling the response

To handle the successful Venmo payment, implement onActivityResult in the Activity where you started Drop-in above.

Verify that the PaymentMethodNonce returned is a VenmoAccountNonce. Then, you can access Venmo properties, such as the Venmo username.

Java
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_CODE) {
    if (resultCode == RESULT_OK) {
      // use the result to update your UI and send the payment method nonce to your server
      DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT);
      String deviceData = result.getDeviceData();

      if (result.getPaymentMethodType() == PaymentMethodType.PAY_WITH_VENMO) {
        VenmoAccountNonce venmoAccountNonce = (VenmoAccountNonce) result.getPaymentMethodNonce();
        String venmoUsername = venmoAccountNonce.getUsername();
      }
    } else if (resultCode == RESULT_CANCELED) {
      // the user canceled
    } else {
      // Handle errors here, an exception may be available in
      Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR);
    }
  }
}

Custom integration

Alternatively, you can add Venmo to your current custom integration.

note

Click here to download Venmo's brand guidelines, and be sure to follow them when configuring the Venmo button or making any other references to Venmo in your app.

Begin by checking that Venmo is currently available for your app and your user. Implement a ConfigurationListener to get a configuration instance that can be used to check on Venmo availability.

Java
@Override
public void onConfigurationFetched(Configuration configuration) {
  boolean venmoReady = configuration.getPayWithVenmo().isEnabled(context);
  showVenmoButton(venmoReady);
}

If your app is venmoReady, start the Venmo payment flow with the following:

Java
@Override
public void onClick(View v) {
  // To vault the Venmo account, change this to true and use a Braintree client token with a customer ID
  Venmo.authorizeAccount(mBraintreeFragment, false);
}

Handling a successful response

Use a PaymentMethodNonceCreatedListener attached to BraintreeFragment to get a paymentMethodNonce if the Venmo flow is successful.

Verify that the PaymentMethodNonce returned is a VenmoAccountNonce. Then, you can access Venmo properties, such as the Venmo username.

note

It's best practice to display the customer's Venmo username alongside their Venmo payment method in your checkout UI – like you would the last 4 digits of a credit card number.

Java
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
  String nonce = paymentMethodNonce.getNonce();

  if (paymentMethodNonce instanceof VenmoAccountNonce) {
    VenmoAccountNonce venmoAccountNonce = (VenmoAccountNonce) paymentMethodNonce;
    String venmoUsername = venmoAccountNonce.getUsername();
  }
}

Handling cancel and error responses

Attaching a BraintreeErrorListener to BraintreeFragment allows your app to view any error responses coming back from BraintreeFragment.

This is the most common error in the Venmo flow:

Java
@Override
public void onError(Exception error) {
  if (error instanceof AppSwitchNotAvailableException) {
    // Braintree is unable to switch to the Venmo app.
    // Append this to your log for troubleshooting.
    String developerReadableMessage = error.getMessage();
  }
}

Similarly, attaching a BraintreeCancelListener to BraintreeFragment allows your app to view any canceled activity responses from BraintreeFragment.

Java
@Override
public void onCancel(int requestCode) {
  if (requestCode == Venmo.VENMO_REQUEST_CODE) {
    // Venmo request was canceled by the user, or the user pressed back.
  }
}

Multiple profiles

If you have a custom integration and have onboarded multiple apps for Venmo processing with a single Braintree gateway, you'll need to pass the profile_id to specify which Venmo profile to present during the payment flow.

You'll also need to pass the profile_id when creating the transaction on the server side.

Java
Venmo.authorizeAccount(fragment, false, YOUR_VENMO_PROFILE_ID);
note

If you have multiple business profiles, the profile_id for each profile can be found by logging into the Control Panel, clicking the gear icon in the top right corner, selecting Processing from the drop-down menu, scrolling to Venmo, and clicking the Options link.

Collect device data

You must collect information about the customer's device before creating each transaction.

Java
DataCollector.collectDeviceData(braintreeFragment, new BraintreeResponseListener<String> {
  @Override
  public void onResponse(String deviceData) {
    // send deviceData to your server
  }
});

You'll need to pass this deviceData when creating the Venmo transaction from your server.

important

Be sure to pass device data as close to the transaction creation as possible. Doing so will help reduce decline rates.

Next Page: Server-side →