@choochmeque/tauri-plugin-iap-api 0.1.10 → 0.2.0
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/LICENSE +21 -0
- package/README.md +34 -4
- package/dist-js/index.cjs +15 -0
- package/dist-js/index.d.ts +16 -0
- package/dist-js/index.js +15 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 - Present Tauri Apps Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# ⚠️ WARNING: WORK IS STILL IN PROGRESS. NOT READY FOR PRODUCTION YET
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-

|
|
3
|
+
[](https://www.npmjs.com/package/@choochmeque/tauri-plugin-iap-api)
|
|
4
|
+
[](https://crates.io/crates/tauri-plugin-iap)
|
|
5
|
+
[](LICENSE)
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
# Tauri Plugin IAP
|
|
@@ -15,6 +16,7 @@ A Tauri plugin for In-App Purchases (IAP) with support for subscriptions on both
|
|
|
15
16
|
- Purchase subscriptions with platform-specific features
|
|
16
17
|
- Restore previous purchases
|
|
17
18
|
- Get purchase history
|
|
19
|
+
- Check product ownership and subscription status
|
|
18
20
|
- Real-time purchase state updates via events
|
|
19
21
|
- Automatic transaction verification (iOS)
|
|
20
22
|
- Support for introductory offers and free trials
|
|
@@ -75,7 +77,9 @@ import {
|
|
|
75
77
|
purchase,
|
|
76
78
|
restorePurchases,
|
|
77
79
|
acknowledgePurchase,
|
|
78
|
-
|
|
80
|
+
getProductStatus,
|
|
81
|
+
onPurchaseUpdated,
|
|
82
|
+
PurchaseState
|
|
79
83
|
} from 'tauri-plugin-iap-api';
|
|
80
84
|
|
|
81
85
|
// Initialize the billing client
|
|
@@ -84,6 +88,15 @@ await initialize();
|
|
|
84
88
|
// Get available products
|
|
85
89
|
const products = await getProducts(['subscription_id_1', 'subscription_id_2'], 'subs');
|
|
86
90
|
|
|
91
|
+
// Check if user owns a specific product
|
|
92
|
+
const status = await getProductStatus('subscription_id_1', 'subs');
|
|
93
|
+
if (status.isOwned && status.purchaseState === PurchaseState.PURCHASED) {
|
|
94
|
+
console.log('User has active subscription');
|
|
95
|
+
if (status.isAutoRenewing) {
|
|
96
|
+
console.log('Subscription will auto-renew');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
87
100
|
// Purchase a subscription or in-app product
|
|
88
101
|
// On Android: use the offer token from subscriptionOfferDetails
|
|
89
102
|
// On iOS: offer token is not used
|
|
@@ -163,6 +176,23 @@ Returns the complete purchase history.
|
|
|
163
176
|
### `acknowledgePurchase(purchaseToken: string)`
|
|
164
177
|
Acknowledges a purchase (required on Android within 3 days, no-op on iOS).
|
|
165
178
|
|
|
179
|
+
### `getProductStatus(productId: string, productType: 'subs' | 'inapp' = 'subs')`
|
|
180
|
+
Checks the ownership and subscription status of a specific product.
|
|
181
|
+
|
|
182
|
+
**Parameters:**
|
|
183
|
+
- `productId`: The product identifier to check
|
|
184
|
+
- `productType`: Type of product ('subs' or 'inapp'), defaults to 'subs'
|
|
185
|
+
|
|
186
|
+
**Returns:** ProductStatus object with:
|
|
187
|
+
- `productId`: Product identifier
|
|
188
|
+
- `isOwned`: Whether the user currently owns the product
|
|
189
|
+
- `purchaseState`: Current state (PURCHASED=0, CANCELED=1, PENDING=2)
|
|
190
|
+
- `purchaseTime`: When the product was purchased (timestamp)
|
|
191
|
+
- `expirationTime`: (subscriptions only) When the subscription expires
|
|
192
|
+
- `isAutoRenewing`: (subscriptions only) Whether auto-renewal is enabled
|
|
193
|
+
- `isAcknowledged`: Whether the purchase has been acknowledged
|
|
194
|
+
- `purchaseToken`: Token for the purchase transaction
|
|
195
|
+
|
|
166
196
|
### `onPurchaseUpdated(callback: (purchase: Purchase) => void)`
|
|
167
197
|
Listens for purchase state changes.
|
|
168
198
|
|
|
@@ -195,4 +225,4 @@ Listens for purchase state changes.
|
|
|
195
225
|
|
|
196
226
|
## License
|
|
197
227
|
|
|
198
|
-
MIT
|
|
228
|
+
[MIT](LICENSE)
|
package/dist-js/index.cjs
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
var core = require('@tauri-apps/api/core');
|
|
4
4
|
var event = require('@tauri-apps/api/event');
|
|
5
5
|
|
|
6
|
+
exports.PurchaseState = void 0;
|
|
7
|
+
(function (PurchaseState) {
|
|
8
|
+
PurchaseState[PurchaseState["PURCHASED"] = 0] = "PURCHASED";
|
|
9
|
+
PurchaseState[PurchaseState["CANCELED"] = 1] = "CANCELED";
|
|
10
|
+
PurchaseState[PurchaseState["PENDING"] = 2] = "PENDING";
|
|
11
|
+
})(exports.PurchaseState || (exports.PurchaseState = {}));
|
|
6
12
|
async function initialize() {
|
|
7
13
|
return await core.invoke('plugin:iap|initialize');
|
|
8
14
|
}
|
|
@@ -40,6 +46,14 @@ async function acknowledgePurchase(purchaseToken) {
|
|
|
40
46
|
},
|
|
41
47
|
});
|
|
42
48
|
}
|
|
49
|
+
async function getProductStatus(productId, productType = 'subs') {
|
|
50
|
+
return await core.invoke('plugin:iap|get_product_status', {
|
|
51
|
+
payload: {
|
|
52
|
+
productId,
|
|
53
|
+
productType,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
43
57
|
// Event listener for purchase updates
|
|
44
58
|
function onPurchaseUpdated(callback) {
|
|
45
59
|
const unlisten = event.listen('purchaseUpdated', (event) => {
|
|
@@ -51,6 +65,7 @@ function onPurchaseUpdated(callback) {
|
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
exports.acknowledgePurchase = acknowledgePurchase;
|
|
68
|
+
exports.getProductStatus = getProductStatus;
|
|
54
69
|
exports.getProducts = getProducts;
|
|
55
70
|
exports.getPurchaseHistory = getPurchaseHistory;
|
|
56
71
|
exports.initialize = initialize;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -57,10 +57,26 @@ export interface GetPurchaseHistoryResponse {
|
|
|
57
57
|
export interface AcknowledgePurchaseResponse {
|
|
58
58
|
success: boolean;
|
|
59
59
|
}
|
|
60
|
+
export declare enum PurchaseState {
|
|
61
|
+
PURCHASED = 0,
|
|
62
|
+
CANCELED = 1,
|
|
63
|
+
PENDING = 2
|
|
64
|
+
}
|
|
65
|
+
export interface ProductStatus {
|
|
66
|
+
productId: string;
|
|
67
|
+
isOwned: boolean;
|
|
68
|
+
purchaseState?: PurchaseState;
|
|
69
|
+
purchaseTime?: number;
|
|
70
|
+
expirationTime?: number;
|
|
71
|
+
isAutoRenewing?: boolean;
|
|
72
|
+
isAcknowledged?: boolean;
|
|
73
|
+
purchaseToken?: string;
|
|
74
|
+
}
|
|
60
75
|
export declare function initialize(): Promise<InitializeResponse>;
|
|
61
76
|
export declare function getProducts(productIds: string[], productType?: 'subs' | 'inapp'): Promise<GetProductsResponse>;
|
|
62
77
|
export declare function purchase(productId: string, productType?: 'subs' | 'inapp', offerToken?: string): Promise<Purchase>;
|
|
63
78
|
export declare function restorePurchases(productType?: 'subs' | 'inapp'): Promise<RestorePurchasesResponse>;
|
|
64
79
|
export declare function getPurchaseHistory(): Promise<GetPurchaseHistoryResponse>;
|
|
65
80
|
export declare function acknowledgePurchase(purchaseToken: string): Promise<AcknowledgePurchaseResponse>;
|
|
81
|
+
export declare function getProductStatus(productId: string, productType?: 'subs' | 'inapp'): Promise<ProductStatus>;
|
|
66
82
|
export declare function onPurchaseUpdated(callback: (purchase: Purchase) => void): () => void;
|
package/dist-js/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { invoke } from '@tauri-apps/api/core';
|
|
2
2
|
import { listen } from '@tauri-apps/api/event';
|
|
3
3
|
|
|
4
|
+
var PurchaseState;
|
|
5
|
+
(function (PurchaseState) {
|
|
6
|
+
PurchaseState[PurchaseState["PURCHASED"] = 0] = "PURCHASED";
|
|
7
|
+
PurchaseState[PurchaseState["CANCELED"] = 1] = "CANCELED";
|
|
8
|
+
PurchaseState[PurchaseState["PENDING"] = 2] = "PENDING";
|
|
9
|
+
})(PurchaseState || (PurchaseState = {}));
|
|
4
10
|
async function initialize() {
|
|
5
11
|
return await invoke('plugin:iap|initialize');
|
|
6
12
|
}
|
|
@@ -38,6 +44,14 @@ async function acknowledgePurchase(purchaseToken) {
|
|
|
38
44
|
},
|
|
39
45
|
});
|
|
40
46
|
}
|
|
47
|
+
async function getProductStatus(productId, productType = 'subs') {
|
|
48
|
+
return await invoke('plugin:iap|get_product_status', {
|
|
49
|
+
payload: {
|
|
50
|
+
productId,
|
|
51
|
+
productType,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
41
55
|
// Event listener for purchase updates
|
|
42
56
|
function onPurchaseUpdated(callback) {
|
|
43
57
|
const unlisten = listen('purchaseUpdated', (event) => {
|
|
@@ -48,4 +62,4 @@ function onPurchaseUpdated(callback) {
|
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
export { acknowledgePurchase, getProducts, getPurchaseHistory, initialize, onPurchaseUpdated, purchase, restorePurchases };
|
|
65
|
+
export { PurchaseState, acknowledgePurchase, getProductStatus, getProducts, getPurchaseHistory, initialize, onPurchaseUpdated, purchase, restorePurchases };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choochmeque/tauri-plugin-iap-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"author": "You",
|
|
5
6
|
"description": "A Tauri v2 plugin that enables In-App Purchases (IAP)",
|
|
6
7
|
"type": "module",
|
|
@@ -27,13 +28,12 @@
|
|
|
27
28
|
"tauri",
|
|
28
29
|
"iap"
|
|
29
30
|
],
|
|
30
|
-
"license": "MIT",
|
|
31
31
|
"bugs": {
|
|
32
32
|
"url": "https://github.com/Choochmeque/tauri-plugin-iap/issues"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Choochmeque/tauri-plugin-iap#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tauri-apps/api": "
|
|
36
|
+
"@tauri-apps/api": "^2.6.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rollup/plugin-typescript": "^12.1.4",
|