I was wondering if with this new functionality, which is amazing by the way, if it is possible to have users pay to be members of your website. Essentially, you charge a one-time or a recurring monthly fee for members to create a profile and access member only information.
This has been something I have wanted to create in Wix forever, and I think this new technology will finally allow for it. I just need a little guidance on how to get started with it as I am brand new to the Wix Code beta.
If you need me to clarify what I am trying to ask or need more information, just let me know! Thank you so much!
The general idea is to maintain a list of users who have paid for your services,
and to only allow access to certain pages to these users.
the solution is based on a few parts:
add a payment option to some landing page in your site.
do this by creating a payment form and integrating it with a payment provider such as stripe.
this can be done with code:
send information to stripe when the user clicks the pay button of your form
get a token back from stripe
send that token to the backend
use stripe’s APIs to send the token back to them thus completing the transaction in a secure manner.
once the payment is done, add this user to the “paying users” list.
for any page in your site that requires payment to gain access:
in the $w.onReady() function match the user credentials to the list.
if the user is not on the list, do one of these:
use the wix location APIs to route to a special page that says “you have to be registered to view this content”
show a page-wide lightbox with the same message
etc.
we will provide a code example for this in the near future.
as for paypal - I am not sure, I don’t know their APIs that well.
but my guess is that it should be similar.
In general, the way stripe works is that when you call its API from the client you get back a token.
you then pass that token to your backend code, and call stripe’s secure API with it to complete the transaction.
keeping a list of paying users is simple -
in the backend code, just after getting the confirmation from stripe, use wix-data to insert a new record to a “paying users” collection.
that collection will hold the user’s ID in the “_owner” field since wix-data always populates this field with the ID of the user that created the record.
the record itself can have some information such as the amount paid or the package selected etc. - all per the logic you want to have in your site.
now when a user opens a restricted page, your page code should use wix-data again to look for a record that has the current user’s ID in the _owner field.
if it doesn’t find one, it means the user did not pay…
hope it helps.
p.s.
as I said we’ll provide a complete sample of this soon.
I really appreciate the help and you taking the time to explain that further. I look forward to seeing the sample soon and I am thrilled we can finally implement this feature!
Hi,
Currently we don’t have a code example for this scenario. I’ve forwarded your request to the relevant team. I’ll get back to you as soon as possible with an answer regarding this matter.
I am currently working on a solution for this exact problem, independently from Wix. I am planning to include an extensive tutorial on how to implement this on any site, and deliver support on this. You can find a demo of this feature here: https://bierleehenk.wixsite.com/paid-membership-demo/
Tal,
Thank you for your response. However, with all due respect - I have often seen in the last 3 months that no response comes back from the relevant team. I hope this time would be different.
Henk,
Kudos to your effort and looking forward to it.