Unable to Retrieve Active Paid Plans via Velo Pricing Plans V2 API (managementListOrders Returns Undefined)

Question:
From backend Velo code (a .jsw module), I want to retrieve and inspect any “ACTIVE” subscription orders tied to a given memberId so that I can conditionally enable site features for paying subscribers.
Product:
Wix Studio Editor / Velo

What are you trying to achieve:
I need to programmatically determine, from backend Velo code, whether a given site member has an active Pricing Plan subscription so that I can enable or restrict features (e.g., the “Connect” button) based on their subscription status.

What have you already tried:

  • Installed and published the Paid Plans (Pricing Plans) app in Wix Studio.
  • Created a backend file (backend/userUtils.jsw) and attempted multiple imports:
  • import { orders } from "wix-pricing-plans-backend"orders undefined / listOrders not found.
  • import { orders } from "wix-pricing-plans-v2" → module not found.
  • import { orders } from "wix-pricing-plans.v2"orders undefined / managementListOrders not found.
  • Followed documentation examples (using filter: [{ field:"memberId",… }], orderStatuses: ["Active"], and { suppressAuth: true }), but every call either threw “undefined” errors or returned an empty array despite an active subscription existing in the Dashboard.

// backend/userUtils.jsw
import wixData from “wix-data”;
// ← Import the V2 Pricing Plans package:
import wixPricingPlansV2 from “wix-pricing-plans.v2”;

/**

  • Given a member’s email, returns an object:
  • {
  • found: Boolean,        // true if that email is a registered member
    
  • memberId: String|null, // the Wix Member ID (or null if not found)
    
  • hasActivePlan: Boolean // true if ≥1 ACTIVE subscription order exists
    
  • }
    */
    export async function getMemberWithActivePlanByEmail(email) {
    console.log(“:magnifying_glass_tilted_left: Looking up member by email:”, email);

// 1) Find the member record by loginEmail
let memberResult;
try {
memberResult = await wixData
.query(“Members/PrivateMembersData”)
.eq(“loginEmail”, email) // “loginEmail” is the correct field
.limit(1)
.find({
suppressAuth: true, // run as site owner
suppressHooks: true
});
} catch (err) {
console.error(“:cross_mark: Error querying Members/PrivateMembersData:”, err);
throw new Error(“Failed to query member by email”);
}

if (!memberResult.items.length) {
// No member with that email
console.log(“:information_source: No member found for:”, email);
return {
found: false,
memberId: null,
hasActivePlan: false
};
}

const member = memberResult.items[0];
const memberId = member._id;
console.log(“:white_check_mark: Found member ID:”, memberId);

// 2) Use V2’s managementListOrders() to fetch Active subscription orders
let activeOrders = ;
try {
// The V2 call lives under wixPricingPlansV2.orders.managementListOrders
const listResult = await wixPricingPlansV2.orders.managementListOrders(
{
filter: [
{ field: “memberId”, operator: “eq”, value: memberId }
],
orderStatuses: [“Active”] // only active subscriptions
},
null, // no custom sort
null, // no custom pagination
{ suppressAuth: true } // run as site owner
);
// listResult.items is an array of matching orders
activeOrders = Array.isArray(listResult.items)
? listResult.items
: ;
console.log(“:white_check_mark: Retrieved ACTIVE orders:”, activeOrders);
} catch (err) {
console.error(“:cross_mark: Error calling managementListOrders:”, err);
// If the Pricing Plans API fails, assume no active plan
return {
found: true,
memberId,
hasActivePlan: false
};
}

// 3) If activeOrders is non‐empty, the user has an ACTIVE subscription
const hasActivePlan = activeOrders.length > 0;
console.log(“:information_source: hasActivePlan =”, hasActivePlan, “for memberId:”, memberId);

return {
found: true,
memberId,
hasActivePlan
};
}

Additional information:
I got the error : :cross_mark: Error calling managementListOrders: Cannot read properties of undefined (reading ‘orders’)

Is there any particular reason why you are fetching a user’s active plan from the backend? Your code is visually hard to debug since you haven’t formatted it correctly using the </> button.

Refer to my code in this post that returns a list of all active pricing plan orders placed by a user, without using any backend code:

In the above example, the code returns "ACTIVE" or "NA" depending on the subscription status. This will make it much easier for you to enable / disable buttons and other elements all from the frontend itself based on the result of the function.

However, that approach only works for logged-in users. In our case:

