Rewardful will automatically insert a hidden input named referral into the form, which will get submitted to your server along with
the rest of this form's data. The value will be a
UUID
representing the current referral. You'll pass this UUID parameter to Stripe in the next step.
Step 3: Add the referral UUID to Stripe Customer metadata
The referral parameter will be submitted with the rest of the form data in Step 2.
In your view function that handles the form submission, add referral
to the Stripe Customer's metadata:
# Gather params submitted with <form>
customer_params = {
'email': request.POST['email'],
'source': request.POST['stripe_token'] # Obtained with stripe.js
}
# Add the `referral` parameter from Rewardful to the Stripe customer metadata, if present.
if 'referral' in request.POST:
customer_params['metadata'] = { 'referral': request.POST['referral'] }
# Create the customer in Stripe.
stripe.Customer.create(**customer_params)
Adding the referral UUID to the Stripe customer's metadata converts the referral and associates it with the affiliate.
Whenever that customer is charged, a commission will be paid to the affiliate according to your campaign rules.
Notes:
If you already have a Stripe customer created, simply add the referral metadata by
updating the customer.
You'll also need to pass the coupon parameter to Stripe if you're using our double-sided incentives feature (coupons)
Learn more →
Refer to the
Stripe API Reference
for full documentation on creating and updating customers with Python.