Open bkcsoft opened 5 months ago
There is an issue with your solution. After payment was made (using promotion code) the Stripe webhook will send request to your site to validate payment data. The validation will fail because payment amount does not match with the seat price. For example you booked a seat with price 50$. In Stripe you applied the promotion code (-15$). Now Stripe webhook will send a request that has 35$ as amount. Validation will fail as we expected the amount to be 50$ not 35$. The validation does not know about the applied promotion code.
Yeah you're right, I missed that. Would have to switch to listening for checkout.session.completed
-events instead, which contains amount_subtotal
. But that would mean having to update existing webhook, which I have no idea how to do.
For the new webhook creation just change charge.succeeded
in https://github.com/SiimKirjanen/seatreg/blob/master/php/services/StripeWebhooksService.php#L23-L27. For the existing webhooks it needs a little more work.
I think we can use https://github.com/SiimKirjanen/seatreg/blob/master/seatreg.php#L114-L118 "side effect" logic that runs only once when SEATREG_TRIGGER_SIDE_EFFECT
constant changes to update existing webhook. Docs for updating webhook 👉 https://docs.stripe.com/api/webhook_endpoints/update . So inside the "side effect" logic we need to detect if there are webhook present and then update. Some method already exist in https://github.com/SiimKirjanen/seatreg/blob/master/php/services/StripeWebhooksService.php but the updating method should be added.
For the new webhook creation just change
charge.succeeded
in https://github.com/SiimKirjanen/seatreg/blob/master/php/services/StripeWebhooksService.php#L23-L27. For the existing webhooks it needs a little more work. I think we can use https://github.com/SiimKirjanen/seatreg/blob/master/seatreg.php#L114-L118 "side effect" logic that runs only once whenSEATREG_TRIGGER_SIDE_EFFECT
constant changes to update existing webhook. Docs for updating webhook 👉 https://docs.stripe.com/api/webhook_endpoints/update . So inside the "side effect" logic we need to detect if there are webhook present and then update. Some method already exist in https://github.com/SiimKirjanen/seatreg/blob/master/php/services/StripeWebhooksService.php but the updating method should be added.
Seems doable. I'll have a look on tuesday.
Makes it so one can use Stripes discounts in the form of promotion codes.
First time in a wordpress plugin so I've just looked at previous PRs and code to figure out what I'm doing.