This code references this blog post IAP2 - Medium
This is an example Ionic application with the full code for configuring and buying a product. This will only work in an emulator, and it will also fail because you need to edit a few pieces with your google and apple product id's, as well as your google play store code in config.xml