rick
rick

Reputation: 81

How to set subscribe the plan in android using stripe payment?

I am implementing the stripe payment gateway in my android app. Up to Now I am able to validate the credit card using stripe but I got stuck to subscribe . I am unable to set Stripe.api_key in app. Its shows cannot resolve variable. If I remove Stripe.api_key then app throw following exception

Stripe::AuthenticationError - No API key provided. (HINT: set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email [email protected] if you have any questions.):

please help to resolve the issue

Upvotes: 1

Views: 3012

Answers (1)

Ywain
Ywain

Reputation: 17503

The only part of the payment flow that should be done directly within a native Android app is the collection and tokenization of the customer's payment information, using Stripe's Android SDK.

Once the token has been created, you must sent it to a backend server, where you can use it to create a customer, then use the customer to create a subscription.

The reason you can't do this directly from the app is because those requests require that you use your secret API key, and the secret API key should never in any way be shared or embedded with the app. Otherwise, an attacker could retrieve it and use it to access your account and issue API requests on your behalf.

Upvotes: 2

Related Questions