Building a Refer and Earn Workflow system:
For this particular scenario, we will be raising a Credit Note (for fixed incentive amount) for a referrer who has referred a new customer. The Credit Note can be later applied during the next billing cycle of the customer. Let us look into a simple scenario to understand this better.
Assume that John is a long term subscriber for your product and he in turn is referring his friend Mark to your product. Here,
John -> Referrer
Mark -> Referred Customer
When Mark subscribes to your product, he will mention that John is the one who has referred Mark. Since John has made a successful referral, you will raise a credit note for John for a fixed incentive amount.
As you can see, the most primary requirement for this workflow is to identify the referrer. In this case, to identify the referrer, we will show a Custom Field of type Email Address in the Hosted Page, where the subscriber can mention his referrer's email address. Later when a new subscription is created, we will be using our Custom Function Workflow to raise a credit note for that referrer.
The below explained custom function does the same.
You can refer to the code in this GitHub link. The code is written in Deluge Script which can be easily understood by non-programmers.
1) Paste your authtoken, Custom Field's label and incentive amount in their corresponding variables.
2) Once a new subscription is created, we can check if a referrer Email id is present. If it is present, we use that Email ID to get the customer (Referrer) details from our database.
3) Once the Referrer is identified, a credit note will be raised for the mentioned incentive amount.
4) In case, if the email address is not present in our database, the admin of the organization will be intimated with an Email regarding this.
Getting started with the Custom Functions:
1. Go to Settings -> Automation -> Custom Functions.
2. Create a new Custom Function. Provide a name for the function.
3. Choose the module and event according to your need.
4. Copy the code which was given above. Do the necessary changes that are required.
5. Save the Custom Function and you are good to go.
Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask!