#ebellotpu6_api
1 messages · Page 1 of 1 (latest)
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.
- ebellotpu6_list-prices, 2 days ago, 16 messages
- ebellotpu6_api, 3 days ago, 29 messages
👋 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/1273933254080335903
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
You'd use a webhook generally: https://docs.stripe.com/checkout/fulfillment
but for example, I have created this plink_1PoMBOJjXBonDcGmYfNp3aMJ paymentLink
Then I open the url and completed a payment
If I retrieve again this payment link, where I can check that this has been payed?
can I assign any paymentintentId or something like that?
Well Payment Links are reusable so there's no notion of the link being 'paid' generally
As I said, the way to be notified of when there's a payment made via a Payment Link is via the checkout.session.completed event that fires. You'd setup a webhook to listen for those, and then trigger whatever logic you need there
Potentially, depends on your technical level and what exactly it is you need to do once you're recieved a payment
You could leverage a no-code tool like Zapier to handle those events instead of writing your own code
When I recieve a payment, I want to update database status, no more
Then sounds like you need a webhook yep
how do them works? I don't want to redirect the customer to any web page. I only want to send a url to the customer to pay and then update my db
There's no webpage involved. The webhook is an endpoint you create on your server/API that receives events from us async (in the background) and processes them to do logic as you need
Get started here: https://docs.stripe.com/webhooks
If I have more than one account, i need to create that for all of them?
in general yes(unless your multiple accounts are connected together in some marketplace setup with our Connect product)
sorry, if I follow this steps and I have put a breakpoint in my webhook code, it would be break in some point?
stripe login
stripe listen --forward-to localhost:4242/webhook
stripe trigger payment_intent.succeeded
I have change the url to my api: localhost:5001/api/Webhook
remember that you need to have stripe listen running so it continues to forward events, you can't just execute it then close it and run stripe trigger; usually you use two terminal windows
and yes sure, if you have a debugger attached to your process and have a breakpoint and you process a webhook that would get hit
in the dashboard I have seen that the listener is Disconnected
How can I connect it?
is stripe listen running in a terminal somewhere on your machine?
2024-08-16 12:21:08 --> charge.succeeded [evt_3PoNHLJjXBonDcGm0Ud87Yf1]
2024-08-16 12:21:08 [ERROR] Failed to POST: Post "http://localhost:5001/api/Webhook": EOF
I am getting this error now
any logs from your process running on port 5001?
no, the breakpoint is not getting hit
I'd try to continue debugging it and add some more logs to see what's happening
also try just using curl or POSTMAN to POST data to your endpoint directly and confirm/deny if that works(to eliminate any issue with it being Stripe-specific versus an issue in your server)
i can hit the breakpoint
but now i am getting this error:
Stripe.StripeException: 'Received event with API version 2022-11-15, but Stripe.net 40.8.0 expects API version 2022-08-01. We recommend that you create a WebhookEndpoint with this API version. Otherwise, you can disable this exception by passing throwOnApiVersionMismatch: false to Stripe.EventUtility.ParseEvent or Stripe.EventUtility.ConstructEvent, but be wary that objects may be incorrectly deserialized
this is my code:
[HttpPost]
public async Task<IActionResult> Handle()
{
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
var webhookSecret = _configuration["StripeWebhookSecret"];
try
{
var stripeEvent = EventUtility.ConstructEvent(json, Request.Headers["Stripe-Signature"], webhookSecret);
if (stripeEvent.Type == Events.PaymentIntentSucceeded)
{
var paymentIntent = stripeEvent.Data.Object as PaymentIntent;
// Actualiza tu base de datos aquí con los detalles del pago
Console.WriteLine($"Pago exitoso: {paymentIntent.Id}");
}
return Ok();
}
catch (StripeException e)
{
return BadRequest(e.Message);
}
}
there's a few ways to handle that , the best is to upgrade your code to be compatible with the latest release of stripe-dotnet 45.8.0 , use that instead, and then you can use --latest https://docs.stripe.com/cli/listen#listen-latest
okey. And this webhook will be hire every time a payment intent succeeded?
because i only want to manage the paymentintents payed using a paymentLink,
it depends what event types you configure the endpoint to listen to (https://docs.stripe.com/webhooks#add-a-webhook-endpoint)
for PaymentLinks we suggest listening to the checkout.session.completed event type. https://docs.stripe.com/checkout/fulfillment
and can I set some data to the paymentLink to identify which paymentLink has been payed completed in the webhook?
you could store the ID of the PaymentLink object in your database and compare to https://docs.stripe.com/api/checkout/sessions when handling checkout.session.completed events ; you can add metadata to https://docs.stripe.com/api/payment-link/create#create_payment_link-metadata ; or to https://docs.stripe.com/api/payment-link/create#create_payment_link-payment_intent_data-metadata and then inspect those fields when handling the event
no(if that's what you need, don't use a PaymentLink, authenticate the user and directly create a CheckoutSession)
okey, I will try with checkout sessions
And the checkoutsession has a url to send it by email to the customer so he can complete the payment?
we don't usually recommend that; you would email the customer a link to your website, where you authenticate them, and then you redirect them to a CheckoutSession you create for that Customer cus_xxx
this is not good for me...
Why wouldn't it work?
Checkout Session URLs are not designed to be sent via email.
It would require a simple endpoint on your server to do this properly: the customer clicks on a URL pointing to your app, the endpoint would generate a fresh Checkout Sessio URL and redirect the customer to Stripe Checkout. This way you don't need to worry about expiry. You don't need to build another page for this.
okey, so I have to configure some paramater in the url that makes customer to login and then redirect to the checkout session?
It depends on you. You can put parameters in the URL that you share that will identify the customer automatically.
And why is the success_url required?
I don't want to redirect my customer to any page. Just show that his payment has been completed on checkout
Can I set this page
Unfortunately Stripe Checkout doesn't support a hosted "success" page.
I don't undertand how it can be so dificult to manage fail payments... I just want to send an email to my customers when they are not be able to complete a paymentintent, so they can retry the payment...
Where did you see this exactly?
Why don't you redirect them to where you handle your PaymentIntents?
because in this page, I use so many data that needs to get from previous pages..
and the customers needs to be loged in...
In what cases do the failed payments occur on your own checkout?
for example when customers needs to authenticate the payment method
or when they have insufficent funds
Is it using card?
yes
I have created an interface to retry payments in the same flow, but if the users close the page...
Card errors will appear synchronously in the Payment Element, so you won't need to send the customer elsewhere.
users close the page
You can save the progreess of their order checkout on your side, and get them back to the payment page when they're back.
dont' worry, we are not understanding...
I will try to change my checkout page to check if some parameters come from url and I will put the logic in there