I’m adding iOS Introductory Offers, and I would like to test before going live. However, when following the guide in the docs, the `discounts` field on the product is an empty array. How do I test this introductory offer before going live?
Example of the code I’m using for reference:
const purchaseDiscountedIOSPackage = async (purchasePackage) => {
const product = purchasePackage.product;
const discount = product.discounts?.[0];
// product.discounts is empty
if (!discount) {
throw new Error('No discount found on producct');
}
const paymentDiscount = await Purchases.getPromotionalOffer(product, discount);
if (!paymentDiscount) {
throw new Error('No payment discount');
}
try {
const purchaseMade = await Purchases.purchaseDiscountedPackage(pkg, paymentDiscount);
return purchaseMade.customerInfo;
} catch (e) {
if (!e.userCancelled) {
throw e;
} else {
throw new Error('ignore');
}
}
};
const purchase = async () => {
const offering = (await Purchases.getOfferings()).current;
const package = offering.availablePackages[0];
if (package) {
await purchaseDiscountedIOSPackage(package);
}
};