В моем ионном приложении я подключаюсь к платежному шлюзу в полоску.
У меня есть функция в firebase
, которая запускается при обновлении клиента.
exports.updateStripeCustomer = functions.database.ref("/Customers/{userId}")
.onUpdate((snapshot, context) => {
const data = snapshot.after.val();
return stripe.customers.createSource(data.payment_sources.customer_id, {
source: data.payment_sources.source
}).then(customer => {
console.log("Update Stripe Customer");
return customer;
},
error => {
return error;
}
);
});
Это мой код в конце приложения, где я обновляю клиента. При обновлении триггера, вызываемого в firebase, как мне получить данные, возвращаемые триггером (функцией firebase) в приведенном ниже коде?
this.angularDb.object('/Customers/' + firebase.auth().currentUser.uid).update({
cardsetup: 1,
payment_sources: {
customer_id: this.user.customer_id,
source: this.card.source.id
}
}).then((res) => {
loading.dismiss();
alert("card details has been successfully updated.");
this.navCtrl.push(LoginPage);
}, (error) => {
loading.dismiss();
console.log("=========>", error.message)
alert(JSON.stringify(error))
});
Если функция firebase возвращает ошибку, мне нужно показать это сообщение об ошибке, возвращенное триггером. Есть ли способ сделать это?