#pool_api

1 messages ¡ Page 1 of 1 (latest)

tawdry summitBOT
#

👋 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.

coarse girder
#

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);
},

proper briar
#

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

coarse girder
#

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

proper briar
#

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?

coarse girder
#

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

proper briar
#

Is that helpful or do you need more firebase specific advice?

coarse girder
#

yes please I would love the firebase specific advice

#

oh Im starting to understand! one second

#

Oh I see, allowing promotion codes solved my issue, I was stuck in my head on putting the promo code inside the textField, thank you very much