I managed to implement this using a Google Play Api and uploading the products to the playstore dynamically/programmatically.
First I used PHP since I am using Laravel for my backend REST API. It is up to you to choose you own. I will installed the google/apiclient
library using composer
using composer require google/apiclient
https://developers.google.com/android-publisher/api-ref/inappproducts
https://developers.google.com/android-publisher/api-ref/inappproducts/insert
A sample product could be uploaded as such:
Step1: You will need to authenticate to the service. By using a service json file or Auth oath if you prefer. In my case I used the service json file and enabled the Google Play API in my GCP console.
Step2: You need an sku(unique) refer to the docs and see the required format
Step3: You need to set a Price(micros) you can use https://github.com/Torann/laravel-currency to convert from one currency to another which I used in this case to obtain my currency based on the default currency of the Store(In app products) NB: The currencies must match else you will get an error.
Step4: You need to set Listings which are basically the title/descriptions under that your app needs for translations purposes
$client = new Google_Client();
$client->setAuthConfig(storage_path('service_account.json'));
// You have to add this scope so it knows it is in app billing store
$client->addScope('https://www.googleapis.com/auth/androidpublisher');
$service = new Google_Service_AndroidPublisher($client);
$body = new \Google_Service_AndroidPublisher_InAppProduct();
$body->setSku("unique_sku_here");
$body->setPackageName('android_app_package_name'); // e.g com.example.in_app_test
//1.00 USD = 1,000,000 Microns.
// Create a new price object
$price = new \Google_Service_AndroidPublisher_Price();
$price->setCurrency('USD');
//Using **torann/currency** library to convert from one currency to another
$new_price = intval(currency("1000", $from = "EUR", $to = "USD", false));
$price->priceMicros = $new_price * 1000000;
$body->setDefaultPrice($price);
// Setting the default language
$body->defaultLanguage = "en_US";
$body->setListings([
'en_US' => [
'title' => 'Product Title',
'description' => "Product Description here"
]
]);
$purchase = $service->inappproducts->insert(
'android_app_package_name',
$body,
[
'autoConvertMissingPrices' => true,
]);
$purchase->setStatus(true); // Always set this to mark the product active on the GPlay console.
With this you will have a return of a successful product upload.
Cheers. Feel free to comment should you have any blockers, I would be happy to clarify.