Venmo
Client-Side Implementation
Set up your iOS client
Get the SDK
CocoaPods
Include Braintree/Venmo
in your Podfile:
- Ruby
# Podfile
pod 'Braintree/Venmo'
Swift Package Manager
Include the BraintreeVenmo
framework.
Carthage
Include the BraintreeCore
and BraintreeVenmo
frameworks.
Allowlist Venmo URL scheme
You must add the following to the queries schemes allowlist in your app's info.plist
:
- XML
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.venmo.touch.v2</string>
</array>
Include the app display name
You must have a display name in your app's info.plist
to help Venmo identify your application:
- XML
<key>CFBundleDisplayName</key>
<string>Your App Name</string>
Setup for app context switching
To handle workflows that involve switching to another app or SFSafariViewController
for authentication, you must register a URL type and configure your app to handle return URLs.
Register a URL type
- In Xcode, click on your project in the Project Navigator and navigate to App Target > Info > URL Types
- Click [+] to add a new URL type
- 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 becom.your-company.your-app.payments
.
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.
Set your return URL
In your AppDelegate's application:didFinishLaunchingWithOptions:
implementation, use setReturnURLScheme:
with the value you set above.
For example:
- Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BTAppContextSwitcher.setReturnURLScheme("com.your-company.your-app.payments")
return true
}
Handle app context switching
Then pass the payment authorization URL to Braintree for finalization.
If you're using UISceneDelegate
(introduced in iOS 13), call BTAppContextSwitcher
's handleOpenURLContext
's method from within the scene:openURLContexts
scene delegate method.
- Swift
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
URLContexts.forEach { context in
if context.url.scheme?.localizedCaseInsensitiveCompare("com.your-company.your-app.payments") == .orderedSame {
BTAppContextSwitcher.handleOpenURLContext(context)
}
}
}
Otherwise, if you aren't using UISceneDelegate
, call BTAppContextSwitcher
's handleOpenURL
's method from within the application:openURL:options
app delegate method.
- Swift
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme?.localizedCaseInsensitiveCompare("com.your-company.your-app.payments") == .orderedSame {
return BTAppContextSwitcher.handleOpenURL(url)
}
return false
}
If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.
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.
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. 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.
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.
- Swift
class ViewController: UIViewController {
var venmoDriver : BTVenmoDriver?
var venmoButton : UIButton?
var apiClient : BTAPIClient!
override func viewDidLoad() {
super.viewDidLoad()
self.apiClient = BTAPIClient(authorization: "<#CLIENT_AUTHORIZATION#>")
self.venmoDriver = BTVenmoDriver(apiClient: self.apiClient)
// setup venmoButton ....
self.venmoButton?.isHidden = !self.venmoDriver?.isiOSAppAvailableForAppSwitch() ?? true
}
func tappedButton() {
let request = BTVenmoRequest()
request.vault = true // Set this and use a client token with a customer ID to vault
request.paymentMethodUsage = .multiUse // available in v5.4.0+
self.venmoDriver?.tokenizeVenmoAccount(with: request) { (venmoAccount, error) in
guard let venmoAccount = venmoAccount else {
print("Error: \(error)")
return
}
// You got a Venmo nonce!
print(venmoAccount.nonce)
}
}
}
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.
Payment method usage
Starting in Braintree iOS v5.4.0, you should specify how you will use the customer's Venmo account by setting the paymentMethodUsage
property on BTVenmoRequest
:
.multiUse
: Request authorization for future payments (vaulting allowed).singleUse
: Request authorization for a one-time payment (vaulting not allowed)
If neither of these options has been specified, vaulting will be supported, but customers will see a legacy UI flow in the Venmo app. We recommend using .multiUse
or .singleUse
for the best customer experience.
The payment method usage will affect the customer flow by:
- Displaying different phrases to the customer on the transaction consent page (e.g. "Authorize
Business Name
to pay with Venmo" vs. "AuthorizeBusiness Name
to pay with Venmo for future purchases" whereBusiness Name
is the business name submitted in the Venmo application form). - Not displaying a merchant connection on the Connected Businesses page in the Venmo app when the
paymentMethodUsage
property is.singleUse
. - Allowing customers to update their funding instrument on the Connected Businesses page in the Venmo app when the
paymentMethodUsage
property is.mulitiUse
.
If paymentMethodUsage
is set to .singleUse
:
- A validation error will be returned if attempting to vault via PaymentMethod.create or Customer.create.
- The transaction will be processed normally but the nonce will not be vaulted if
store-in-vault
orstore-in-vault-on-success
is passed during transaction.sale.
- Swift
let request = BTVenmoRequest()
request.paymentMethodUsage = .multiUse
self.venmoDriver?.tokenizeVenmoAccount(with: request) { (nonce, error) in
// ...
}
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.
- Swift
let request = BTVenmoRequest()
request.profileID = "YOUR_VENMO_PROFILE_ID"
self.venmoDriver?.tokenizeVenmoAccount(with: request) { (nonce, error) in
// ...
}
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.
Get the SDK
CocoaPods
Include Braintree/PayPalDataCollector
in your Podfile:
- Ruby
# Podfile
pod 'Braintree/PayPalDataCollector'
Swift Package Manager
Include the PayPalDataCollector
framework.
Carthage
Include the PayPalDataCollector
and PPRiskMagnes
frameworks.
Collect device data
- Swift
let deviceData = PPDataCollector.collectPayPalDeviceData()
You'll need to pass this deviceData
when creating the Venmo transaction from your server.
Be sure to pass device data as close to the transaction creation as possible. Doing so will help reduce decline rates.