LifeHacks, Coliving & Permaculture 🌱

UPDATE 06 April 2021 : We are quite deceived by Tapfiliate because it does not support sending payouts from Tapfiliate. We do not see the interest of paying $70/mo to do it manually every month. We decided to implement our own solution.

Tapfiliate does not work out of the box with stripe checkout (client side only) and wix.

Keep in mind that this is a little bit advanced so you will need to be familiar with Wix, Javascript (node) and Stripe API.

I was accepting recurring payments with stripe checkout client side only code

My use case is classic SaaS business model : customers have a 15 days trial then pay monthly or annually.

The officials integrations does not work for me :

Main problems I faced :

  • I don't have access to stripe customer_id without running server-side code
  • tap have to run within the page and not js page code or html element because of cookies scope

Here I will explain how I successfully setup Tapfiliate with Stripe all within Wix corvid without any external dependencies :

  1. Configure Stripe Checkout button to return a session_id
  2. Enable Wix Corvid (developer mode)
  3. Fetch customer_id from Stripe API using wix back-end code
  4. Redirect to same page with ?customer_id=cus_xxxxx
  5. Use that URL parameter to tap('trial', cus_xxxxxx)

Configure Stripe Checkout to return session_id

Unfortunately Stripe does not return a customer_id on successful payment or even trial.
First thing to do is to create/update your checkout js success_url to return a session_id

As an HTML element on a wix page
<!-- Load Stripe.js on your website. -->
<script src=""></script>

<!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. -->
  style="background-color:#6772E5;color:#FFF;padding:19px 82px;border:0px solid rgb(127, 0, 0);border-radius:5px;border-color:#6772E5;font-size:1.2em;cursor:pointer"
  onmouseout="'#6772E5';'#6772E5;';return true;"

<div id="error-message"></div>

(function() {
  var stripe = Stripe('pk_live_my-key');

  var checkoutButton = document.getElementById('checkout-button-plan_id');
  checkoutButton.addEventListener('click', function () {
    // When the customer clicks on the button, redirect
    // them to Checkout.
      items: [{plan: 'my-plan-id', quantity: 1}],
      locale: "fr",
      // Do not rely on the redirect to the successUrl for fulfilling
      // purchases, customers may not always reach the success_url after
      // a successful payment.
      // Instead use one of the strategies described in
      successUrl: '{CHECKOUT_SESSION_ID}',
      cancelUrl: '',
    .then(function (result) {
      if (result.error) {
        // If `redirectToCheckout` fails due to a browser or network
        // error, display the localized error message to your customer.
        var displayError = document.getElementById('error-message');
        displayError.textContent = result.error.message;

πŸ‘† Complete script

Now that Stripe returns a session_id you will be able to get a customer_id with server-side code.

Enable Wix Corvid

This mode is for developer but it is awesome, you can :

  • run backend node js code like 3rd party API calls...
  • run front end code like updating the code

Everything in ES6.

on the left you can see Public, Back-end and node_modules!

Setup a thank you page

We want to fetch our customer_id by using the session_id returned by stripe on successful payment.

This is how my page look like after a subscription creation. Notice the URL parameter
Showing spinner and updating the text to ask the client to wait until we redirect to /success?customer_id=cus_xxx

Full code:

// API Reference:
// Code Examples:
import wixLocation from 'wix-location';
import { getCustomer } from 'backend/stripe';

$w.onReady(async function () {
	if (wixLocation.query.session_id) {
		$w('#text103').html = '<h1 class="font_0" style="text-align:center;">On y est presque...</h1><h1 class="font_0" style="font-size:40px; text-align:center;"><span style="font-size:40px;"><span style="color:#777DFC;">Nous finalisons votre commande</span></span></h1></div>';
		var sessionId = wixLocation.query.session_id;
		var customer = await getCustomer(sessionId);''+ customer);
	else {
		$w('#text103').html = '<h1 class="font_0" style="text-align:center;">Merci</h1><h1 class="font_0" style="font-size:40px; text-align:center;"><span style="font-size:40px;"><span style="color:#777DFC;">Votre commande a bien Γ©tΓ© prise en compte</span></span></h1></div>';

What we just did :

  • Hide/show some waiting text / spinner
  • fetch session_id that we send to getCustomer (defined in the backend next step)
  • Redirect to /success?customer_id=cus_xxx

Stripe API in Corvid Wix back-end

  1. Install the Stripe package in node_modules

2. Add a stripe.jsw file in Back-end and write the following code :

import Stripe from 'stripe';

// Filename: backend/stripe.jsw (web modules need to have a .jsw extension)

export async function getCustomer(sessionId) {
	console.log('fetching customer....', sessionId);
	try {
	const stripe = new Stripe('rk_live_my-id');
    const session = await stripe.checkout.sessions.retrieve(sessionId);
	console.log("session-------", session);
  	return session.customer;
	} catch(error) {
	 return error;

Here we fetch the session using our Stripe API key. The API call is defined there :

Stripe API Reference - Retrieve a Session
Complete reference documentation for the Stripe API. Includes representative code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET client libraries.

Add Tapfiliate script in all the pages

Go to Parameters > Monitoring and Analytics

New Tools > Custom

  <script src="" type="text/javascript" async></script>
  <script type="text/javascript">
function getQueryParams(){var r={},n=function(r){return decodeURIComponent(r.replace(/\+/g," "))},"&");for(var e in t){var o=t[e].toString().split("=");o.length>1&&(r[n(o[0])]=n(o[1]))}return r}
      tap('create', 'my-tapfiliate-account-id', { integration: "stripe" });
      var params = getQueryParams();
      if (params.customer_id) {
        tap('trial', params.customer_id);
Copy the first step from

What this does :

  • detect if there are ref=.... and set cookies
  • if there are any customer_id it will set as trial on customer

Make sure this whole thing work you will need to create an affiliate and test everything


I would prefer to rely on webhooks rather than a thankyou page for security reasons.

In my case any customers are trial first then they are converted on Stripe only when their trial expires so I believe this won't an issue. I hope.

You've successfully subscribed to Stephane Bounmy
Welcome back! You've successfully signed in.
Great! You've successfully signed up.
Your link has expired
Success! Your account is fully activated, you now have access to all content.