To integrate the Referral Rewards with your Advocate's membership account, you'll need to use the Custom Reward option and process the information received to credit an advocate's membership account accordingly.

You can process this information manually as we'll send you an email each time a referral is detected. Alternatively, you can also receive the information programatically via a webhook and process it accordingly.

Note: Implementing this will require technical expertise on your part as every membership account platform is different


i.e. We return the following JSON response when a referred purchase is made:

Field : Description

referral_email : Email address of referred friend.
referral_timestamp : UNIX timestamp when referral purchase was made.
referring_email : Email address of referring advocate.

Example of the JSON response:

{
"referral_email": "friend@example.com",
"referral_timestamp": 1434439382,
"referring_email": "advocate@example.com"
}

Each webhook notification includes a X-Referral-Candy-Signature header which is generated by calculating the MD5 hash of your API secret along with the data sent in the request.

To verify the authenticity of a webhook notification, calculate the MD5 hash and ensure that it matches the value of the X-Referral-Candy-Signature header.

Note that if you are using a Rack based framework such as Ruby on Rails or Sinatra the header you are looking for is HTTP_X_REFERRAL_CANDY_SIGNATURE

A Ruby example:

require 'digest/md5'

# obtain from your ReferralCandy My Profile page
API_SECRET = "your_secret"


def webhook_verified?(request)
data = request.body.read
signature = Digest::MD5.hexdigest("#{API_SECRET}#{data}")
signature == request.env["HTTP_X_REFERRAL_CANDY_SIGNATURE"]
end

*Please note that our server expects a response with HTTP status code of 200. In the event that the webhook notification does not get a 200 response, the ReferralCandy app will send you an email to notify you about this. The webhook will not be tried again and the reward isn’t lost (this webhook is just a notification, so it will not affect the running of your referral program).

Did this answer your question?