I am creating a Rails 3.2 app and I am using Paymill as the payment gateway.
I am trying to setup a webhook on my system (Already setup on Paymill side). This webhook should respond to callbacks when a transaction was successful.
How can I "capture" the response object in my code? Using params?
Thankful for all help!
I don't know paymill, but it looks like it works the same way as stripe.
Thus, you have to handle the response with params.
You can have a look on this code sample: https://github.com/apalancat/paymill-rails
A webhook call from Paymill includes a JSON in the request. This JSON includes some meta data about the event that was triggered and the objects affected. So, you'd have to take the request body and parse the JSON to extract the information you are looking for. You can see a sample JSON file here:
https://www.paymill.com/de-de/dokumentation/referenz/api-referenz/#events
Related
enter image description hereNot getting appropriate response like I get on the postman application
I tried a few online APIs which give me response, but I need an option to be able to add a payload in my program. I am using tc3 iotbase library from the twincat library repo.
The HTTP POST request payload is builded by the FB_IotHttpRequest function block, when you call one of the send methods
You can use 2 option here:
FB_IotHttpRequest.SendRequest(...) in this case you need to create the payload JSON manually
FB_IotHttpRequest.SendJsonDomRequest(...) in this case you need just pass the reference of the FB_JsonDomParser, which contains the json document.
Background:
Looking at some links like these below, I noticed two unique sets of descriptions for GET versus POST.
One description states that the difference is in how the information is sent: GET sends that information through the URL whereas POST sends that information through the HTTP request body.
Another description states that the difference is in which way that
information is sent: GET sends information to the server whereas POST
requests information from the server.
I find these descriptions to be lacking for the following reasons:
What if I want to get something from the server (GET) but I am sending a large amount of data first (eg. 50MB of text) so I would need to send it in the HTTP request body (POST). Would it be OK to use POST to get something from the server?
What if I don't want sensitive information to be stored in the URL, is it OK to instead use POST everytime?
The jquery GET function has the same method signature as the jquery POST function (see documentation), specifically it can also send data as A plain object or string that is sent to the server with the request, which I interpret as being added to the HTTP request body. If data for GET can be sent via the HTTP request body, then to me, this contradicts most of these sites that claim that as one of the differentiating descriptions of POST vs GET.
Nothing's to stop me from creating API endpoints which are GET but behave like POST (or PUT, or DELETE or PATCH)
Question:
Is the lack of strict descriptions because of my poor understanding, because of the ad hoc development process for HTTP/Ajax or is it something else entirely?
Supporting Links:
HTTP Request Methods
GET vs. POST
GET vs POST: Key Difference between HTTP Methods
jQuery - AJAX get() and post() Methods
Thank you for the nice work you put into this amazing library.
I have an issue with my request adapter but only with the MultipartFormData.
I want to be able to update the body of the request but when the request gets in the adapter, I'm getting a nil httpBody. I only get this behaviour on Multipart, not on classic POST requests.
I'm trying to sign the request with an oauth2 token (async), but the particularity of this API is that the token is sent in the body and not in the headers.
There's a body as the metrics in the response say (Request Body Transfer Bytes) 231306
I'm using Alamofire 5.0.0
This is most likely due to multipart forms using UploadRequests (and therefore URLSessionUploadTasks) which do not include the body data as part of the URLRequest for performance reasons. If you update your question with what you're trying to do to the body, perhaps I can provide an alternate solution. If nothing else, you could manually create multipart uploads by using MultipartFormData.encode() directly and adding the Data to a URLRequest, but that's not recommended for large uploads.
Since 2 days I've been exploring the Telegram bot API, which is pretty neat. But there is one thing I can't figure out.
When you don't use the webHook but the /getUpdates call, you can tell the API via the offset parameter which message where processed by the server.
But how do you do this with the webHook in place? I keep getting the same message as an update. Which results in the server spamming the user with the same message.
The solution I came up with is as follows:
Receive an update from the webhook
Save the update_id
Reply to the user /sendMessage
disable the webHook /setWebhook?url=
Set the offset /getUpdates?offset={update_id+1}
Reinstate the webHook /setWebhook?url=https://mywebhook.domain.com
There must be a better way right? Anyone?
Ok, problem solved. It appeared that just a 200 (OK) wasn't enough (the body of my response was null. I've added a body to the response {}, and know it works fine.
You must say to telegram that you get updates successfully with this:
- 200 response code
&
- empty json like this {}
use This on webHook to get data from telegram servers:
// get the raw POST data
$rawData = file_get_contents("php://input");
// this returns null if not valid json
$jsonData = json_decode($rawData);
What HTTP status code are you returning on the page handling your webhook? It is possible that Telegram is attempting to retry your webhook endpoint because it's not receiving a status 200 (OK) from you.
not really sure where to start here other then to dive into CF (I REALLY don't want to do that) but....
I have an NSURLConnection signing OAuth2 requests to an ASP.NET WebAPI Resource Server, this resource server returns JSON body AND statusCode 400. I have yet to find a way to parse the data from the response when it returns code 400.
Does anyone here have any ideas? I would prefer to keep using NSURLConnection as this is only an OAuth2 consumer class. My other code is using restkit, but I do not want the OAuth2 end to require said library.
The process to parse data from a request which returns status 400 should be identical to that of a request returning status 200.
Simply note the status code in -connection:didReceiveResponse: and allow the request to continue; you will receive any additional data that the server sends in -connection:didReceiveData: as usual. Finally, you'll get a -connectionDidFinishLoading: call when all data has been received, and you can parse the JSON there.
Does your HTTP request Accept header specify "application/json"? If so, then this is probably an IIS bug and not iOS.
Interestingly enough, MVC4 ActionResult is broken in the RTM. Switching it over to Pure WebApi and fine tuning the response, I was able to finesse it into returning the proper data, it was likely serializing the json improperly which other languages weren't catching.