#pool_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1328450666200436757
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
I tried just adding a discount field into the customer sent to firebase onPressed: _productId.isEmpty
? null
: () async {
setState(() {
pressedNext = true;
});
final price = await FirebaseFirestore
.instance
.collection('products')
.doc(_productId)
.collection('prices')
.where('active', isEqualTo: true)
.limit(1)
.get();
final docRef = await FirebaseFirestore
.instance
.collection('customers')
.doc(FirebaseAuth
.instance.currentUser?.uid)
.collection("checkout_sessions")
.add({
"client": "web",
"mode": "subscription",
"price": price.docs[0].id,
"discount": discountCode,
"success_url": "https://$domain/",
"cancel_url": "https://$domain/"
});
setState(() =>
_checkoutSessionId = docRef.id);
},
Hello can you tell me more about what you are trying to do here? Is the custom text field for a discount code that you will check yourself and apply to the customer if it is valid? Or something else
I would like to provide the customers codes that I create beforehand but are applied automatically to their subscription if they put them in the text field and they're valid
Checkout has pre-built functionality for taking discount codes, but I don't think there is a way to have Checkout automatically apply discounts from a custom text field. Have you considered using the built in discounts functionality for this?
I see, that might be exactly what I'm trying to do, I am just unsure how to fix my syntax and if the discount information will be properly transfered from firebase to stripe
We have this doc on creating discounts and coupons. the only real checkout thing that would need to happen is passing allow_promotion_codes=true https://docs.stripe.com/payments/checkout/discounts?payment-ui=stripe-hosted
Is that helpful or do you need more firebase specific advice?