#ugo=php

1 messages · Page 1 of 1 (latest)

quasi vessel
#

@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.

last axle
#

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 :/

quasi vessel
#

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

last axle
#

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?

quasi vessel
quasi vessel
last axle
#

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?

quasi vessel
#

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)