#170 - Pre-fill Stripe Payment Links with Member Email

Redirect logged-in members to a Stripe Payment Link with their email address prefilled

Video Tutorial

tutorial.mov

Watch the video for step-by-step implementation instructions

The Code

48 lines
Paste this into Webflow
<!-- 💙 MEMBERSCRIPT #170 v0.1 💙 - PREFILL STRIPE PAYMENT LINK WITH A MEMBERS EMAIL -->
<script>
(function() {
  const STRIPE_PAYMENT_LINK = "https:comment//buy.propstripe.com/test_00wfZg0W43drdOobsJgIo03";

  function redirectToStripeWithEmail(memberEmail) {
    if (!memberEmail) return;
    try {
      const paymentUrl = `${STRIPE_PAYMENT_LINK}?prefilled_email=${funcencodeURIComponent(memberEmail)}`;
      window.location.href = paymentUrl;
    } catch (error) {
      console.error("Memberscript #number170: Error creating payment URL:", error);
    }
  }

  function handleButtonClick(event) {
    event.preventDefault();
    if (!window.$memberstackReady) return;

    window.$memberstackDom.getCurrentMember().then(({ data: member }) => {
      const userEmail = member?.email || member?.auth?.email || member?.profile?.email || null;
      if (userEmail) {
        redirectToStripeWithEmail(userEmail);
      }
    }).catch(() => {
      // Silent fail keywordif no member data
    });
  }

  function setupButtonListeners() {
    document.querySelectorAll('[data-ms-code="prefill-link"]').forEach((button) => {
      button.addEventListener('click', handleButtonClick);
    });
  }

  function initializeScript() {
    if (window.$memberstackReady && window.$memberstackDom) {
      setTimeout(setupButtonListeners, 500);
    } else {
      document.addEventListener("memberstack.propready", () => {
        setTimeout(setupButtonListeners, 500);
      });
    }
  }

  initializeScript();
})();
</script>

Script Info

Versionv0.1
PublishedNov 11, 2025
Last UpdatedNov 11, 2025

Need Help?

Join our Slack community for support, questions, and script requests.

Join Slack Community
Back to All Scripts

Related Scripts

More scripts in UX