10

I am building an android app which pays someone. I explored Stripe Connect and it has an API and flow for website which requires displaying a stripe connect button and also needs a re-direct uri.

However, I can not find anything on for Android which allows to show a connect button and prompt user to create or connect a stripe account natively on Android device. Should I use a webview to do this or is there some more elegant way to do this?

windchime
  • 1,253
  • 16
  • 37

2 Answers2

8

As far as I know, there're no native SDK for mobile stripe connect. I did the webview route for android. Was trivial, but I agree that I wished there're a more elegant solution to this.

For those who are wondering on how to do this (since I can't find any doc out there), here you go:

  1. Create a button that will open a new intent with a web view.

  2. The webview should load the oauth/authorize endpoint ("https://connect.stripe.com/oauth/authorize?response_type=code&client_id=[YOUR_API_KEY]&scope=read_write"). Do not forget to enable javascript on your webview.

  3. Once the form in webview is filled, Stripe will redirect to the redirect_url you provided with the authorization code if the authorization is successful. Have your web service parse that authorization code.

  4. Have your service make a post to stripe oauth/token with providing grant_type, client_id, code, and client_secret.

  5. Stripe will then respond back with the token (auth credentials) that you needed. Store that for later use & you're pretty much done.

Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162
HungryMonkey
  • 121
  • 1
  • 4
  • hi HungryMondkey, can you please tell me about redirect_url? what should be there in that url? i mean in html body etc? – Zeeshan Shabbir Aug 10 '16 at 10:02
  • 1
    Please can you give some information on how the web service works in this context? How do I receive the token from the web service back to the android app? If the web service needs to save the auth credentials, how do I send the user information so I can map the user on a particular app to the stripe auth credentials to be saved – Tosin John Aug 26 '17 at 13:16
  • Account form is not loading on step#2. how was this resolved? – Cflux Feb 13 '20 at 14:56
  • Please provide more code – walkmn Jul 21 '22 at 12:44
0

I know this is quite an old one but, After investing my 2 days and trying, searching a lot of techniques to create stripe account in android platform I found Stripe API which solves my problem...

Firstly, here is the jar file you have to include in your project. Then you have to initialize key provided you at the dashboard

Stripe.apiKey = "sk_test_xxxxxxxxxxxxxxxxxxxxxxxx";
RequestOptions requestOptions = RequestOptions.builder()
                                 .setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxx").build();
Map<String, Object> accountParams = new HashMap<String, Object>();
   accountParams.put("managed", false);
   accountParams.put("country", "US");
   accountParams.put("email", "some@email.com");
  1. To create an account use create() method for Account class with there parameter create link

    try {
       Account create = Account.create(accountParams, null);
    } catch (AuthenticationException e) {
       e.printStackTrace();
    } 
    
  2. Then to retrieve account detail pass account id to retrieve() method

    try {
       Account detail = Account.retrieve("acct_xxxxxxxxxxxxxx", null);
    } catch (AuthenticationException e) {
       e.printStackTrace();
    } 
    

You can find more at Stripe Android API, and yes please do correct me if I am wrong..

Exception you need to catch AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException

Cflux
  • 1,423
  • 3
  • 19
  • 39
Iamat8
  • 3,888
  • 9
  • 25
  • 35