Retrieve data from post webhook using React - reactjs

So this is a more general question and I did not know who to turn to. I have configured a webhook using from a live streaming third party platform I am using. I did this using Golang and tested my webhook I am getting the POST data how I want. Now the problem is how do you get this data back on the front end. I have looked into setting up websockets and server side events. They both don't make too much sense to me as I see the work on the front end should be pretty straightforward. I don't think I should have to configure another endpoint to get the webhook data and it doesn't listen to the webhook async anyway so I don't think that will work. Any help please...

Related

Is it possible to make work together Django Rest Framework, + Django Channels + Reactjs? if so..do I need Socket.io too on the client side?

I guess that the Title is quite explicit, but I will try to further explain my requirements so maybe anybody can help.
As explained Im building a site that uses DRF as backend and React in the client side, and i would like to have some real time functionalities, so I´ve been researching on the issue which took me to Channels as the way to manage asyncronous actions and websockets. The question is that the more I read the more I get confused... by the Channels documentation one might say that it has capabilities to work whether sincronous as asyncronous server..but then i do not want to miss my DRF classes that simplify my life so much... and the there is this other question coming to my mind regarding if then, i must also use socket.io in the front to connect with channels on the back.... so as you see... im quite confused...anybody could help?
I'm not sure about the client-side and socketio. but yes you can use Django channels and react to communicate on a WebSocket. you also be able to send a message on channels outside of consumers(API view). but it's kind of risky to retrieve data from WebSocket outside of the consumer. everything in consumers(channels) execute asynchronously so accessing received a message on WebSocket by API is not guaranteed.
1 - set up a Django-channels consumer and on connect add the channel to a group
2 - connect to the channel by react and communicate with the server and keep the channel open.
3- make APIs for events and send the event from API to the channel group.

Integrate Payment Gateway with IONIC

Don't mark question as duplicate or already asked. If know please answer.
I am trying to integrate payumoney payment gateway in my hybrid app. I went through some tutorials and finally reached to plugin cordovaInAppBrowser and using its events, loadstart, loadstop but not able to send and get parameters.Since last One Week I stucked and so finally posting here. Thanks, in advance
Finally I succeed in integrating the payment gateway in ionic. Its very easy, jsut follow the following steps,
add the cordovaInAppBrowser plugin and Inject the dependency.
make all the fields you get that to send to that Gateway with all validations.
now you needed some 3 files as success.php, failure.php and paymentfile.html.
$cordovaInAppBrowser.open("filename?"+params, '_blank',options)
make note that success and faliure php file are in server and access them through server
get the response in the php file than to controller, based on the response traverse the path and its done.
Most important you need to serialize the data while sending as its should be global and assign it to window object.
Also we have to use the cordovaInAppBrowser events loadstop() and all the stuff i had done in this event and later i call the close() function when its done.
Its Done.

Laravel: Making a Real Time Application using Angular

I am starting to work with angular and am fascinated by the bi-directional data-binding capabilities and by its $http method, which lets me save changes in to my mysql database, without refreshing the page.
Another thing I am currently fascinated by is the real time capability across multiple clients using firebase. Here all clients are updated in REAL TIME, when the database receives any changes. I'd probably like to use firebase, but I would have to drop Laravel and MySql as a persistence layer entirely, which I would like to keep for the moment, since my application is already working in Laravel, just not in real time.
How would I go about having a Real Time application, which updates every client, without refreshing the view, in Laravel using MySQL and Angular?
If I am not mistaken, Pusher and PubNub, are providing this necessary open connection with the server using websockets, so when the server has something to share, angular will now and render it.
Since I would like to use Laravel and MySQL as a persistence layer, I am not sure, what the best way would be. I am not even sure, if I understood everything correctly, which I wrote above, since I am new to angular and real-time applications.
What would be the next necessary steps, to get some Real-Time capability into a PHP/MySQL application?
The solution for your problem is:
1º - open websocket connection with the websocket-server and subscribe a channel, after this send the data to your serve using ajax
tutorial angular pusher
2º - In server side, you get the data, saves to your database and send a 'PUBLISH' to the respective channel into websocket server
lib useful for this
3º - Through the subscribe gets the data in real time
Pusher.subscribe('channel', 'event', function (item) {
// code
});
I had a similar problem recently and I finally ended up using Redis publish/subscribe Redis. You can store data in the channel and then subscribe to any changes. When something changes you can send it to Pusher which will send it then to the clients.
I also recommend considering Node.js and Socket.io since you can achieve very good performance without third party service, and even if you don't have experience with node you can find very good examples on Socket.IO how to write an application.
For Redis there is a good library for PHP called Predis and there is Redis Node client as well, so you can mix it all together.

Is it possible to set up an IPN listener using client side scripting?

I'm integrating a web payment using angularjs.
My main goal are
to let the user be able to topup or pay via paypal
upon successful redirect him back to my site
If the transaction is successful i will then update our db records.
Glad to say that after 2days I'm done with the first 2 steps. Then I've read about using PDT (Payment Data Transfer) and I used this to get the transaction details of the payer but I had read many post saying using PDT isn't reliable enough that I also must use IPN (Instant Payment Notification). So I google about it and almost all sample/tutorial about IPN are made from using server side scripting. So is it possible to perform an IPN listener using javascript alone?
No, not on the client-side. You can use server-side Javascript (nodejs) to do this. The purpose of IPN is to let your server know that a payment is completed. The IPN request comes directly from paypal behind the scenes to a URL you give it. There's no way for a client to receive this signal instead, and if it could then there'd be a big security flaw because anyone could forge it.
However, you could update your backend using IPN, then use something like socket.io (websockets) or long-polling (plain old ajax) to let your client know that payment was successful. With long-polling, you'd basically be asking your back-end every second or two whether or not payment was succesful. With sockets, you have a more direct communication. I like socket.io because it falls back to long polling (or flash) if real web sockets aren't available.

How can a server communiate with two clients at once (JavaScript, HTML, PHP)?

I got an assignment to do and for that I could use any www technology like HTML, JavaScript, PHP etc. I'm really sorry to say that I haven't studied any of these technologies. Therefore I took few tutorials and skimmed through them searching for answers.
I found solutions for many problems but one problem yet unsolved. It is this:
I want two clients to communicate through a server for this assignment. One send a message, server processes it and forwards it to the next.
None of PHP tutorials showed me anyway of doing this. All of them talked of communication between one client with a server.
Please help. Show me a way to do this. Thanks.
Currently, without reverting to cutting-edge (and possibly hacky/unreliable) techniques, your PHP server cannot initiate communications with a page you've already loaded into a web browser. This is a result of the way the HTTP protocol works.
One way to solve this would be polling on the "receiving" end for data. Something like a publish-subscribe pattern.
One way to do this would be:
One client sends data to the server using an HTTP request (XHR aka AJAX) specifying the target for this data (the other client).
The server stores this data in a persistent storage (local file, database, etc).
The second client periodically sends a request to the server asking if there's any new data for it to consume. This can be done using setInterval and XHR in JavaScript.
I would suggest you take a look at:
http://en.wikipedia.org/wiki/Publish/subscribe
And also, for a cutting edge way to do this, check out Socket.IO:
http://socket.io
You might want to Google on "php chat server." Building a chat server is a simple way to get started.
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-simple-web-based-chat-application/
http://code.jenseng.com/jenChat/

Resources