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?
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:
Create a button that will open a new intent with a web view.
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.
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.
Have your service make a post to stripe oauth/token with providing grant_type, client_id, code, and client_secret.
Stripe will then respond back with the token (auth credentials) that you needed. Store that for later use & you're pretty much done.
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");
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();
}
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