#blackbearftw_webhooks

1 messages ยท Page 1 of 1 (latest)

noble tangleBOT
#

๐Ÿ‘‹ 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.

gleaming oliveBOT
#

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.

idle cradle
#

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

gleaming oliveBOT
potent pasture
#

Hmm I don't really understand how your initial question relates to the unused customer, can you elaborate?

#

Or are those separate issues

idle cradle
#

no they are part of the same question

potent pasture
#

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?

idle cradle
#

Well its not that its not working

#

its more like

#

is that the proper way to do it?

potent pasture
#

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

idle cradle
#

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?

potent pasture
#

Ok, you're using Checkout to create the subscriptions?

idle cradle
#

yeah

potent pasture
#

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?

idle cradle
#

well no

#

I need the subscription to be linked to a tenant

potent pasture
#

Can you maybe summarize your flow to explain where you set this and what you're trying to improve?

idle cradle
#

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

potent pasture
#

are your tenants a 1:1 mapping to customers in stripe?

idle cradle
#

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

potent pasture
#

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

idle cradle
#

currently yeah, but I rather have them be created after the subscription is paid

potent pasture
#

ok

#

When/where do you need to tenant mapping ultimately?

#

customers? or would it suffice to have it on the subscription?

idle cradle
#

after the subscription is payed, I would like to create the tenant

#

for the first time

#

preferably

potent pasture
#

so before checkout/payment/subscirption creation, the tenant ID doesn't even exist yet?

idle cradle
#

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

potent pasture
#

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

idle cradle
#

sure

potent pasture
#

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

idle cradle
#

okay

#

I will do that

potent pasture
#

๐Ÿ‘

idle cradle
#

thank you

#

please keep this open

#

for a bit so I can read it back

noble tangleBOT
idle cradle
#

okay so I just did all of that

distant parcel
#

๐Ÿ‘‹ I'm stepping in for my teammate. Did letting Checkout create the customer, and adding metadata to the customer after Checkout Session completion help?

idle cradle
#

uhm

#

so

#

my webhook isn't being called

#

in the test modus

distant parcel
#

Do you have a Checkout Session ID or Subscription ID I can look at?

#

A webhook endpoint ID would also help (we_...)

idle cradle
#

sub_1P723UHzBP054H0c1BbiyrgI

distant parcel
#

Ah, I see you're using a local event listener (the Stripe CLI) for this

idle cradle
#

yeah

distant parcel
#

I see we went the checkout.session.completed event successfully

idle cradle
#

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

distant parcel
#

Right

idle cradle
#

lets try again

distant parcel
idle cradle
#

nope this works

#

thank you

distant parcel
#

Sure thing!

idle cradle
#

one question

#

how do I now access the meta data