У меня есть функция firebase, которая вызывает API Stripe для создания пользователя, что прекрасно работает.Тем не менее, я не могу получить правильный ответ от функции в моем приложении Flutter.Что бы я ни пытался, данные ответа всегда равны нулю, даже когда функция возвращает ответ, а не ошибку.Этот код в значительной степени совпадает с примером из документации.Может кто-нибудь определить, где я иду не так?
Функция
exports.stripeSignup = functions.https.onCall(async (data, context) => {
const uid = context.auth.uid;
console.log(`Received data ${JSON.stringify(data)}`);
stripe.accounts.create({
type: 'custom',
business_type: 'individual',
individual: {
email: data.email,
first_name: data.first_name,
last_name: data.last_name,
},
country: 'GB',
email: data.email,
requested_capabilities: ['card_payments', 'transfers']
})
.then((account) => {
console.log(`Stripe account: ${account.id}`);
return {
stripeId: account.id
};
})
.catch((err) => {
console.log(`Err: ${JSON.stringify(err)}`);
return null;
});
});
final HttpsCallable callable =
CloudFunctions.instance.getHttpsCallable(functionName: 'stripeSignup');
try {
final HttpsCallableResult res = await callable.call(<String, dynamic>{
'first_name': firstname,
'last_name': lastname,
'dob': dob,
'email': email,
'phone': phone,
});
print('Stripe response - ${res.data}');
String stripeId = res.data['stripeId'];
return stripeId;
} on CloudFunctionsException catch (e) {
return null;
}