• This repository has been archived on 28/Nov/2023
  • Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make and accept payments in your iOS app via Venmo

Venmo iOS SDK

Build Status

The Venmo iOS SDK lets you make and accept payments in your app using Venmo.

Installation

If you're using CocoaPods:

  1. If you don't have a Podfile, run pod init
  2. Add the following line to your Podfile:
pod 'Venmo-iOS-SDK', '~>1.3'

Make sure you run pod install to install all of your dependencies, and open your .xcworkspace file, not your .xcodeproj files!

If you don't use CocoaPods:

Clone this repository and add it to your project (this is a multi-step process, but it is possible). We recommend working with CocoaPods for now.

Usage

Using the Venmo iOS SDK is as easy as Venmo-ing a friend!

1. Create your app on Venmo

  1. Create a new application on the Venmo developer site.
  2. Make a note of your new app's app id and app secret.

2. Configure your Xcode project

  1. In your app target's Info section, scroll down to URL Types.

  2. Add a new URL Type with the following properties:

    Identifier: venmo<<YOUR_APP_ID>>

    URL Schemes: venmo<<YOUR_APP_ID>>

For example, if your app ID is 1234, put venmo1234.

Set URL Types

Note: If you are using the Parse SDK, and have issues, this gist should help you.

  1. You will need to update your application's plist to handle the changes to canOpenURL described in https://developer.apple.com/videos/wwdc/2015/?id=703

If you're recompiling with iOS SDK 9.0, add the following to your application's plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>venmo</string>
</array>

3. Initialize the Venmo iOS SDK

Add the Venmo SDK header file to your app delegate. Import this header in any of your implementation files to use the SDK.

#import <Venmo-iOS-SDK/Venmo.h>

Add the following code to initialize the SDK in your app delegate's application:didFinishLaunchingWithOptions: method.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [Venmo startWithAppId:@"VENMO_APP_ID" secret:@"VENMO_APP_SECRET" name:@"VENMO_APP_NAME"];

    return YES;
}
  • VENMO_APP_ID: ID from your registered app on the Venmo developer site
  • VENMO_APP_SECRET: Secret from your registered app on the Venmo developer site
  • VENMO_APP_NAME: The app name that will show up in the Venmo app (e.g. "sent via My Supercool App")

To allow the Venmo iOS SDK to handle responses from the Venmo app, add the following to your app delegate's application:openURL:sourceApplication:annotation: method:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if ([[Venmo sharedInstance] handleOpenURL:url]) {
        return YES;
    }
    // You can add your app-specific url handling code here if needed
    return NO;
}

4. Choose a transaction method

The Venmo iOS SDK lets you send a payment in two ways:

  1. Switching to the Venmo app

    • [[Venmo sharedInstance] setDefaultTransactionMethod:VENTransactionMethodAppSwitch];
    • This transaction method will switch the user to a pre-filled payment screen in the Venmo app. After the user sends or cancels the payment, they'll be switched back to your app.
    • If the user doesn't have the Venmo app installed, the payment will fail with an appropriate error.
    • N.B. You should run your app on a device with the Venmo app installed to test switching to the Venmo app.
  2. Using the Venmo API

    • [[Venmo sharedInstance] setDefaultTransactionMethod:VENTransactionMethodAPI];
    • This transaction method won't switch the user to Venmo to make the payment, but will prompt the user to give your app access to their Venmo account. If you want to use this transaction method, you will need to request permissions from the user before attempting to send a transaction.

If the user doesn't have the Venmo app installed, we recommend sending transactions via the Venmo API.

if (![Venmo isVenmoAppInstalled]) {
    [[Venmo sharedInstance] setDefaultTransactionMethod:VENTransactionMethodAPI];
}
else {
    [[Venmo sharedInstance] setDefaultTransactionMethod:VENTransactionMethodAppSwitch];
}

5. Request permissions

You can request access to a user's Venmo account using requestPermissions:withCompletionHandler:. Permissions can be specified with these scopes. If the user has the Venmo app installed, requestPermissions:withCompletionHandler will switch the user to an authorization page in the Venmo app. Otherwise, the user will be directed to an authorization page in Safari. After granting or denying permissions, the user will be redirected back to your app.

[[Venmo sharedInstance] requestPermissions:@[VENPermissionMakePayments,
                                             VENPermissionAccessProfile]
                     withCompletionHandler:^(BOOL success, NSError *error) {
    if (success) {
        // :)
    }
    else {
        // :(
    }
}];

6. Send a payment