I need to run from the backend.
The use case :

  • we have a button on a custom page.
  • The page is accessible by the public.
  • If the member doesn’t purchase the service. It will not be enable.
  • Therefore, the solution you provide doesn’t work for me. you solution is for login user.

I have my script below :

// backend/userUtils.jsw

import wixData from “wix-data”;
// Import the V2 Pricing Plans package for subscription management
import wixPricingPlansV2 from “wix-pricing-plans.v2”;

/**

  • Given a member’s email, returns an object indicating:
  • {
  • found: Boolean,        // true if that email corresponds to a registered member
    
  • memberId: String|null, // the Wix Member ID (or null if not found)
    
  • hasActivePlan: Boolean // true if ≥1 ACTIVE subscription order exists
    
  • }
  • @param {string} email – The loginEmail of the Wix Member to check.
    */
    export async function getMemberWithActivePlanByEmail(email) {
    console.log(“:magnifying_glass_tilted_left: Looking up member by email:”, email);

// ─── 1) Find the member record by loginEmail ─────────────────────────────────
let memberResult;
try {
memberResult = await wixData
.query(“Members/PrivateMembersData”)
.eq(“loginEmail”, email) // “loginEmail” is the field to match
.limit(1)
.find({
suppressAuth: true, // run this query with site-owner permissions
suppressHooks: true // skip any save/update hooks
});
} catch (err) {
console.error(“:cross_mark: Error querying Members/PrivateMembersData:”, err);
throw new Error(“Failed to query member by email”);
}

// If no member is found, return found=false immediately
if (!memberResult.items.length) {
console.log(“:information_source: No member found for:”, email);
return {
found: false,
memberId: null,
hasActivePlan: false
};
}

// Extract the member’s ID from the query result
const member = memberResult.items[0];
const memberId = member._id;
console.log(“:white_check_mark: Found member ID:”, memberId);

// ─── 2) Use V2’s managementListOrders() to fetch ACTIVE subscription orders ────
let activeOrders = ;
try {
// Call managementListOrders with a filter on memberId and only “ACTIVE” statuses
const listResult = await wixPricingPlansV2.orders.managementListOrders(
{
filter: [
{ field: “memberId”, operator: “eq”, value: memberId }
],
orderStatuses: [“ACTIVE”] // only include active subscriptions
},
null, // no custom sort needed
null, // no custom pagination needed
{ suppressAuth: true } // run with site-owner permissions
);

// Extract items array; if it's not an array, default to an empty array
activeOrders = Array.isArray(listResult.items) ? listResult.items : [];
console.log("✅ Retrieved ACTIVE orders:", activeOrders);

} catch (err) {
console.error(“:cross_mark: Error calling managementListOrders:”, err);
// If the Pricing Plans API fails, assume no active plan
return {
found: true,
memberId,
hasActivePlan: false
};
}

// ─── 3) Determine if there is ≥1 active subscription ───────────────────────────
const hasActivePlan = activeOrders.length > 0;
console.log(“:information_source: hasActivePlan =”, hasActivePlan, “for memberId:”, memberId);

// Return the result object
return {
found: true,
memberId,
hasActivePlan
};
}

If you can use my site for testing, let me know. I can provide u an email to run.

Again, your code isn’t formatted as it should be. Makes it unreadable.

Well how are you going to check if a user is an active subscriber or not without their email?

From what I can make out of your code, you are trying to check if a user with a particular email has a subscription or not. But you need the email of the user in order to perform this check. So where are you fetching the user’s email from then?


In your code, I can see:

You are using Members/PrivateData, which is a deprecated collection.

Then secondly,

You are using a .jsw file, which is also deprecated and has now been replaced by web.js


All you have provided is your backend code. Where is the frontend code that you are using on your custom page? Also how does your logic work if it is accessible by everyone and not restricted to members? If it’s open to everyone, how will you check if the user is a paid subscriber or not without their email? What happens to users who are not logged in? Will they see the button or not?

Your backend function inside userUtils.jsw takes in an email ID as a parameter and runs multiple processes one after the other to fetch the subscription status based on that. But how are you passing this email to the backend is the question. Without having a user logged into your site, how would you fetch their email to perform this check?

Provide more details about your logic flow and elaborate each flow that you’d like to achieve for a logged in, as well as a non logged in user and what would the output be for each case. Also provide screenshots or a test URL so that fellow forum users can get an idea of what you’re trying to achieve and can help you with it. And again, do not copy-paste your code directly. First in the code editor on your site, right click and click Format. Then copy the entire code and use the </> button on here and paste your code inside of it to make it neat and readable.

1 Like