RC is throwing “Must provide product parameter”
and when i send pkg it throws “must provide discount parameter” error. both discount and pkg exist.
snippet:
const offerings = await Purchases.getOfferings();
if (offerings.current?.availablePackages?.length > 0) {
const packages = offerings.current.availablePackages;
for (const pkg of packages) {
if (pkg.product && pkg.product.discounts && pkg.product.discounts.length > 0) {
const discount = pkg.product.discounts[0];
// Use the original, unmodified product and discount objects
if (discount && discount.identifier) {
try {
addLog(`Found discount for ${pkg.identifier}. Fetching offer...`);
const paymentDiscount = await Purchases.getPromotionalOffer(pkg.product, discount);
// Attach the promotional offer to the original package object
pkg.paymentDiscount = paymentDiscount;
addLog(`Successfully attached offer to ${pkg.identifier}.`);
} catch (error) {
addLog(`Error fetching promo for ${pkg.identifier}: ${error.message}`, 'error');
}
}
}
}
