Help Center

Integrating Referral Rewards with my Advocate's membership account

Last Updated: Mar 16, 2017

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

  1. Select the Custom Reward option for your Referral Reward
  2. Specify the webhook URL that you would like to use 
    • When a referral is detected, the ReferralCandy system will call that webhook URL with a payload containing the details of that referral along with a signature for authentication
    • Verify the authenticity of the payload by making a call to the ReferralCandy app with the signature
    • Once the payload is verified, you have access to the data for that referral


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).

Still have questions? Contact us.

Have other questions? Contact us.

support@referralcandy.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete