Has anyone had success using Stripe connect with an iOS app. I have a few questions:
I\'m following the guidelines here: https://stripe.com/docs/connect/getting-st
You should setup a small web app to create stripe charges and storing you customers Authorization Code. Configure two routes in your web app for redirect_uri
and webhook_uri
and add the url in your Stripe Apps settings. The charges should be created from a server side app because it requires the secret_key / authorization_code which should not be stored in an iPad app. Otherwise they may lead to a security leak. I'm trying to describe the concept below:
Provide the stripe connect button
in your app and set the link to open in Safari (not in an web view). You should add a state
parameter to the url with an id
which is unique to your users.
On tapping the button your user will be redirected to Stripe where s/he will be asked to authorize your application. Upon authorization stripe will hit your redirect_uri
with a authorization_code
and the state
you previously provided. Do a post call according to Stripe Documentation with the authorization_code
to get an access_token
. Store the access_token
mapped with the state
in a database.
Define a custom url scheme in your app. Invoke the custom url from your web app. The user supposed to open the url in mobile safari. So invoking the custom url will reopen your application. You can pass an additional parameter to indicate failure / success. In your app update the view based on this parameter.
Now you are all set to create a charge on your server on behalf of the iPad user. Use stripe iOS sdk to generate a card_token
from the card information. It'll require your stripe publishable_key
. Then define an api in your web app which takes 3 parameters: card_token
, user_id
and amount
. Call this api from your iPad app whenever you want to create a charge. You can also encrypt this information with a key if you're worried about security using any standard encryption method. You can easily decrypt the info in your web app as you know the key.
When this api is called from the iPad app you'll receive the user_id
(which you saved as state
previously), card_token
and amount
. Retrieve the access_token
mapped to the user_id
(or state). You can then made a charge on behalf of the user using the access_token
, card_token
and amount
.
You can use ruby / php / python / node in the server as Stripe provides sdk for them. I assume other languages can be used as well as there is a REST interface.
Please note that this is just a concept. It should work like it but I haven't implemented it yet. I'll update this answer with sample code when I'm done.
You can use UIWebView. You will still need to use redirect urls and monitor the redirect using the delegate "webView:shouldStartLoadWithRequest:navigationType:"