#ugo=php
1 messages · Page 1 of 1 (latest)
@last axle hmm, wouldn't that rely on cookies?
a webhook is just a request Stripe's backend server sends to your backend server. There's no cookies or user session.
Maybe, I'm approaching the whole payment process wrong then :P, I am trying to take a single payment of a certain amount, once the payment has gone through the session containing the basket items, I need to then store in a mysql database
But I soon come to realise that on the webhook I cannot access session variables :/
yep. You should for example add metadata to the object you create(a PaymentIntent, or CheckoutSession?) with some information you need like the order ID in your system and then in the webhook handler you can access that metadata in order to connect the webhook to the order in your system and fulfill the right order
I thought about using metadata, however a basket can contain alot of products with a character limit of 500, and a maximum of 50 entries, my concern is that a customer could theoretically exceed this amount.
If i was to complete database submissions on the return url page, instead of the webhook, does the return url page, ensure that the payment went through successfully?
well that should all be in your database and you just have the ID of the order(some value you can use to lookup the right row in your DB) on the Stripe object and then you look up your database for the actual details
no, since anyone could visit the return URL directly, and they might also never visit it(since they might close the browser before finishing the redirect but after paying), so you should rely on webhooks to have your backend fulfill the order
The thing im struggling to understand is, since the order isn't processed until payment is complete, I have no orderID.
there is no data in the database, except the products to purchase, the shopping cart is stored in a session
unless, I add the session data, to a database table, and update a field such as 'payment-status', on the webhook?
not sure really unfortunately, this is a little out of scope for what I know about since it's more a specific details of your overall e-commerce integration(I wish I knew/could help more).
IMO you probably want to persist the shopping cart in a database before redirecting to Checkout, or maybe there's some way to get the session contents in memory without using $_SESSION directly(maybe there's some ID you can put in the Stripe metadata that lets you look up a particular session)