I've been asked how we can send and receive HTTP requests to trigger a Mobile Text billing service. The billing service has no webservice to respond/trigger these message and will only take requests from a whitelisted IP. Therefore I assume we need a server side web service written that can handle a client request - trigger a billing message and return a reply to the client jquery/ajax.
This is coming from a fron-end developer with limited back end knowledge though! Therefore does anyone agree with my assumption - before I respond!?
Cheers
Paul
A webService is most prefferable. it gives more flexibility for future changes on the front end architechture (or type)
Related
I'm new to webhooks and am not really getting the hang of some points of it. KISS; the current problem is, think about:
a platform
that provides a service X
to book a service X, customer Y has to pay in advance
every payment is authorized first only
every payment is captured after the service has been received
From the booking of a service to the capture of the related payment, only the authorization is handled involving the client-side. All the rest is handled on the server-side.
For every possible case of a booking of a service on my platform, payment authorizations is requested as the first action on the server-side. Adaptations of the DB of the platform are only executed after a successful authorization of the payment from the frontend.
The only fallback webhook I implement is for the case where a customer books a service, authenticates, and then loses connection. Because in this case, the customer would have booked the service, but the platform server could not make the related updates. So the customer will have paid, but not receive his / her service via the platform.
My strategy is thus to implement a webhook to listen for the event of a transaction authorization "completed", and, if no transaction data is found internally, execute what needs to be done.
BUT, two questions popped up:
A) How can I control that a webhook gets executed AFTER the regular server-side script should have been executed? Delay the execution of the webhook script? What are the best pracs here?
B) If A) is possible, isn't it smarter to just cancel the authorized payment in the webhook, instead of coding the completion of every possible transaction via webhook? Already the thing that you lose the entire payload in case of a client who lost connection (the payload that you need to execute the server-side tasks after a payment authorization), and the consequent need of passing the according payload back-and-fourth to your payment API, while ensuring that CID is encrypted etc.; this just sounds like overkill to me.. Was anyone in the same situation, and also decided to just immediately cancel the just-authorized payment in lost connections via webhooks? Or must webhooks generally execute the exact same server-side script that the related server-validation would do? Meaning I have to find a way to pass the payload to my webhook function?
The webhook is your notification that the event has happened - you're under no obligation to perform any processing right that moment, or ever.
If you're using webhooks as a backup to a primary synchronous flow (a good design!), then you can record the event and enqueue for later.
Stick a record somewhere indicating "got this authorization. Check this again in an hour to make sure the customer did the thing."
And to your comment above: you probably don't want your sync and async flows to be the same. Your async backup might involve contacting the customer eg via email, while that's not necessary for the sync flow since the customer is still on session.
I want to send notifications to multiple android devices(where same app is installed) by fcm from php server side by calling this url -
https://fcm.googleapis.com/fcm/send
I checked sending messages to device groups but my requirement is such that there will not be definite devices to which i will send messages because i am going to do it in a hourly cron job, and each time a cron job runs it will send notification messages to different different devices according to requirements. or can it be done in another way?
But i am thinking to use "registration_ids" parameter instead of "to" parameter, details of these fields here in the Downstream HTTP messages section. In this registration_ids field i will put all required device registration tokens in array. Now my question is after receiving message in android device can the message be parsed in the android app sdk codes?. i am in a bit of doubt as in this documentation there are no mentions of registration_ids parameter when sending messages to multiple android devices. Please assure me. And furthermore, will the message be sent when android app is in background?!. Please don't write one line, provide some examples if possible.
In the documentation for building requests to send to multiple devices you will find an example of passing multiple FCM tokens in a single call to the FCM API in the tokens parameter (in Node.js) or by using a HTTP batch request with multiple subrequests (in the REST API).
If you're having a hard time making this work, posting a question that shows what you tried increases the chances that someone can help making it work.
Yes, the message is sent regardless of whether the app is in the foreground, or in background. Whether the notification is actually shown depends on many more factors, many of which are outside of your control (such as the Android version, device maker/OEM, and the user settings).
We made an mobile application and all purchases confirming after 10-45 minutes later via php server side logic.
Sample: if user clicks to buy button, getting request taken response message then server logic process some logic and confirming after this action.
So, we need to send log purchase event from php server to fabric.io server. Is there any way to do this? Or what is your opinions?
I made some searches about server to server communication and there isnt anything.
this is not how Answers works. you could in best case let the mobile client request the order status from the web-server and then report a successful purchase or a declined transaction to Answers from there... or even indicate to the mobile client, that the purchase is still being processed (without logging that as an event)... when a purchase takes that long, that's almost mandatory.
just see for yourself, Fabric for Web appears read-only.
there isnt any way to send it at this moment.
self.addEventListener('push', function(event) {
var jsonObj = event.data.json();
}
I have written chrome web push notification, but event.data is always null.
Currently I am using GCMPushMessage library, I think I need php curl for sending notification. Can anybody help me to send web push notification with payload?
As of 2015 , this related SO post stated, this is an intended behavior.
A downside to the current implementation of the Push API in Chrome is that you can't send any data with a push message. Nope, nothing. The reason for this is that in a future implementation, payload data will have to be encrypted on your server before it's sent to a push messaging endpoint. This way the endpoint, whatever push provider it is, will not be able to easily view the content of the push message. This also protects against other vulnerabilities like poor validation of HTTPS certificates and man-in-the-middle attacks between your server and the push provider. However, this encryption isn't supported yet, so in the meantime you'll need to perform a fetch to get information needed to populate a notification.
As provided by the document you have to fetch the information then populate it in the notification.
An update was released March 2016 named : Web Push Payload Encryption
Prior to Chrome 50, push messages could not contain any payload data. When the 'push' event fired in your service worker, all you knew was that the server was trying to tell you something, but not what it might be. You then had to make a follow up request to the server and obtain the details of the notification to show, which might fail in poor network conditions.
Now in Chrome 50 (and in the current version of Firefox on desktop) you can send some arbitrary data along with the push so that the client can avoid making the extra request. However, with great power comes great responsibility, so all payload data must be encrypted.
Ensure you've followed the implementation needed for applying payload in web push for Chrome. Like some Client-side changes and Server-side changes.
Hope this helps.
Actually I am using API to send SMS from a webpage from my site.
The SMS gateway site just gives the feedback of delivery, doesn't return to my website.
After sending SMS, I need to send emails & update database.
I know JavaScript & php.
I don't want to depend on SMS gateways redirection, is there a way to go to their webpage & return back without their involvement?
Call the API from your server using cURL and keep the client experience completly under your control - this way you not only can redirect, AJAX or whatever as much as you want, you can also doge some low-flying bullets with clients abusing your pages.
From your question, I assume that you are transferring control to the SMS gateway site by redirecting the browser to it, then no. Once the browser leaves your site and loads the gateway site, you no longer have the ability to run any code.
If you are, instead, invoking the SMS gateway API via server or client side code, then yes. Once the HTTP request that invokes the API is complete, you will be able to perform a redirect as you normally would.