I’d like to create a members only page, that lists their invoices and when clicked opens the invoice to be viewed/payed.
I’m trying to work with the billing invoice collection, as suggested here…
Invoices - Velo API Reference - Wix.com
I’ve got the following server-side
import wixBillingBackend from 'wix-billing-backend';
import {invoices} from 'wix-billing-backend';
import wixData from 'wix-data';
export async function getMyInvoices() {
const returnedInvoices = await wixData.query('Billing/Invoices').find();
const firstInvoice = returnedInvoices.items[0];
const id = {
id: firstInvoice._id,
version: firstInvoice.version
};
const options = {
suppressAuth: false
};
return await invoices.createInvoicePreviewUrl(id, options);
}
Calling the function from my custom member page I get the following error…
WDE0025: The Billing/Invoices collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.
I can’t see the billing collection in “Wix App Collections” - am I doing something wrong, or is the billing backend no longer available?
1 Like
The Billing/Invoices
collection has been temporarily removed from CMS in both the Editor and Site Dashboard.
As for a temporary workaround, you can create a custom Billing Invoice collection and use the billing event handlers to populate it.
1 Like
Hi Thomas,
Thanks for the quick reply.
Its good to know I wasn’t going mad
. I don’t suppose there’s an ETA on them coming back?
I know there’s also a feature pending for adding a “My Invoices” page to the members section, which might meet my requirements, but its always good to have options to customize, and also I’m keen to do it now.
I think I understand your work-around suggestion…
I add some code to register for billing events and have that event code add the invoice to a custom collection, which I can then utilise as normal to create my members page custom content. Its a neat idea and I’ll give it a go (any code help would be great, but not essential)
I’ve a couple of questions…
- Will billing events generate for invoices I create for my customers using the Wix Admin site? As these are the only invoices I want to capture.
- Is there any way to get already existing invoices captured into my custom collection?
Thanks for the help.
Will billing events generate for invoices I create for my customers using the Wix Admin site? As these are the only invoices I want to capture.
You will be able to capture the invoice creation event regardless where it is initiated from.
Is there any way to get already existing invoices captured into my custom collection?
From my understanding there is no way to achieve this via the Billing Backend API, however if you are following the workaround, you can export your existing invoices as a CSV from the Invoice section in your site’s dashboard, and then import the CSV (making sure the data is correctly mapped) into your custom billing collection.
Unfortunately, I do not have a ETA for when this will be resolved but I recommend visiting the support page I linked previously and pressing “I experienced this issue” as it will notify you once it is solved.
2 Likes
Thanks Thomas, that’s a great answer, I’ll get working on the code.
1 Like
When will this be fixed? The work around does not get me any information on ListItems on an invoice.