I am trying to fix my previously working(can not give a head on this one) firebase cloud function that on document delete should trigger stripe's customers.deleteSource endpoint. However it simply does not trigger it and I can not understand why.
This is the function:
exports.removePaymentSource = functions.region('europe-west1').firestore.document('/stripe_customers/{userId}/sources/{sourceId}').onDelete(async (change, context) => {
console.log('Does not log..')
try {
const source = change.before.data();
const customer_id = source.customer;
const card = source.card;
console.log('Does not log..')
console.log('Does not trigger the await')
return await stripe.customers.deleteSource(customer_id, card);
} catch (error) {
return reportError(error, {user: context.params.userId});
}
});
In this case I would expect to see some error since it does log on Firebase's functions log but it logs 'executed successfully..'. Also I would like to mention that all my other stripe endpoints are working perfectly, so the stripe implementation itself is fine, just the damn deleteSource.
This is the picture from Firebase's functions logs:
What I am doing wrong? Can anybody please lead me to the right direction? Any help is appreciated!
