CodeIgniter Forums
building a webhook's endpoint - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: building a webhook's endpoint (/showthread.php?tid=82153)



building a webhook's endpoint - richb201 - 06-17-2022

I have a webhook coming from Stripe. Should I create my endpoint by using the controller and have its function call a function in a Model? Or is there a better way in CI3 such as directly accessing a view? If I do the view, how do I directly address  it from Stripe? This is running on the public internet.


RE: building a webhook's endpoint - hoangyen123 - 06-17-2022

I have the same question. Pls help.


RE: building a webhook's endpoint - InsiteFX - 06-17-2022

I found this, you guys can read it.

LORNAJANE Blog - Handling Incoming Webhooks in PHP

Be sure to also read the Comments.


RE: building a webhook's endpoint - richb201 - 06-18-2022

Thx insite.


RE: building a webhook's endpoint - richb201 - 06-18-2022

Insite I read the article (and comments) and can surely see the authors point. In my case, I am just marking if the users payment went through. I already have a record for each user in my table. So I just need to update the field to paid or not paid. I use RDS, not a local table, so there could be an aws delay. But I am not really doing any processing.

For speed purposes, should the webhook being going directly to a view, rather than a method in my controller? How can l directly address a view from the app that is sending the webhook? How do I path it?

Thx

(06-18-2022, 08:12 AM)richb201 Wrote: Insite I read the article (and comments) and can surely see the authors point. In my case, I am just marking if the users payment went through. I already have a record for each user in  my table. So I just need to update the field to paid or not paid. I use RDS, not a local table, so there could be an aws delay. But I am not really doing any processing.

For speed purposes,  should the webhook being going directly to a view, rather than a method in my controller? How can l directly address a view from the app that is sending the webhook? How do I path it?

Or is a method in the controller preferred?

Thx



RE: building a webhook's endpoint - InsiteFX - 06-18-2022

If you need to also update a database table field then yes a method would be the way to go.


RE: building a webhook's endpoint - richb201 - 06-19-2022

Insite, good idea. Just one question. The examples show getting the payload with read file://input. How will thar work if I am going through a method?

[quote pid="397473" dateline="1655646259"]
Insite, good idea. Just one question? The examples (in stripe) show getting the payload with $payload=@file_get_contents('php//input').  Will that work if I am in a  method?
[/quote]


RE: building a webhook's endpoint - InsiteFX - 06-20-2022

Yes, it should still work it's just pure php code.