After setting the desired transaction method and requesting permissions (if you want to use the Venmo API), you can send payments using sendPaymentTo:amount:note:completionHandler:. To send a payment request (a.k.a. charge), use sendRequestTo:amount:note:completionHandler:.

[[Venmo sharedInstance] sendPaymentTo:self.toTextField.text
                               amount:self.amountTextField.text.floatValue*100 // this is in cents!
                                 note:self.noteTextField.text
                    completionHandler:^(VENTransaction *transaction, BOOL success, NSError *error) {
    if (success) {
        NSLog(@"Transaction succeeded!");
    }
    else {
        NSLog(@"Transaction failed with error: %@", [error localizedDescription]);
    }
}];

Sample Application

Included in the sample directory is a sample application, MiniVenmo, which demonstrates how to log in with Venmo and send payments using the Venmo iOS SDK.

Contributing

We'd love to see your ideas for improving this library! The best way to contribute is by submitting a pull request – we'll do our best to respond to your patch as soon as possible. You can also submit an issue if you find bugs or have any questions. :octocat:

Please make sure to follow our general coding style and add test coverage for new features!

More Repositories

1

synx

A command-line tool that reorganizes your Xcode project folder to match your Xcode groups
Ruby
6,082
star
2

Static

Simple static table views for iOS in Swift.
Swift
1,250
star
3

VENTouchLock

A Touch ID and Passcode framework used in the Venmo app.
Objective-C
965
star
4

business-rules

Python DSL for setting up business intelligence rules that can be configured without code
Python
891
star
5

VENTokenField

Easy-to-use token field that is used in the Venmo app.
Objective-C
793
star
6

VENCalculatorInputView

Calculator keyboard used in the Venmo iOS app
Objective-C
763
star
7

DVR

Network testing for Swift
Swift
651
star
8

tooltip-view

Dead simple Android Tooltip Views
Java
486
star
9

DryDock-iOS

DEPRECATED: An open-source internal installer app
433
star
10

VENSeparatorView

Jagged border separators on UIViews used in the Venmo app.
Objective-C
379
star
11

VENVersionTracker

Objective-C
300
star
12

business-rules-ui

A JavaScript library for building out the logic and UI for business rules.
JavaScript
197
star
13

VENPromotionsManager

iOS Library to perform location & time-based promotions.
Objective-C
197
star
14

cursor-utils

A library that encapsulates the repeatable actions of Android Cursors.
Java
195
star
15

react-html-document

A foundational React component useful for rendering full html documents on the server.
JavaScript
155
star
16

VENExperimentsManager

An Objective-C library enabling easy implementation of feature experiments on iOS allowing users to opt in and out of experiments at will.
Objective-C
76
star
17

slouch

A lightweight Python framework for building cli-inspired Slack bots.
Python
71
star
18

xcode_server

Xcode Bot client
Ruby
58
star
19

android-pin

An easy drop-in PIN controller for Android
Java
42
star
20

app-switch-android

Java
35
star
21

VENCore

Core Objective-C client library for the Venmo API
Objective-C
27
star
22

QuizTrain

Swift Framework for TestRail's API
Swift
19
star
23

feature_ramp

Toggling and ramping features via a lightweight Redis backend.
Python
18
star
24

btnamespace

A Python library to isolate state on the Braintree sandbox during testing.
Python
17
star
25

flaskeleton

Python
13
star
26

swaggergenerator

Create swagger / OpenAPI schemas from example interactions.
Python
11
star
27

tornado-stub-client

A stub library for making requests with tornado's AsyncHTTPClient
Python
9
star
28

venmo.github.io

Old Venmo Engineering Blog
CSS
8
star
29

nose-detecthttp

A nose plugin that can detect tests making external http calls.
Python
7
star
30

puppet-consulr

Dynamic puppet manifests using consul
Ruby
5
star
31

puppet-sentry

Puppet module for managing the Sentry realtime event logging and aggregation platform
Ruby
4
star
32

python3-avro

Copies the python3 client implementation from our fork of apache's avro project.
Python
4
star
33

nose-seed-faker

A nose plugin that seeds the faker package
Python
4
star
34

QuizTrainExample

Example of how to use QuizTrain with Unit Tests and UI Tests on iOS
Swift
3
star
35

single-click-highlightable

HOC for React that allows users to highlight text on elements without triggering the onClick handler
JavaScript
3
star
36

puppet-hound

Puppet hound module
Puppet
2
star
37

nose-timeout

Nose plugin for aborting long running tests
Python
1
star
38

foundations-interview

This is a test repository used in Foundations team interview process
JavaScript
1
star