I have created a consumable in app purchase in iTunes connect as shown in the following figure.
After that I created a sandbox user and I verified that appid.
When I try to check the products using the following code
func requestProducts(forIds ids: Set<String>)
{
productRequest.cancel()
productRequest = SKProductsRequest(productIdentifiers: "com.iapcourse.meal")
productRequest.delegate = self
productRequest.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
self.products = response.products
print(products.count)
if products.count == 0
{
requestProducts(forIds: "com.iapcourse.meal")
}
else {
delegate?.iapProductsLoaded()
}
}
I receive zero product from the delegate method.
The status of your in-app purchases needs to be in the "Ready to Submit" stage before you can test in Sandbox. A common thing to miss is the preview image, for testing, you can upload anything you want so the meta-data is complete. Also, you need to make sure you have the "Paid Applications" agreement signed - it's not very clear anywhere in App Store connect that this is required so it's sometimes overlooked.
I really good article that goes over a checklist of everything you need to configure is: Configuring In-app Products is Hard