Created
December 24, 2021 14:04
-
-
Save ologunB/dedf6dcd6bae51cb42a2664a12c01cb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const admin = require('firebase-admin'); | |
const axios = require('axios').default; | |
admin.initializeApp(functions.config().functions); | |
// you can test with the key | |
var testKey = | |
'sk_test_51HjsXiD2Y81WySxcSYZQxWqgom4mPTou65NDgdWwJ8PECjIT98CwUU4vyudP4BpSrZDjp4elhfPXcakUcHQia3bg00zX1RDDdo'; | |
//functions.config().stripe.testkey | |
exports.stripePayment = functions.https.onCall(async (data, context)=>{ | |
const amount = data.amount; | |
const stripe = require('stripe')(testKey); | |
return stripe.paymentIntents.create({ | |
amount: amount, | |
currency: 'cad' | |
}).then(result => { | |
return result; | |
}).catch((error) => { | |
return console.log(`url Error: ${error}`); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment