II'm using Corvid code to work with my Moonclerk API to display how many people are subscribed to our service. It works great in the Wix editor, but when we hit Publish, it doesn't work on the actual site. Does anyone know why this might be?
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,blur_3,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Why is most problems solved by changing permissions 😉
If all your important info like API keys are in your backend jsw file, then you should be okay.
https://support.wix.com/en/article/corvid-security-considerations
https://support.wix.com/en/article/corvid-about-web-module-permissions
Although, note that it states on the latter link...
By default, permissions are granted to Anyone for all the functions in your Web Module.
Is it for site members only or for all users, if it is just for site members then you can possibly look at changing it to suit from anyone.
Ah, I believed I fixed it, backend call permissions were set to Admin only. I set it to Anyone and it works now. This doesn't expose my API key to everyone, does it?
This code updates the displayed number of subscribers we have. It works in Preview mode, but not when we hit Publish.
The strange this is it USED to work in published mode, but doesn't anymore.
// For full API documentation, including code examples, visit https://wix.to/94BuAAs import { getPatreenos, getMonthlyPayments } from 'backend/moonclerkModule.jsw'; const donationCalculator = function(totalMonthlyPayments) { let donationAmount = parseInt(totalMonthlyPayments, 10); // TODO factor in ~20% shipping cost here donationAmount *= 0.05; return donationAmount; } const abilityToPayRentCalculator = function(totalMonthlyPayments) { let progressAmount = parseInt(totalMonthlyPayments, 10); // deduct 2.9% + 30¢ of every transaction. e.g. $2.61 of every $3 subscription. // will need to do more specifiic calcuation by parsing each payment amount, // keeping track of the tiers purchased, and then applying to those accordingly // e.g. progressAmount = $3 transaction minus 38.7c) // Maybe average it out for now to set a deductable // TODO factor in ~20% shipping cost here // wix progressBar already has a target value // let progressAmountPercentage = progressAmount/1500 * 100; // return progressAmountPercentage; return progressAmount; } $w.onReady(function () { // Get number of Patreenos getPatreenos() .then(function(patreenosCustomers) { $w("#text13").text = patreenosCustomers.customers.length.toString(); }); // Get monthly payment amount getMonthlyPayments() .then(function(monthlyPayments) { if (monthlyPayments) { let totalMonthlyPayments = 0; for(let payments in monthlyPayments.payments) { let eachPayment = monthlyPayments.payments[payments].amount; totalMonthlyPayments += eachPayment; } // convert to dollars totalMonthlyPayments = ((totalMonthlyPayments/100).toFixed(2)); let donationAmount = donationCalculator(totalMonthlyPayments); donationAmount = donationAmount.toFixed(2); $w("#text19").text = ('$' + donationAmount).toString(); $w("#text20").text = ('$' + donationAmount).toString(); let progressAmount = abilityToPayRentCalculator(totalMonthlyPayments); $w("#progressBar1").value = progressAmount; } else { $w("#text19").text = ":(" $w("#text20").text = ":(" } }) });
Would help if you add here any code that you have used for the page that does not work and any pics that you think will help etc.
However, check how and where you are using the API as it is read only.
https://github.com/moonclerk/developer/blob/master/api/README.md
This is a READ ONLY REST-style API that uses JSON for serialization and an API key for authentication.
Assuming that you have read about using Wix Fetch or Wix HTTP Functions for this.
https://www.wix.com/corvid/reference/wix-fetch.html
https://support.wix.com/en/article/corvid-accessing-third-party-services-with-the-fetch-api
https://www.wix.com/corvid/reference/wix-http-functions.html
https://support.wix.com/en/article/corvid-exposing-a-site-api-with-http-functions
Corvid Example.
https://www.wix.com/corvid/forum/wix-tips-and-updates/example-myapi-and-myapiclient
How to Use HTTP Functions to Expose Your Site's API | Corvid by Wix
Also, if you use datasets with your setup, tehn make sure that you sync them as in editor/preview you are using sandbox, whereas in published site the users are using the live version.
https://support.wix.com/en/article/syncing-data-between-sandbox-and-live-database-collections
Finally, as it is Moonclerk API and not a Wix product, you might be best to go through MoonClerk own support about it too.
They do have their own page for integrating it into Wix, however it is through html and not their API.
https://www.moonclerk.com/wix-moonclerk-setting-up-recurring-payments/
Although note that you can use Stripe too.
http://help.moonclerk.com/en/collections/12830-accepting-payments
Of which Wix has already got a fully working example set up here.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-stripe-payment-processing