Reputation: 7
I can generate a token with the createTokenWithCardAsync function, but then I don't know how to use the token to go through with the payment process.
Would anyone know which functions are in the 'expo-payments-stripe'? The actual stripe functions like stripe.customers.create() or stripe.charges.create() do not work. So far I just know of 2 functions compatible with that package, the one I mentioned above and createTokenWithCardFormAsync...
Ultimately I would like to attach the token to a customer so that they don't need to put their card details everytime they want to purchase something.
Also at the moment of token creation I do not charge any money, just want to 'keep' their info just like uber does.
thanks!
Upvotes: 0
Views: 362
Reputation: 3331
Customer creation and Charge creation on Stripe is a secret-key only function, therefore cannot be done on your client-side (your mobile app which can only use your publishable key).
Therefore, the flow here is:
Create a Token on your app (as you are)
Post the token to your backend endpoint
Your backend endpoint (written in say, node using stripe-node
) calls stripe.customers.create()
with the Token ID, attaching the Token to the Customer
Charge creation later also has to happen server-side, not client-side.
Upvotes: 1