1

I am trying to prevent Recurly Webhooks from being executed multiple times if they are retried incorrectly (i.e.: when builds go out and servers time out occasionally). I see in the dashboard that webhooks have unique IDs, but these don't seem to be accessible in the message hash, am I missing something? I'm using Rails for what it's worth.

<?xml version="1.0" encoding="UTF-8"?>
<updated_subscription_notification>
  <account>
    <account_code>1</account_code>
    <username nil="true"></username>
    <email>verena@example.com</email>
    <first_name>Verena</first_name>
    <last_name>Example</last_name>
    <company_name nil="true"></company_name>
  </account>
  <subscription>
    <plan>
      <plan_code>1dpt</plan_code>
      <name>Subscription One</name>
    </plan>
    <uuid>292332928954ca62fa48048be5ac98ec</uuid>
    <state>active</state>
    <quantity type="integer">1</quantity>
    <total_amount_in_cents type="integer">200</total_amount_in_cents>
    <activated_at type="datetime">2010-09-23T22:12:39Z</activated_at>
    <canceled_at nil="true" type="datetime"></canceled_at>
    <expires_at nil="true" type="datetime"></expires_at>
    <current_period_started_at type="datetime">2010-09-23T22:03:30Z</current_period_started_at>
    <current_period_ends_at type="datetime">2010-09-24T22:03:30Z</current_period_ends_at>
    <trial_started_at nil="true" type="datetime">
    </trial_started_at>
    <trial_ends_at nil="true" type="datetime">
    </trial_ends_at>
    <collection_method>automatic</collection_method>
  </subscription>
</updated_subscription_notification>
dmulter
  • 2,608
  • 3
  • 15
  • 24
theleanmc
  • 33
  • 4

2 Answers2

1

A webhook may be retired several times, however once a successful status code is received by your server, Recurly will stop attempting to resend that notification. Hence, only one webhook will be delivered per event. Also, webhook IDs aren't included in the message hash, they're only found in the UI.

1

Unfortunately the only way to stop webhooks from being resent is to reply with a 200 status code with 5 seconds.(https://docs.recurly.com/docs/webhooks)

It was 30 seconds but that got changed November 2015 I think.

Anyway I solved it by throwing the message off to a queue and immediately responding with 200 response.