Venmo
Client-Side Implementation
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.
For full details, see Drop-in Setup and Integration.
Custom integration
Alternatively, you can add Venmo to your current custom integration. Keep in mind, for compliance purposes, we require you to present the customer with an order summary before and after purchase.
The pre-purchase summary should include:
- The items ordered
- The total order price
- An indication of Venmo as the payment method
The post-purchase summary can either be shown in the UI or sent via email. It should include:
- The items purchased
- The total purchase price
- The customer's name
- The customer's Venmo username
Failing to comply with these guidelines can lead to an interruption of your Venmo service.
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.
- Android
@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:
- Android
@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.
- Android
@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:
- Android
@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
.
- Android
@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.
- Android
Venmo.authorizeAccount(fragment, false, YOUR_VENMO_PROFILE_ID);
Collect device data
You must collect information about the customer's device before creating each transaction.
- Android
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.
Next Page: Server-side →