tauri-plugin-iap 0.9.1

A Tauri v2 plugin that enables In-App Purchases (IAP)
Documentation
// Linux is unsupported — every method is a stub that returns `Err`.

use serde::de::DeserializeOwned;
use tauri::{AppHandle, Runtime, plugin::PluginApi};

use crate::models::{
    GetProductsResponse, GetPurchaseHistoryResponse, ProductStatus, Purchase, PurchaseRequest,
    RestorePurchasesResponse,
};

#[allow(clippy::unnecessary_wraps)]
pub fn init<R: Runtime, C: DeserializeOwned>(
    app: &AppHandle<R>,
    _api: &PluginApi<R, C>,
) -> crate::Result<Iap<R>> {
    Ok(Iap(app.clone()))
}

/// Access to the iap APIs.
pub struct Iap<R: Runtime>(AppHandle<R>);

#[allow(clippy::unused_async, clippy::unused_self)]
impl<R: Runtime> Iap<R> {
    pub async fn get_products(
        &self,
        _product_ids: Vec<String>,
        _product_type: String,
    ) -> crate::Result<GetProductsResponse> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub async fn purchase(&self, _payload: PurchaseRequest) -> crate::Result<Purchase> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub async fn restore_purchases(
        &self,
        _product_type: String,
    ) -> crate::Result<RestorePurchasesResponse> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub fn get_purchase_history(&self) -> crate::Result<GetPurchaseHistoryResponse> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub async fn acknowledge_purchase(&self, _purchase_token: String) -> crate::Result<()> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub async fn consume_purchase(&self, _purchase_token: String) -> crate::Result<()> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }

    pub async fn get_product_status(
        &self,
        _product_id: String,
        _product_type: String,
    ) -> crate::Result<ProductStatus> {
        Err(crate::Error::from(std::io::Error::other(
            "IAP is not supported on this platform",
        )))
    }
}