Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { databse } from 'firebase'
- const userRef = database().ref('users/' + uid) // Assumes you have the users uid
- userRef.update({ token, lastFour }) // Assumes you've used Stripe.js to get a card token and lastFour
- userRef.child('stripeCustomerId').on('value', snap => {
- let stripeCustomerId = snap.val()
- if (stripeCustomerId) {
- userRef.child('charges').push({
- amount: 4000, // $40
- currency: 'usd',
- description: 'Example charge',
- customer: stripeCustomerId
- })
- userRef.child('stripeCustomerId').off('value')
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement