@choochmeque/tauri-plugin-iap-api 0.1.8 → 0.1.10

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.
Files changed (2) hide show
  1. package/README.md +31 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -26,13 +26,33 @@ A Tauri plugin for In-App Purchases (IAP) with support for subscriptions on both
26
26
 
27
27
  ## Installation
28
28
 
29
- Add the plugin to your Tauri project:
29
+ Install the JavaScript package:
30
+
31
+ ```bash
32
+ npm install @choochmeque/tauri-plugin-iap-api
33
+ # or
34
+ yarn add @choochmeque/tauri-plugin-iap-api
35
+ # or
36
+ pnpm add @choochmeque/tauri-plugin-iap-api
37
+ ```
38
+
39
+ Add the plugin to your Tauri project's `Cargo.toml`:
30
40
 
31
41
  ```toml
32
42
  [dependencies]
33
43
  tauri-plugin-iap = "0.1"
34
44
  ```
35
45
 
46
+ Configure the plugin permissions in your `capabilities/default.json`:
47
+
48
+ ```json
49
+ {
50
+ "permissions": [
51
+ "iap:default"
52
+ ]
53
+ }
54
+ ```
55
+
36
56
  Register the plugin in your Tauri app:
37
57
 
38
58
  ```rust
@@ -64,13 +84,13 @@ await initialize();
64
84
  // Get available products
65
85
  const products = await getProducts(['subscription_id_1', 'subscription_id_2'], 'subs');
66
86
 
67
- // Purchase a subscription
87
+ // Purchase a subscription or in-app product
68
88
  // On Android: use the offer token from subscriptionOfferDetails
69
89
  // On iOS: offer token is not used
70
- const purchaseResult = await purchase('subscription_id_1', offerToken);
90
+ const purchaseResult = await purchase('subscription_id_1', 'subs', offerToken);
71
91
 
72
- // Restore purchases
73
- const restored = await restorePurchases();
92
+ // Restore purchases (specify product type)
93
+ const restored = await restorePurchases('subs');
74
94
 
75
95
  // Acknowledge a purchase (Android only, iOS auto-acknowledges)
76
96
  await acknowledgePurchase(purchaseResult.purchaseToken);
@@ -121,18 +141,22 @@ Fetches product details from the store.
121
141
  - `formattedPrice`: Localized price string
122
142
  - `subscriptionOfferDetails`: (subscriptions only) Array of offers
123
143
 
124
- ### `purchase(productId: string, offerToken?: string)`
144
+ ### `purchase(productId: string, productType: 'subs' | 'inapp' = 'subs', offerToken?: string)`
125
145
  Initiates a purchase flow.
126
146
 
127
147
  **Parameters:**
128
148
  - `productId`: The product to purchase
149
+ - `productType`: Type of product ('subs' for subscriptions, 'inapp' for one-time purchases), defaults to 'subs'
129
150
  - `offerToken`: (Android only) The offer token for subscriptions
130
151
 
131
152
  **Returns:** Purchase object with transaction details
132
153
 
133
- ### `restorePurchases()`
154
+ ### `restorePurchases(productType: 'subs' | 'inapp' = 'subs')`
134
155
  Queries and returns all active purchases.
135
156
 
157
+ **Parameters:**
158
+ - `productType`: Type of products to restore ('subs' or 'inapp'), defaults to 'subs'
159
+
136
160
  ### `getPurchaseHistory()`
137
161
  Returns the complete purchase history.
138
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choochmeque/tauri-plugin-iap-api",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "author": "You",
5
5
  "description": "A Tauri v2 plugin that enables In-App Purchases (IAP)",
6
6
  "type": "module",