def METHOD_NAME(product_config, task):
    publish_config = product_config["apps"][task["channel"]]
    target_store = task.get("target_store")
    # Determine the target store. If "target_store" isn't provided on the task payload,
    # attempt to automatically determine it by checking if the channel only supports a single
    # target - if so, then use that target store.
    if target_store:
        if not publish_config.get(target_store):
            raise ValueError('Task had `target_store` set to "{}", but the "{}" channel does not support ' "that target".format(target_store, task["channel"]))
    elif publish_config.get("google"):
        target_store = "google"
    else:
        raise ValueError("Unknown target store")
    store_config = publish_config[target_store]
    rollout_percentage = task.get("rollout_percentage")
    google_track = task.get("google_play_track", store_config["default_track"])
    google_track = _handle_legacy_google_track(google_track)
    return {
        "target_store": target_store,
        "dry_run": _google_should_do_dry_run(task),
        "certificate_alias": publish_config.get("certificate_alias"),
        "username": store_config["service_account"],
        "secret": store_config["credentials_file"],
        "package_names": publish_config["package_names"],
        "google_track": google_track,
        "google_rollout_percentage": rollout_percentage,
    }