Webhook sending over and over - even though it says successful and I get the data

This might just be a backlog as I'm working on a dev site and only temporarily allowing FC to send the webhook to the server (via .htaccess removal).

But
I have a test order in FC
I tell it to resubmit the webook (which incidentally says pending near the button on your backend)

"Webhooks (Status: Pending)
'XXXX' (json): Pending"

It says successful

"Success:
Transaction xxxxxxxxxxx has been sent to the selected webhooks."

I get the data

Then it just sends over and over and over again with no end in sight....

Is there a confirmation that I should be sending back? or is something else happening on your end that isn't seeing this as successful?

While I can code around making duplicate entries to the customer data on our end, this is a lot of unnecessary traffic to my site.

Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @yyhmsg,

    Good question. Our webhooks will automatically retry on a schedule that gets a little longer after each retry, if we don't get a successful response back from your endpoint, which is simply a 200 HTTP response.

    If the webhook is still showing as pending after a minute or so on the transactions page - that shows that our webhook system isn't getting a successful response from your endpoint, and so will keep retrying over the next hour. After that time - if it's still unsuccessful, we'll log an error to your store's error log with details of what happened. Looking at your store - it appears that that is a 500 error.

    In terms of the success message you see when re-feeding the transaction - that's just indicating that it was successfully queued to send to your webhook - so it's more of a pending success rather than a "everything completed" message. We'll look at clarifying that message a little more to give more context there.
  • To be clearer, I'm actually getting all of the data on my end and able to process all of it. So everything is technically successful, yet it still sends over and over. I am turning access on and off, so at times, yes, you will see a 500.

    Should my script actually send http_response_code(200); after processing? I was assuming that when it doesn't send 500 then your side would think everything was ok?


  • Also is there a fix set of IP addresses that the webhooks are sent from so I can ensure my dev server is always open to them without opening it to everyone?
  • fc_adamfc_adam FoxyCart Team
    edited November 9
    @yyhmsg,

    Thanks for the additional details. From the logs - I can see there are some requests that are returning the 401 response - which is what we would be receiving when you lock down your server again. Every other request though we're getting a 500 response from your server.

    Your server can definitely be receiving the webhook payload just fine and able to process it, but from the responses we are receiving from your endpoint, there is something in your script which is causing it to respond with a 500 response instead of 200. We don't have any visibility as to what that could be - your server logs should show you more specific details about why it's triggering that 500 error.

    In terms of adding a specific 200 response, that shouldn't be required, as it's the default response when everything finishes fine. For it to be responding 500 to us - something in your script is triggering that to occur.
  • That's strange, I'm using the code right from your site and getting the data fine.... I have the following code:


    // Verify the webhook payload
    $signature = hash_hmac('sha256', $data, FOXY_WEBHOOK_ENCRYPTION_KEY);
    if (!hash_equals($signature, $_SERVER['HTTP_FOXY_WEBHOOK_SIGNATURE'])) {
    echo "Signature verification failed - data corrupted";
    http_response_code(500);
    return;
    }


    then
    ////////////////////////////////
    // IF WE HAVE JSON DATA FROM FC

    if (is_array($parsedData)) { ..... }


    then

    // END OF WE HAVE JSON FROM FC
    } else {
    // JSON data not found
    echo("No data");
    http_response_code(500);
    return;
    }


  • fc_marijafc_marija FoxyCart Team
    @yyhmsg -

    Have you had a chance to look at your server's logs? Feel free to whisper those here if you'd like us to take a look.
Sign In or Register to comment.