#Example #Stripe #Payment #Router #WebModules #ServerSide #backend #3rdPartyServices #fetch #suppressAuth #Permissions #Repeater #DynamicPages #SharingBeers
Demonstrates
-
Web modules - server-side (backend) code
-
Accessing 3rd Party Services (using backend function)
-
Calling Server-side Code from the Front-end with Web Modules
-
Routers - for static and dynamic pages
-
fetch() in the wix-fetch API
-
Repeater (for list of items)
-
Dynamic pages
Required for this example
In order to run this example, you will need a Stripe account to supply your own Stripe API keys .
Links for this example
About this example
This app demonstrates different levels of user access:
-
All visitors to the site have access to the FREE page.
-
Visitors who have signed up, and have logged in, also have access to the FREEMIUM page.
-
Paid visitors (payment made from the PAYMENT page) have access to the PREMIUM page and to premium items on the RECIPES page.
To allow repeated testing of different access levels, the user can log out and clear pay on the HOME page.
Note : The wix-users API is only partially functional when previewing a site and causes page navigation issues when running a site in Preview mode. View a published version of your site for complete functionality.
The PAYMENT page is used to test the interface with the Stripe payment processing system. Click on the Fill test data button to automatically fill the fields with valid Stripe test values. Click on the Pay button, and the form first encodes the credit card details and calls the Stripe public API to create a Stripe payments token. Using the token, the form calls the backend stripeProxy module to complete the Stripe transaction. After the payment request is submitted, if the transaction is successful, the Charge ID response from Stripe is displayed. (This would not normally be displayed on a live system.) If an error occurred, the returned error type is displayed. Transactions can be viewed under Payments in your Stripe account dashboard. Once you are satisfied that the Stripe interface works correctly in your site, you can replace the test keys with live keys.
Since all access to the Members database collection is in backend code, we are able to set the collection Permissions to Private Data to provide a high level of security.
Backend code is able to override the strict permissions and gain access to the collection by using the suppressAuth option.
The ABOUT page has a button for opening a sitemap of the example in a separate tab/window.