You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-34Lines changed: 47 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -3,59 +3,72 @@ Use this SDK to easily add Venmo payments to your Android app! Just follow thes
3
3
1) First you need to register your app with Venmo here: https://venmo.com/account/app/new (for a description on what these fields are,
4
4
go here: https://venmo.com/api#registering-an-application). After your app has been approved, you will need to get your app credentials here: https://venmo.com/account/settings/developers.
5
5
6
-
2) Download the two files listed in this repository, and include them in your directory: VenmoSDK.java and VenmoResponse.java. You'll need to add your package name at the top of each file (e.g. "package com.name;")
6
+
2) Download the two following two files and include them in your directory: VenmoSDK.java and VenmoWebViewActivity. You'll need to edit your manifest to add VenmoWebViewActivity as an activity, and you'll need to add your package name at the top of each file (e.g. "package com.name;").
7
7
8
-
3)You'll also need to download json_simple-1.1.jar from here: http://code.google.com/p/json-simple/. Add this to your libs directory (create this folder if it doesn't already exist).
8
+
3)Download venmo_webview.xml and add it to your res/layout directory.
9
9
10
-
4) You need to add that json jar to your class path. To do so, in Eclipse go to Project -> Properties, and then click "Java Build Path" on the left. Click the Libraries tab at the top. Click "Add Jar" and then find the .jar file you just put in your libs directory. Select it and click "OK". See screenshot.png for a screenshot of this.
10
+
4) You'll also need to download json_simple-1.1.jar from here: http://code.google.com/p/json-simple/. Add this to your libs directory (create this folder if it doesn't already exist). You'll need to add that json jar to your class path. To do so, in Eclipse go to Project -> Properties, and then click "Java Build Path" on the left. Click the Libraries tab at the top. Click "Add Jar" and then find the .jar file you just put in your libs directory. Select it and click "OK". See screenshot.png for a screenshot of this.
11
11
12
-
5) Now, you're ready to use the SDK! From your app, include the following code when you want the Venmo app to open:
12
+
5) Now, you're ready to use the SDK! From the activity in your app where you want to open the Venmo app, include the following code:
* app_id is the app_id you have registered with venmo.com
27
-
* app_local_id is something you make up. An example is "abcd".
28
31
* app_name is the name of your app
29
32
* recipient is the venmo username, phone number, or email address of the person who is being paid or charged
30
33
* amount is the amount to be paid or charged
31
34
* note is the note that will be sent with the payment/charge. For example, the note might be "for a drink on me!"
32
35
* txn is either "pay" or "charge"
33
36
37
+
This will open the Venmo app's pay/charge screen if the user has the Venmo app installed on the phone. If they don't have it installed, it will instead send them to the activity you added - VenmoWebViewActivity - which displays a mobile web version of Venmo in a webview. This will allow the user to enter his credit card information and complete the transaction.
38
+
39
+
6) If you look at the previous step, you'll see that the Venmo activity that allows the transaction to be completed is opened using the "startActivityForResult" method, which means that once the activity is finished, control will be yielded back to your activity. To handle the response (i.e. to know whether the payment was completed successfully), implement Android's onActivityResult method in the same activity where you wrote the code in step 5. This will look like the following:
40
+
41
+
@Override
42
+
protected void onActivityResult(int requestCode, int resultCode, Intent data)
43
+
{
44
+
switch(requestCode) {
45
+
case 1: { //1 is the requestCode we picked for Venmo earlier when we called startActivityForResult
where 9999 is your app_id and abcd is the app_local_id you created above.
49
-
50
-
7) Create a file named URLActivity.java, which should extend Activity. This is the activity that is called when control is given back to your app, after a payment has gone through and the user pressed "back to your app". Inside of the onCreate method, include the following:
where app_secret is the secret key you were given when you registered your app with Venmo.
69
+
Note that we're using 1 as the requestCode for Venmo.
57
70
58
-
If you want to display the results of the transaction, then the response variable contains public methods you can use to access these variables:
71
+
Make sure you display the results of the transaction after it is completed. The response variable above contains public methods you can use to access these variables:
0 commit comments