Wix Pricing Plans app - list all current subscriptions in velo

We’re interested in using the Wix Pricing Plans app to sell subscriptions. We need to be able to generate a list of members with currently active subscriptions in Velo. I don’t understand where the Wix Pricing Plans app stores the subscription information and how to query the subscription information. I don’t see the subscription information in the collections I’ve looked at in the Wix Editor (in Dev Mode). Or if the subscription information is in the collections I don’t understand the structure.

Where is does the Wix Pricing Plans app store subscription information and how do I query it to get a list of all members with an active subscription?

Ultimately we want to make a REST API that lists all the members with a current subscription (along with some custom data we will add).

Ahhh - the listOrders() function. I was expecting to see a new collection of subscriptions or something like that.

Thanks!

I made a function (directly from the list-orders documentation) to read the orders. I call it from a my http-functions.js and I can not seem to get the permissions correctly set up. I’ve configured the API key and wix-site-id correctly (calls to https://www.wixapis.com/pricing-plans/v2/orders with the same API key and wix-site-id work correctly).

import { Permissions, webMethod } from "wix-web-module";
import { orders } from "wix-pricing-plans-backend";

export const myListOrdersFunction = webMethod(Permissions.Anyone, async () => {
  try {
    const listedOrders = await orders.listOrders();

    return listedOrders;
  } catch (error) {
    console.log("myListOrdersFunction: caught error while trying to listOrders: ")
    console.error(error);
  }
});

The error I get is:

Details
"root":{
"insertId":"..........EAi.fa2cS4rNhqlnnxSTtB"
"timestamp":"2024-06-06T03:48:39.909Z"
"labels":{...
}
"sourceLocation":{
"file":"backend/getActiveSubscribers.web.js"
"line":27
"column":10
}
"operation":{
"id":"1717645716.037147434827230230"
"producer":"backend"
}
"jsonPayload":{
"message":"["message: ''\ndetails:\n applicationError:\n description: Forbidden\n code: FORBIDDEN\n data: {}"]"
}
"severity":"ERROR"
"receiveTimestamp":"2024-06-06T03:48:40.046Z"
}

The fix was to add “suppressAuth” option to the listOrders call:

    let options = {
      "suppressAuth" : true 
    };
    const listedOrders = await orders.listOrders(null, null, null, options);
1 Like