How to add credits with a plan

Hey guys!

I’m new to Webflow and I think it’s fantastic so far.

I’m setting up a system with Webflow, Memberstack, and Make.

This provides a SaaS for the user, I want the user to buy a plan that gives him x amount of credits, and each time he uses the service he consumes a credit.

My question is, is there a way to have a custom field that counts the number of credits the user has purchased and then deducts a credit for each request?

If the user has no credits, he is invited to buy more credits.

I really appreciate any help you can provide.


DEBIT
Memberstack allows you to get the member id via script, so you can use that to build a “buy one” button.

That button would be a submit button on a hidden form, that triggers a webhook on Make, to check available credits. If there are enough, debit and return success. If there are not enough, return a failure.

  • Inputs: Memberstack MemberID, number credits paying
  • Outputs: Success/fail, message, and number credits remaining

You’d want to track the user credit balances somewhere, I’d recommend AirTable. Easy to report and update.

NOTE: Personally I’d build it so that you can specify the number of credits you want to debit, and default to 1. It’s just as easy, and you might have premium products later.

When a user completes a transaction, you have a success/fail response, and display the appropriate form success or failure message that Webflow lets you design.
Your fail message would invite them to buy more credits, with a link.

You can custom script that, or you can use my attributes-based tool here-

Just return a webhook response with a 200-range HTTP response code for success, or a 400+ for errors. That way you can build it like an API with different messages, e.g. member unknown, member account locked, unable to access database.

The tool will take care of displaying success / fail automatically based on the webhook response.

GETTING BALANCE
For a “you have X credits remaining” message.
You could build a second Make webhook that get that balance, or you can use the first one with a 0 credit payment request, and use the credit balance it returns.

TOP-UPS
Are you using Webflow ECommerce?

You could create some products there with credit values, and then install a webhook directly from Webflow’s API to notify a “top-up” Make automation of new orders. Here you might have to get creative to figure out how to insert the Memberstack member ID into the order data as a hidden custom field.

Pretty sure it can be done, but I haven’t tried that bit.

Thanks, Michael, I’m digesting your answer and looking forward to implementing it as soon as I finish understanding all the steps and concepts.

I have a question tho, with Webflow Users already existing, I guess I could just use the Webflow CMS to store the user info and update it accordingly, I’m I right? So I wouldn’t need to retrieve any of the MS info

No, Memberships BETA doesn’t currently have any way to retrieve the user ID, or to bind CMS items to a specific User. Someday, we hope.

1 Like