Skip to content

Commit 925d322

Browse files
committed
extend referral service rst
1 parent c4113ff commit 925d322

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

docs/referral_service.rst

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ When a referred user purchases a subscription, the `ReferralService` updates the
2626
2727
ReferralService.handle_purchase_subscription(
2828
user=user_instance,
29-
amount_paid=10000,
30-
invoice_external_id=12345
29+
amount_paid=10000, # original paid amount in cents
30+
invoice_external_id=12345 # an optional external invoice ID (e.g. chargeebe_id).
3131
)
3232
33-
.. note::
34-
35-
Field amount_paid must be in cents
3633
3734
The method updates the user's referral status and calculates the commission based on the amount paid.
3835

@@ -47,16 +44,12 @@ If a referred user requests a refund, the service updates the referral status to
4744
4845
ReferralService.handle_user_refund(
4946
user=user_instance,
50-
amount_refunded=5000,
51-
amount_paid=10000,
52-
invoice_external_id=12345
47+
amount_refunded=5000, # refunded amount in cents
48+
amount_paid=10000, # original paid amount in cents
49+
invoice_external_id=12345 # an optional external invoice ID (e.g. chargeebe_id).
5350
)
5451
5552
56-
.. note::
57-
58-
Field amount_paid and amount_refunded must be in cents
59-
6053
The method sets the referral status to `Refund` and adjusts the commission accordingly.
6154

6255
Example refund scenario:
@@ -84,4 +77,52 @@ In this case, the promoter's final commission will be $5, reflecting the amount
8477

8578
.. note::
8679

87-
It is possible for a promoter to have a negative balance if multiple refunds are processed and the refunded amounts exceed the promoter’s total earned commissions. This can occur if the promoter has already been paid for referrals, but the referred users later request refunds.
80+
It is possible for a promoter to have a negative balance if multiple refunds are processed and the refunded amounts exceed the promoter’s total earned commissions. This can occur if the promoter has already been paid for referrals, but the referred users later request refunds.
81+
82+
83+
Sending Referral Invitation Emails
84+
----------------------------------
85+
86+
The `send_referral_invitation_email` method allows promoters to send an email invitation containing a referral link.
87+
88+
- **Method**: `send_referral_invitation_email`
89+
90+
.. code-block:: python
91+
92+
ReferralService.send_referral_invitation_email(
93+
emails_to=["[email protected]"],
94+
invitation_link="http://localhost:8000/?ref=6B86B273FF",
95+
promoter_full_name="John Doe",
96+
subject="Join us!",
97+
template_path="app_name/referral_invitation.html"
98+
)
99+
100+
### Key Requirements
101+
102+
1. **Environment Variables**:
103+
104+
Make sure to set the following environment variables in your `.env` file before sending referral invitation emails:
105+
106+
.. code-block:: bash
107+
108+
BASE_REFERRAL_LINK=
109+
BASE_EMAIL=
110+
111+
These variables are necessary for generating the referral link and setting the "from" email address.
112+
113+
2. **Correct Template Path**:
114+
115+
You must correctly pass the path to the HTML email template when calling this method.
116+
117+
Example of saving an email template in Django:
118+
119+
- Full Path: `app_name/templates/app_name/referral_invitation.html`
120+
121+
.. note::
122+
123+
The referral link sent by email contains an extra param `ref-source=email` for future tracking.
124+
125+
.. code-block:: bash
126+
127+
GET http://localhost:8000/?ref=6B86B273FF&ref-source=email
128+

0 commit comments

Comments
 (0)