@choochmeque/tauri-plugin-iap-api 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ⚠️ WARNING: WORK IS STILL IN PROGRESS. NOT READY FOR PRODUCTION YET
2
2
 
3
- [![npm version](https://badge.fury.io/js/@choochmeque%2Ftauri-plugin-iap-api.svg)](https://badge.fury.io/js/@choochmeque%2Ftauri-plugin-iap-api)
3
+ ![NPM Version](https://img.shields.io/npm/v/@choochmeque%2Ftauri-plugin-iap-api)
4
4
  ![Crates.io Version](https://img.shields.io/crates/v/tauri-plugin-iap)
5
5
 
6
6
 
@@ -64,13 +64,13 @@ await initialize();
64
64
  // Get available products
65
65
  const products = await getProducts(['subscription_id_1', 'subscription_id_2'], 'subs');
66
66
 
67
- // Purchase a subscription
67
+ // Purchase a subscription or in-app product
68
68
  // On Android: use the offer token from subscriptionOfferDetails
69
69
  // On iOS: offer token is not used
70
- const purchaseResult = await purchase('subscription_id_1', offerToken);
70
+ const purchaseResult = await purchase('subscription_id_1', 'subs', offerToken);
71
71
 
72
- // Restore purchases
73
- const restored = await restorePurchases();
72
+ // Restore purchases (specify product type)
73
+ const restored = await restorePurchases('subs');
74
74
 
75
75
  // Acknowledge a purchase (Android only, iOS auto-acknowledges)
76
76
  await acknowledgePurchase(purchaseResult.purchaseToken);
@@ -121,18 +121,22 @@ Fetches product details from the store.
121
121
  - `formattedPrice`: Localized price string
122
122
  - `subscriptionOfferDetails`: (subscriptions only) Array of offers
123
123
 
124
- ### `purchase(productId: string, offerToken?: string)`
124
+ ### `purchase(productId: string, productType: 'subs' | 'inapp' = 'subs', offerToken?: string)`
125
125
  Initiates a purchase flow.
126
126
 
127
127
  **Parameters:**
128
128
  - `productId`: The product to purchase
129
+ - `productType`: Type of product ('subs' for subscriptions, 'inapp' for one-time purchases), defaults to 'subs'
129
130
  - `offerToken`: (Android only) The offer token for subscriptions
130
131
 
131
132
  **Returns:** Purchase object with transaction details
132
133
 
133
- ### `restorePurchases()`
134
+ ### `restorePurchases(productType: 'subs' | 'inapp' = 'subs')`
134
135
  Queries and returns all active purchases.
135
136
 
137
+ **Parameters:**
138
+ - `productType`: Type of products to restore ('subs' or 'inapp'), defaults to 'subs'
139
+
136
140
  ### `getPurchaseHistory()`
137
141
  Returns the complete purchase history.
138
142
 
package/dist-js/index.cjs CHANGED
@@ -14,16 +14,21 @@ async function getProducts(productIds, productType = 'subs') {
14
14
  },
15
15
  });
16
16
  }
17
- async function purchase(productId, offerToken) {
17
+ async function purchase(productId, productType = 'subs', offerToken) {
18
18
  return await core.invoke('plugin:iap|purchase', {
19
19
  payload: {
20
20
  productId,
21
+ productType,
21
22
  offerToken,
22
23
  },
23
24
  });
24
25
  }
25
- async function restorePurchases() {
26
- return await core.invoke('plugin:iap|restore_purchases');
26
+ async function restorePurchases(productType = 'subs') {
27
+ return await core.invoke('plugin:iap|restore_purchases', {
28
+ payload: {
29
+ productType,
30
+ },
31
+ });
27
32
  }
28
33
  async function getPurchaseHistory() {
29
34
  return await core.invoke('plugin:iap|get_purchase_history');
@@ -59,8 +59,8 @@ export interface AcknowledgePurchaseResponse {
59
59
  }
60
60
  export declare function initialize(): Promise<InitializeResponse>;
61
61
  export declare function getProducts(productIds: string[], productType?: 'subs' | 'inapp'): Promise<GetProductsResponse>;
62
- export declare function purchase(productId: string, offerToken?: string): Promise<Purchase>;
63
- export declare function restorePurchases(): Promise<RestorePurchasesResponse>;
62
+ export declare function purchase(productId: string, productType?: 'subs' | 'inapp', offerToken?: string): Promise<Purchase>;
63
+ export declare function restorePurchases(productType?: 'subs' | 'inapp'): Promise<RestorePurchasesResponse>;
64
64
  export declare function getPurchaseHistory(): Promise<GetPurchaseHistoryResponse>;
65
65
  export declare function acknowledgePurchase(purchaseToken: string): Promise<AcknowledgePurchaseResponse>;
66
66
  export declare function onPurchaseUpdated(callback: (purchase: Purchase) => void): () => void;
package/dist-js/index.js CHANGED
@@ -12,16 +12,21 @@ async function getProducts(productIds, productType = 'subs') {
12
12
  },
13
13
  });
14
14
  }
15
- async function purchase(productId, offerToken) {
15
+ async function purchase(productId, productType = 'subs', offerToken) {
16
16
  return await invoke('plugin:iap|purchase', {
17
17
  payload: {
18
18
  productId,
19
+ productType,
19
20
  offerToken,
20
21
  },
21
22
  });
22
23
  }
23
- async function restorePurchases() {
24
- return await invoke('plugin:iap|restore_purchases');
24
+ async function restorePurchases(productType = 'subs') {
25
+ return await invoke('plugin:iap|restore_purchases', {
26
+ payload: {
27
+ productType,
28
+ },
29
+ });
25
30
  }
26
31
  async function getPurchaseHistory() {
27
32
  return await invoke('plugin:iap|get_purchase_history');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choochmeque/tauri-plugin-iap-api",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "author": "You",
5
5
  "description": "A Tauri v2 plugin that enables In-App Purchases (IAP)",
6
6
  "type": "module",