#Yousuf
1 messages · Page 1 of 1 (latest)
@solar obsidian let's chat here. I'm adding your other message from the main channel:
For the server, I am using firebase cloud functions, I did the following:
1- npm install stripe
2- this my index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const stripe = require('stripe')('sktest...);
admin.initializeApp();
exports.createStripeCharge = functions.https.onCall(async (data, context) => {
const amount = data.amount; // Amount in cents
// const paymentMethodId = data.paymentMethodId;
console.log(data.amount)
console.log("fuckoff 10")
try {
const paymentIntent = await stripe.paymentIntents.create({
amount:1000,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
// payment_method: paymentMethodId,
// confirm: true,
});
console.log("ssssssss")
return { clientSecret: paymentIntent.client_secret };
} catch (error) {
throw new functions.https.HttpsError('internal', 'Payment failed 4', error.message);
}
}); ```
Thanks, I would really appreciate any help
hello, i see the error on both the android and ios emulators whenever the onpay function is triggered.
Okay and have you added logs client-side to know exactly where the error occurs?
I guess so, it is popping up through this alert:
Alert.alert('Payment failed 3', error.message);
is there anything else I should do?
Do you see your "hello" log?
My guess is functions.httpsCallable('createStripeCharge') is coming back undefined
Firebase is a separate module than just using the Stripe React Native module
Did you install what was necessary for Firebase?
nope
Yeah, It everything else is working: firebase authentication, firestore, ...etc
I also have another cloud function thats working for push notifications
Hmm okay instead of alerting the error.message can you alert (or log) the whole error object?
} catch (error) {
console.log(error)
Alert.alert('Payment failed 3', error.message);
}
LOG [TypeError: undefined is not a function]
thats all am getting
Ah do you mean to have // const functions = useFunctions(); commented out?
i wasnt sure if i needed it. i tried uncommenting it. I dont think it worked. ill try again though
That is what defines functions which you use for functions.https.onCall()
So yeah if you don't have that then functions will be undefined like the error notes
// import functions from '@react-native-firebase/functions';
//import { useFunctions } from '@react-native-firebase/functions';
I was using the first import statement
Ah well that is commented out too in what you just provided?
You can try logging out functions on your component render as well
Which would be telling here
i tried this: const { data } = await firebase.functions.httpsCallable('createStripeCharge')({
I am getting this error: " LOG Cannot read property 'httpsCallable' of undefined"
Cool so same issue overall. functions is udnefined
yup
i added the missing parenthesis after functions. I got back the same error < LOG undefined is not a function>