availability

Venmo payments are currently in a limited release and are only available to select merchants.

Set up your iOS client

If you are using CocoaPods to integrate the Braintree iOS v4 SDK, add the Venmo subspec to your Podfile:

Ruby
Click to copy
Copied
# Podfile
pod 'Braintree'
pod 'Braintree/Venmo'

Whitelist Venmo URL scheme

You must add the following to the queries schemes whitelist in your app's info.plist:

XML
Click to copy
Copied
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>com.venmo.touch.v2</string>
</array>

Setup for app switch

To handle payments that involve switching to another app or SFSafariViewController for authentication, you must register a URL type and configure your app to return from app switches.

Register a URL type

  1. In Xcode, click on your project in the Project Navigator and navigate to App Target > Info > URL Types
  2. Click [+] to add a new URL type
  3. Under URL Schemes, enter your app switch return URL scheme. This scheme must start with your app's Bundle ID and be dedicated to Braintree app switch returns. For example, if the app bundle ID is com.your-company.Your-App, then your URL scheme could be com.your-company.Your-App.payments.
important

If you have multiple app targets, be sure to add the return URL type for all of the targets.

Testing the URL type

You can test out your new URL scheme by opening up a URL that starts with it (e.g. com.your-company.Your-App.payments://test) in Mobile Safari on your iOS Device or Simulator.

In addition, always test your app switching on a real device.

Update your application delegate

In your AppDelegate's application:didFinishLaunchingWithOptions: implementation, use setReturnURLScheme: with the value you set above.

For example:

Objective-C Swift
Click to copy
Copied
#import "AppDelegate.h"
#import "BraintreeCore.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [BTAppSwitch setReturnURLScheme:@"com.your-company.Your-App.payments"];
    return YES;
}

Then in your application delegate, pass the payment authorization URL to Braintree for finalization:

Objective-C Swift
Click to copy
Copied
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    if ([url.scheme localizedCaseInsensitiveCompare:@"com.your-company.Your-App.payments"] == NSOrderedSame) {
        return [BTAppSwitch handleOpenURL:url options:options];
    }
    return NO;
}

// If you support iOS 7 or 8, add the following method.
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    if ([url.scheme localizedCaseInsensitiveCompare:@"com.your-company.Your-App.payments"] == NSOrderedSame) {
        return [BTAppSwitch handleOpenURL:url sourceApplication:sourceApplication];
    }
    return NO;
}

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.

Enable Venmo for Drop-in

If you are using CocoaPods to integrate Drop-in, add the Venmo subspec to your Podfile:

Ruby
Click to copy
Copied
# Podfile
pod 'BraintreeDropIn'
pod 'Braintree/Venmo'

For more details on Drop-in, see Client-Side Implementation for Drop-in.

Handling the response

To handle the successful Venmo payment, cast the BTPaymentMethodNonce to a BTVenmoAccountNonce to access the username property that you receive from the BTDropInResult.

Custom integration

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

note

Be sure to follow Venmo's brand guidelines when configuring the Venmo button and any other references to Venmo in your app.

Objective-C Swift
Click to copy
Copied
#import "BraintreeVenmo.h"

@interface ViewController ()
@property (nonatomic, strong) BTVenmoDriver *venmoDriver;
@property (nonatomic, strong) UIButton *venmoButton;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.venmoDriver = [[BTVenmoDriver alloc] initWithAPIClient:self.apiClient];
    // setup venmoButton ....
    self.venmoButton.hidden = [self.venmoDriver isiOSAppAvailableForAppSwitch];
}

- (void)tappedButton {
    [self.venmoDriver authorizeAccountWithCompletion:^(BTVenmoAccountNonce * _Nullable venmoAccount, NSError * _Nullable error) {
        if (venmoAccount) {
            // You got a Venmo nonce!
            NSLog(@"%@", venmoAccount.nonce);
        }
    }];
}
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.

Collect device data

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

Objective-C Swift
Click to copy
Copied
#import "PPDataCollector.h"
NSString *deviceData = [PPDataCollector collectPayPalDeviceData];

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: Server-side →

Still have questions?

If you can’t find an answer, contact our Support team.