问题
I would like to use firebase as a server and send request to payment request to stripe. I have zero experience server side so I am looking for a simple way to achieve this. This post Is it possible to integrate Stripe With Firebase and with iOS? is close to what I want to achieve and it also list some interesting link. Does anyone know where I can find a good but simple tutorial to set up firebase as a server for stripe?
回答1:
I resolved this with the following 2 steps
- follow step 1, 2 and 3 of the the get started article (https://firebase.google.com/docs/functions/get-started). This has allowed me to install all the software which was needed (note I had several issue with firebase tool install and node/npm but eventually I managed to install)
- Follow this youtube guide (https://www.youtube.com/watch?v=NsPGRIVOg0U). It is a nice video, simple to understand, on what to do to set up the function to request the execution of the payment.
- create some logic in my swift app to save the stripe token in a realtime database as below
func saveTokenInRealtimeDatabase(token: STPToken) {
let ref = Database.database().reference(withPath: "payments") ref.child(Auth.auth().currentUser!.uid).childByAutoId().setValue(["amount": valueToCharge, "token": token.allResponseFields]) }
回答2:
You will find in the list of official Cloud Function samples, a sample on how to integrate Firestore and Stripe:
"Create Stripe customers and charge them on Cloud Firestore write", https://github.com/firebase/functions-samples/tree/master/stripe
来源:https://stackoverflow.com/questions/57250314/how-to-set-up-firebase-as-server-and-execute-stripe-payment