#Ayla

1 messages · Page 1 of 1 (latest)

ivory rapidsBOT
glad vessel
#

Cancelling the subscription by any means (Dashboard, API, customer portal) should ensure that the Firebase document is updated correctly to reflect that

lime rock
#

sure, but I have to take care of the firebase document myself? I don't do so for creating the subscription (via API). Documents like "payments" and "subscription" are created automatically

glad vessel
#

On customer.subscription.deleted events

glad vessel
lime rock
#

hm, sorry, I think i didn't get it .. I followed the instructions in the extension documentation to create a nwe subscrition like so: const docRef = await db .collection('users') .doc(currentUser.uid) .collection('checkout_sessions') .add({ price: 'price_1GqIC8HYgolSBA35zoTTN2Zl', success_url: window.location.origin, cancel_url: window.location.origin, }); // Wait for the CheckoutSession to get attached by the extension docRef.onSnapshot((snap) => { const { error, url } = snap.data(); if (error) { // Show an error to your customer and // inspect your Cloud Function logs in the Firebase console. alert(`An error occured: ${error.message}`); } if (url) { // We have a Stripe Checkout URL, let's redirect. window.location.assign(url); } });

#

how would the process look like for cancleing the subscription

glad vessel
#

Ok, great. And that creates the Subscription in Stripe and reflected status in Firebase, yes?

lime rock
#

jup

glad vessel
#

There's no specific function in the extension to cancel. You can either:

Learn how to cancel existing subscriptions.

GitHub

Repository of Firebase Extensions built by Stripe. - stripe-firebase-extensions/POSTINSTALL.md at next · stripe/stripe-firebase-extensions

lime rock
#

okay, great, Ill take a look to solution 1 and 3 and let you know if it works for me. Thanks for your help!

glad vessel
lime rock
#

hey, sorry, I did not manage to create a working solution. I initialize (in the react frontend) stripe like so: const initializeStripe = async () => { if (!stripePromise) { stripePromise = await loadStripe( process.env.REACT_APP_STRIPE_PK_KEY ); } return stripePromise; }; and when I use this to get my stripe object: const stripe = await getStripe(); it does not have a method stripe.subscriptions.del

glad vessel
#

That's because those methods are not available via Stripe.js, you need stripe-node to use server-side API requests like that

lime rock
#

Means I cant use stripe in my react frontend?

glad vessel
#

Not to make direct API calls like that, no. You'd need a server-side function

lime rock
#

hm, okay. Is there a reason, why some functionallity like creating subscriptions are available to access via the frontend code and others like deleting subscriptions are not?

glad vessel
#

The Stripe.js/React wrapper is mainly for using Elements and such, for collecting payment details

#

Creating Subscriptions isn't available via the front-end, not directly anyway. You're creating your subscriptions via the extension which, under the hood, uses the server-side APIs

#

It's just a convenient wrapper

lime rock
#

alright, got it (: .. thanks