简体   繁体   中英

How to save credit card for later use in Stripe payment with Flutter app and Firebase?

What is the approach to this problem? Can I do everything from app or I need to use cloud functions to save/get saved card?

Both "saving card for later use" [0] and "get saved card" [1] are both secret-key operations only, so those should be driven from your server-side code / cloud function.

The publishable key (the API key you use in your Flutter app) isn't capable of fetching/attaching saved cards to Customer objects, in Stripe. You can imagine the security concern if this were supported, that someone could use your publishable key (it is a public key) to list another Customer's saved cards.

[0] https://stripe.com/docs/api/payment_methods/attach

[1] https://stripe.com/docs/api/payment_methods/list

Use shared Preferences? You can learn more about it here

Here is the document you are looking for: https://stripe.com/docs/payments/save-and-reuse

  1. Create a Customer before setup
  2. Create a SetupIntent
  3. Collect card details
  4. Charge the saved card later

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM