#blackbearftw_webhooks
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/1230603285753237626
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- blackbearftw_webhooks, 21 hours ago, 8 messages
I would like to avoid making unnecessary customers in stripe
subscription is per team
and when I a user changes their mind before signing up the first time, I will now have an unusued customer in my dashboard
I preferably only want to make a stripe customer after payment is completed
but I also of course need to know what tenantId the subscription belongs to
Hmm I don't really understand how your initial question relates to the unused customer, can you elaborate?
Or are those separate issues
no they are part of the same question
For the original question, what you mentioned trying with metadata sounds like it should work, since you can set whatever details you need and check the metadata in the events. What part of that was not working like you expected?
I preferably only want to make a stripe customer after payment is completed
With subscriptions, you cannot do that, because the subscription needs a customer and you need to create the subscription before completing payment
metadata is a fine way to track details not natively supported in our api, if it works for your needs
yeah but I can allow the customer to fill in their information on the stripe checkout page right
why would I first programmatically create a customer?
Ok, you're using Checkout to create the subscriptions?
yeah
And the issue is that you're putting metadata on the customer, which forces you to create it ahead of time?
and thats what you want to avoid?
Can you maybe summarize your flow to explain where you set this and what you're trying to improve?
I want the user to create a tenant, this tenant officially gets created when they bought the subscription
but stripe somehow needs to know that the subscription that was created belongs to a specific tenant in my system
my problem is communicating that with my system
so one option would be creating a customer in stripe, getting the customer id, storing that as part of the tenant
are your tenants a 1:1 mapping to customers in stripe?
but then when they change their mind before purchasing the subscription, I now have a useless customer in stripe and a unused tenant in my system
yeah
I now have a useless customer in stripe and a unused tenant in my system
I'm missing a piece here about "unused" tenant. Do these not already exist?
We can keep working on this, but briefly we should be able to avoid customer creation up front for a new subscription, you can let Checkout handle creating that for you
currently yeah, but I rather have them be created after the subscription is paid
ok
When/where do you need to tenant mapping ultimately?
customers? or would it suffice to have it on the subscription?
after the subscription is payed, I would like to create the tenant
for the first time
preferably
so before checkout/payment/subscirption creation, the tenant ID doesn't even exist yet?
no
only the current logged in user
id
and the information they specified, like tenant name
and I somehow need them to pay, then create that object
the only way I can think of is using the meta field
so could this work? a rough sketch:
1/ create checkout session with user id & initial tenant name
2/ let checkout create customer automatically with payment success
3/ you read those id/name details from the session to set the customer metadata
sure
Ok so then I would recommend setting the user id & name in the checkout session metadata when you create it
then after success you listen for checkout.session.complete events, the metadata is there for you to inspect along with the subscription
and the customer id
so you can then go an update that new customer metadata with those details, copying from the session metadata
๐
okay so I just did all of that
๐ I'm stepping in for my teammate. Did letting Checkout create the customer, and adding metadata to the customer after Checkout Session completion help?
Do you have a Checkout Session ID or Subscription ID I can look at?
A webhook endpoint ID would also help (we_...)
sub_1P723UHzBP054H0c1BbiyrgI
Ah, I see you're using a local event listener (the Stripe CLI) for this
yeah
I see we went the checkout.session.completed event successfully
mhm
well
[ApiController, Route(Routes.Subscriptions.Webhook)]
public class WebhookEndpoint(Webhook.Handler handler) : ControllerBase
{
[HttpGet]
public async Task<WebhookResponse> HandleAsync(
CancellationToken cancellationToken = new()
) => await handler.HandleAsync(new Webhook.Command(), cancellationToken);
}
its not calling this code
1 sec
I think its something with our authentication
ah its post
Right
lets try again
In case it's helpful, you can also quickly trigger one-off events with the CLI to double check any local webhook handler logic: https://docs.stripe.com/webhooks#test-webhook
Sure thing!