#xPaghkman

1 messages · Page 1 of 1 (latest)

proud burrowBOT
trim acorn
queen lotus
#

@trim acorn I want the opposite. Since if a user signs up, it will have own referral code to share, but he should not be able to use that code for him self

#

Would be good to have this functionality, otherwise I am not gonna be able to integrate referral code system.

wise sierra
#

there's not really any way to do that without adding a layer of your own logic on top. How would the promo codes get redeemed, what's your frontend payment integration?

queen lotus
#

I am using Stripe Checkout flow. I create a checkout seesion by customer id.

wise sierra
#

ok, then there isn't really any option since we simply don't support this kind of restriction to apply to the promo code object

queen lotus
#

Hmm. So looks like it is not possible to do that with Stripe at the moment. What would you suggest as alternative flow or something to make it work with Stripe ?

#

And is it possible that if this can be considered as feature request for Stripe? Maybe you could forward this use case to Stripe teams. At least for future, would be really good to have it.

wise sierra
#

there's no good answer beyond "don't use Promo Codes, build your own thing". So e.g. before sending a customer to Checkout, collect a code from them on your own page. Check that code against your own logic and restrictions, and if you allow it, then create the CheckoutSession with a coupon applied, and if not, create it without

queen lotus
wise sierra
#

yes

queen lotus
#

Thank you for explanations.

#

And I have one more additional question

#

About which webhook really I should listen to exactly know that subscription is paid and active and get the applied promo code for it.

wise sierra
#

checkout.session.created

#

note that field is not included by default or in the webhook body, you have to retrieve the CheckoutSession object from the API and pass expand:["total_details.breakdown.discounts"] I think, to get it returned

queen lotus
wise sierra
#

checkout.session.completed sorry

queen lotus
#

Okay, and, I believe, I will also need to listen for subscription update event to get the actions happening on customer portal.

#

Is there any race condition for receiving the events ? for example, when user completes checkout, I will get session.completed, but in the meantime I will probably get some subscription.update event, so is there any chance that this can overwrite the data in my database ?

wise sierra
queen lotus
#

Your endpoint shouldn’t expect delivery of these events in this order and should handle this accordingly. This is so general. I am not sure how am I supposed to compare the events by priority. For example checkout.session.completed vs subscription updated event. How do I know which one to consider as top priority.

wise sierra
#

generally you treat the event as a notification that something changed, and retrieve the related object from the API to get the latest state, and sync your system with that rather than the body in the event

queen lotus
#

Yes, make sense. Thank you!

#

So I can put like an internal function like syncSubscription and for any incoming webhooks related to subscription events, I can just call sync function, and I would make sure that I will have always latest data.

zenith warren
#

Hi! I'm taking over this thread.

#

It depends what exactly you want to sync. For subscription you could listen to customer.subscription.updated, and when you receive that event sync the subscription with your own database.

queen lotus
#

Basically I want to sync every update about when subscription details changes. So what @wise sierra saying makes sense I think. Because Like I can listen 4-5.. events for subscription details change, and in every webhook calling, I can just directly fetch subscription details by id instead of using the data coming with webhook

zenith warren
#

yes agreed.

queen lotus
#

And I believe it would be really good to see some strategies in the stripe documentation, otherwise it is so general. And might lead to wrong way for some people.

zenith warren
#

Thanks for the feedback!

queen lotus
#

@zenith warren Question, is checkout.session.completed triggered when also checkout session fails ? or it is just triggered when it is successful ?

zenith warren
queen lotus
#

@zenith warren Another question 🙂

#

Does this customer.subscription.updated event webhook covers any change in subscription object ?

#

For example there also these events

#

Since every one of them is an update in subscription, and would it trigger every time customer.subscription.updated, or this event is specific for just for some fields change ?

#

I could not find much about this topic in the doc.

zenith warren
#

I'm not 100% sure. I would recommend to update the subscription yourself and see which events are triggered