Stripe documentation points out that:
Because properly acknowledging receipt of the webhook
notification is so important, your endpoint should return
a 2xx HTTP status code prior to any complex logic could
cause a timeout.
In the web hook I'm developing with PHP this is exactly the
case — there is some complex logic involved after the event
is received.
Currently I'm returning the response code with a simple call
to http_response_code(). But how can I send the response
headers (with the code) before proceeding? Would a flush()
call force the headers to be sent?
Related
i have a backend system using PHP to handle transaction.
in this case, there is three environment involved.
A = client, B = my system, C = payment gateway
the scenario is :
client (A) send request over HTTP post request,then
my system (B) receive that request and then
send request to payment gateway (C) using cUrl.
what happen now is :
every request from client proceed by my system partially, which mean next process will be process when previous request to C has response.
what i want is :
even the prevoius request not yet responded by C, my system can receive next request from A and send another request to C.
I´m using Zapier Webhooks for integration between a Web Portal and an API. Both, the web portal and the API was developed with php. I´m using curl to send a request to a catch hook in Zapier, sending the Post Data. Then in my zap, the second step toke the catched fields and send it as form data to and PUT webhook to my API URL.
The problem is that in my portal, when I print the response of this call it always show something like this:
{"status": "success", "attempt": "5a81c6d1-bb9b-4afe-9ece-0cba4a0a52b0", "id": "cec1978a-c98f-4521-89f3-83a4041c15a4", "request_id": "5a81c6d1-bb9b-4afe-9ece-0cba4a0a52b0"}
But I need the real response of the webhook in the second step, showed in my zapier task as Data Output.
Someone knows why this is happening and how can I get the real response?
Thanks
David here, from the Zapier Platform team.
What you're describing isn't currently possible. When Zapier receives a hook, it lets the sender know the hook was successful and they need not retry; this isn't customizable.
In this situation, it sounds like you need a simple webserver, so you can customize the in and out behavior of your data? Or skip Zapier entirely and send the webhook directly to the destination.
I'm going to implement the IPN protocol in my website, using php.
Paypal documentation note that the protocol goes as follows:
The user clicks the button.
Paypal posts my IPN listener an IPN message.
My listener has to send an empty HTTP 200 OK response.
My listener has to send the message gotten from paypal (with a preceding string) back to paypal.
Paypal sends my listener a "VERIFIED" or "INVALID" response.
Can anyone explain why the protocol demands this [3] step?
Why can't it be fulfilled just with the [4]th step?
Also, I noticed that in another chapter of paypal documantation, they skip this [3]rd step themselves (see their implementation). So I wonder, is it really necessary??
The 200 OK response will happen automatically as long as your IPN script completes successfully. This let's the PayPal server that it did indeed complete.
If PayPal's IPN server gets something other than 200 OK back from your web server it will assume your script failed and will place that IPN in a que to be re-sent. It will resend after 30 seconds, then 60 seconds, then 120 seconds, etc. until it gets that 200 OK.
This is why sometimes people end up with duplicate IPN's. If you've got something at the very bottom of your script, for example, that's failing, but all of your email notifications, database updates, etc. actually did work prior to that point, you'd end up seeing those things happen again and again because PayPal kept re-sending the IPN. This can be very messy, of course, so you want to make sure that's not happening.
Again, though, the response code gets sent back to PayPal from your web server automatically. It's not something you actually have to do within your code.
I'm attempting to use the iron.mq push queue, but am having difficulty figuring out how to properly respond to the queue after receiving a message. I realize that I might also not fully understand how the queue system behaves, but my understanding is that it is something like this:
Message sent to queue
Message pushed from queue to my endpoint
Message is 'reserved' until my endpoint responds or times out
Endpoint responds with either a 2xx (success) and it is deleted or 4xx/5xx failure, in which case the queue will attempt to resend the message to the endpoint.
For example, my script (using FuelPHP) has something like this:
$headers = Input::headers(); //gets array of headers sent from ironmq
$data = #file_get_contents('php://input'); //get the body
Now that I have received the message, I want to do one of two things:
Process message and return response to ironmq servers that it was successful
Delay the process (by sending a 4xx/5xx?) and have it be resent after a defined period of time.
But... how do you respond to a push message? Using the PHP SDK's deleteMessage method causes an exception as the message appears to no longer exist.
Version 1. Endpoint responded with status 202. http://dev.iron.io/mq/reference/push_queues/#how_the_endpoint_should_handle_push_messages
You should explicitly delete a message after processing via deleteMessagePushStatus()
Version 2. Endpoint responded with status 200. Message will be deleted automatically, no actions required
so - two ways:
202 -> do long work -> deleteMessagePushStatus()
4xx or 5xx -> 4xx or 5xx (many times) -> 200
I am writing a script to handle the paypal IPN, so when someone buys something via paypal it will send them an email and write some info into a database.
I am using the Instant Payment Notification simulator, and it is sending my email ok but i would like it to actually re-direct to my php page, so i can test my error checking etc. When you submit it does call the page but i would like to actually be re-directed to it.
Anyone know if this is possible, or if there is anything i can do to 'fake' this process
Cheers
Luke
Well, you can just test your IPN by using a temporary Payment Data Transfer page. Read this page for more information about this.
So basically after your payment has been done it redirects you to that success page and does everything. So you can use the success page as a test version of your future IPN page. After your script is working exactly the way you want, you can use the code on that page by simply copy-pasting it into your IPN page and deleting that test PDT page.
Another way is to catch the entire output of your IPN page and mail it to you. Or store it somewhere. To do this, make use of PHP's output buffering.
I hope that makes sense to you...
I usually use micahcarrick Paypal IPN class for Paypal IPN.In this class you can see
success case in switch case statement, There you can redirect to your success page.
Actually, Paypal IPN will return response to us. you can see the action parameter in return url. using this you can find is payment is success or cancel or any error during payment.
Hope it helps,Thanks
Paypal IPN messages are Server to Server Messages for asynchronously receiving messages from Paypal regarding transactions. The HTTP Client used by Paypal to deliver IPN message to your server may not support redirect requests. As these HTTP requests are not coming from users browsers' output from your Php script is irrelevant. If you want to do any extended processing you have to incorporate that into your IPN Handler.