Skip to content

Instantly share code, notes, and snippets.

@ologunB
Created December 24, 2021 14:04
Show Gist options
  • Save ologunB/dedf6dcd6bae51cb42a2664a12c01cb3 to your computer and use it in GitHub Desktop.
Save ologunB/dedf6dcd6bae51cb42a2664a12c01cb3 to your computer and use it in GitHub Desktop.
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