I have a firebase http cloud function
exports.createCharge = functions.https.onCall((data, context) =>{
Within this function, I am creating a Stripe charge
return stripe.charges.create(chargeInfo, { idempotency_key }, function (err, charge){
if(err){
return err.message;
}else{
return "done";
}
});
The stripe charge is the last line of code in the http function. My problem is the error message doesn't get returned back to the client, and the task.getResult() in my app comes back as null after completion. Also, variables do not persist outside of the stripe charge. err and charge must be used within the scope of the stripe charge function almost as if the stripe charge function is running in it's own environment. How can I return the err or charge back to the client?