#hannamitri
1 messages · Page 1 of 1 (latest)
Just noticed the card details are not being saved for one-time payments
It's working fine for subscriptions
what code are you using exactly to take the one time payments?
stripeObj = {
mode: "payment",
line_items: [
{
price: PlanPriceIdB[plan],
quantity: 1,
},
],
success_url: `${window.location.origin}/`,
cancel_url: `${window.location.origin}/`,
billing_address_collection: "auto",
};
you have to pass https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage if you want Checkout to save the PaymentMethod to the Customer
I'll try it and let you know if it works
Now it's showing here, but the payment methods is still empty
This is my new object:
stripeObj = {
mode: "payment",
line_items: [
{
price: PlanPriceIdB[plan],
quantity: 1,
},
],
allow_promotion_codes: plan === "bootcamp",
success_url: `${window.location.origin}/onboarding`,
cancel_url: `${window.location.origin}/`,
billing_address_collection: "auto",
setup_future_usage: "off_session",
};
that's not correct
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage
it's inside the payment_intent_data field, so payment_intent_data:{setup_future_usage:"off_session"}
oops, my bad - but i'm still getting the same result
I don't think it can be done inside that object
I thnk it can
do you have some example I can look at like your most recent PaymentIntent pi_xxxx or CheckoutSession cs_test_xxxx that has the problem?
stripeObj = {
mode: "payment",
line_items: [
{
price: PlanPriceIdB[plan],
quantity: 1,
},
],
allow_promotion_codes: plan === "bootcamp",
success_url: `${window.location.origin}/onboarding`,
cancel_url: `${window.location.origin}/`,
billing_address_collection: "auto",
payment_intent_data: {
setup_future_usage: "off_session",
},
};
await firebase.default
.firestore()
.collection("customers")
.doc(user.uid)
.collection("checkout_sessions")
.add(stripeObj)
.then((docRef) => {
docRef.onSnapshot(async (snap) => {
const { sessionId } = snap.data();
if (sessionId) {
const stripe = await loadStripe(process.env.STRIPE_KEY);
await stripe.redirectToCheckout({ sessionId });
}
});
});
That's the whole code
PaymentIntent pi_xxxx or CheckoutSession cs_test_xxxx that has the problem
my guess is that code you posted isn't actually running and you didn't deploy it to Firebase after changing it. Is that possible?
I'm still testing it on my local, let me restart my local server
The code looks good, right?
yes
please share a PaymentIntent pi_xxxx or CheckoutSession cs_test_xxxx that has the problem
pi_3NLPDYJkrlmcPYXM06pzWECN
you can see that no value came through for payment_intent_data , so the code you posted above is not what is actually running(as I said, maybe it's not deployed properly)
or you didn't save the .js file after making the change, or didn't restart the local server
I think the issue is that I'm not using stripe's API
Do you think that may be the problem?
I don't know what you mean by "not using Stripe's API".
that's a screenshot of ChatGPT , yep. Did you have a question to ask me here?
Yeah, what do you think of the answer
dunno, I am not going to read it. Did you have a question?
Taking into consideration I did everything you said above and it's still not working, what do you think I should do?
I think you should check that the code you posted is actually running
I explained to you that if you look at your API logs, you can clearly see that the parameters you say you pass in your code are not in the API request we recieve
It is running, because that's how I tried buying a subscription
but the code you posted has nothing to do with subscriptions
Sorry I meant payment
I think in any case this is a problem with that Firebase library we use
it only accepts certain parameters, and it ignores one it doesn't recoginse
that is what is happening and why it is not passing through your payment_intent_data
That could be the problem
I suggest not using that firebase library unfortunately, it's unmaintained
I think that's the problem, cause there's literally nothing else
yep, I've seen that problem before
make sure I suppose that you are using the latest version of the Firebase extension
I think we added support at some point ; https://github.com/stripe/stripe-firebase-extensions/issues/340
but overall, unfortuantely that library is not maintained anymore.