#Maniac-NET-webhook
1 messages · Page 1 of 1 (latest)
haha no worries.
I feel like I am probably the millionth person to do this, so a sample project must exist so that I don't have to figure it out from scratch. But I can't find anything. And the documentation seems to be missing pieces.
How about choosing .NET here
or click the "Download full app"
Yes, I have the basics working. I can call the checkout page, when user makes a payment it calls my webhook. But that example does not capture the customer ID for me
See this example: https://stripe.com/docs/billing/subscriptions/build-subscriptions
#4 says Provistion and Monitor Subscriptions
In that example code it shows:
switch (stripeEvent.Type) {
case 'checkout.session.completed':
// Payment is successful and the subscription is created.
// You should provision the subscription and save the customer ID to your database.
break;
case 'invoice.paid':
So the comments "//you shoudl provision the sub and SAVE THE CUSTOMER ID" This is my problem. I can't figure out how to get and save the customer ID. It's only a comment in this code and I can't believe there is no code example anywhere ?
In that case you can explore what's inside the event. It's a Checkout Session object: https://stripe.com/docs/api/checkout/sessions/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
var session = stripeEvent.Data.Object as Session;
Then get the CustomerId : https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Entities/Checkout/Sessions/Session.cs#L121
Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com. - stripe-dotnet/Session.cs at master · stripe/stripe-dotnet
I am not super familiar with .NET but I believe it should be something like that
Similar to the Doc
hmm, ok I have to explore that session object link you sent
I guess there is no "completed" .net sample project where it is already being done?
All the links / documentation seem to discuss it, but no actual coded example that I can find. I'm just trying to see if I can save my brain some energy 🙂
I found it!
thank you sir, that looks interesting. I will examine it !
looks like on succesfull checkout, it will give me that session ID. So I can figure out how to use that in the Customer object I guess.
It should give you a full Session object, which has quite a lot of information inside. One is the CustomerId
I see. I am reading. If that object contains the customer ID then that is perfect. Thank you!
I am surprised they don't have a properly coded example that does this already
The only comment "save customer ID now" is a little misleading without showing us 😦
Sorry, but hope you have a good start here to explore the object
yes thank you very much for your help