How to implement a credit-based form submission system where users have to purchase tokens? Answered

Post author
Salland SEO

I was wondering If it would be possible to create something like a token/credit system so users can buy new credits. With those credits I would like to make it possible to use a form. Every form submission will cost 1 token/credit. And when your tokens are up you'll get a popup saying you need to buy new credits.

Does anyone know if this is possible, and if so would anyone wanna share with me how to do so?

Big thanks in forward!

Comments

3 comments

  • Comment author
    Posty

    Hi, 

    I had a similar situation to yours.

    Try implementing something like this:
    https://www.youtube.com/watch?v=UF9FVidUakE&ab_channel=MemberstackTeam

    In my project, if you don't have enough tokens to submit a form, a button that says "buy tokens" is shown, and if you have enough tokens "buy tokens" button" is hidden and the submit button is shown.
    This is the code I use to show/hide buttons. In my case, a submit button is shown if you have 2 or more tokens, otherwise it is hidden and "buy tokens" button is shown.

    <script>
      document.addEventListener('DOMContentLoaded', function() {
        const memberstack = window.$memberstackDom;
        memberstack.getCurrentMember()
          .then(({ data: member }) => {
            if (member && member.metaData) {
              const credits = parseInt(member.metaData.credits || 0);
              updateButtonVisibility(credits);
            } else {
              console.error('Member data or metadata not found');
            }
          })
          .catch((error) => {
            console.error('Error retrieving member data:', error);
          });
      });

      function updateButtonVisibility(credits) {
        console.log('Credits:', credits); // Debugging line

        const buttonWithCredits = document.getElementById('buttonWithCredits');
        const buttonWithoutCredits = document.getElementById('buttonWithoutCredits');

        if (!buttonWithCredits || !buttonWithoutCredits) {
          console.error('Buttons not found');
          return;
        }

        if (credits >= 2) {
          buttonWithCredits.style.display = 'block';
          buttonWithoutCredits.style.display = 'none';
        } else {
          buttonWithCredits.style.display = 'none';
          buttonWithoutCredits.style.display = 'block';
        }
      }
    </script>

    I hope this helps :)

    0
  • Comment author
    Niket Kumar

    Hey there Salland SEO

    Yes, you definitely can do this using Make.com
    Duncan, has already made a video about it to understand how exactly the credit system is going to work.

    You can find the video here - https://docs.memberstack.com/hc/en-us/articles/16711820872091--Code-Credit-System-with-Make-com-Webflow

    Once you have setup the credit system, you can then play around with gated content and other features of memberstack logics to make the user able to submit only if they have certain credits left.

    Let me know if this gave you some idea about the credit system and it's paid form submission. 

    Thanks.

    0
  • Comment author
    Niket Kumar

    Hey Salland SEO! Seems like there hasn't been any response to my my reply. I'm going to consider this question resolved. If you need further 1on1 support, you can post a new question at hiophelia.com

    0

Please sign in to leave a comment.