If you’re using a payment provider (e.g. WooCommerce, GoHighLevel) and not Stripe directly, please refer to other integrations.
After signing up and selecting Stripe as your payment provider, you need to do a few things before you can start using Afficone.
Connect your Stripe Account
After signing up selecting Stripe as your payment provider, click the Connect with Stripe button. This will lead you to a Stripe-hosted page where you can select the Stripe Account you want to use for this integration.
Install our tracking script on your website
In order to track affiliate clicks, you have to add our <script> tag to all of your website’s pages.
For example, if you have a landing page at example.com , but your billing page is at app.example.com , you have to add the script to both of these pages.
Installation Add the Afficone tracking script to your website.
Integrate your Stripe’s payment system
Depending on how you handle payments on your side, you might have to add some additional code on your backend.
Client Checkout
Server Checkout
Payment Intents
Payment Links
Buy Buttons
If you’re using client-based Stripe checkouts, you have to add the clientReferenceId property to your checkout configuration. < script src = "https://js.stripe.com/v3/" ></ script >
stripe . redirectToCheckout ({
success_url: 'https://example.com/success' ,
mode: 'payment' | 'setup' | 'subscription' ,
line_items: [
// The items being purchased
],
clientReferenceId: window . Afficone . referral ?? null
});
On the client, the affiliate’s referral code is stored in the window.Afficone.referral property. const stripe = require ( 'stripe' )( 'YOUR_API_KEY' );
const session = await stripe . checkout . sessions . create ({
success_url: 'https://example.com/success' ,
mode: 'payment' | 'setup' | 'subscription' ,
line_items: [
// The items being purchased
],
customer_creation: "always" // Required to be "always"
clientReferenceId : "[REFERRAL_CODE]" // Pass this from the browser
});
This is a very specific use-case. If you’re using Stripe checkout or Stripe invoices, you don’t have to use this approach.
On the client, the affiliate’s referral code is stored in the window.Afficone.referral property. const stripe = require ( 'stripe' )( 'YOUR_API_KEY' );
const paymentIntent = await stripe . paymentIntents . create ({
amount: 20 ,
currency: 'usd' ,
automatic_payment_methods: {
enabled: true
},
metadata: {
_afficoneRef: "[REFERRAL_CODE]" // Pass this from the browser
}
});
When creating a payment link, make sure to check Save payment details for future use .
If you’re creating it via API, set customer_creation: "always"
The Afficone tracking script will automatically insert the client_reference_id parameter in all <a> elements containing a payment link. When creating a buy button, make sure to check Save payment details for future use .
If you’re creating it via API, set customer_creation: "always"
The Afficone tracking script will automatically insert the client_reference_id parameter in all <stripe-buy-button> elements.
Offering free trials?
If you’re creating Stripe customers via API (that’s usually the case when offering a free trial), you have to set some customer metadata manually.
This is done by specifying an _afficoneRef property in the metadata object when creating a customer:
const stripe = require ( 'stripe' )( '[Your API key]' );
const customer = await stripe . customers . create ({
metadata: {
_afficoneRef: '[Referral Code]' ,
}
});
You can pass the referral code from the browser to your backend - it’s located in window.Afficone.referral.