@capgo/native-purchases 0.0.66 → 0.0.72
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 +376 -5
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +43 -60
- package/dist/docs.json +37 -5
- package/dist/esm/definitions.d.ts +14 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -0
- package/dist/esm/web.js +4 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +4 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +4 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/NativePurchasesPlugin.swift +34 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
<h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
In-app Purchases Made Easy
|
|
9
|
+
## In-app Purchases Made Easy
|
|
10
|
+
|
|
11
|
+
This plugin allows you to implement in-app purchases and subscriptions in your Capacitor app using native APIs.
|
|
10
12
|
|
|
11
13
|
## Install
|
|
12
14
|
|
|
@@ -23,6 +25,357 @@ Add this to manifest
|
|
|
23
25
|
<uses-permission android:name="com.android.vending.BILLING" />
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Import the plugin in your TypeScript file:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { NativePurchases } from '@capgo/native-purchases';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Check if billing is supported
|
|
37
|
+
|
|
38
|
+
Before attempting to make purchases, check if billing is supported on the device:
|
|
39
|
+
We only support Storekit 2 on iOS (iOS 15+) and google play on Android
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const checkBillingSupport = async () => {
|
|
43
|
+
try {
|
|
44
|
+
const { isBillingSupported } = await NativePurchases.isBillingSupported();
|
|
45
|
+
if (isBillingSupported) {
|
|
46
|
+
console.log('Billing is supported on this device');
|
|
47
|
+
} else {
|
|
48
|
+
console.log('Billing is not supported on this device');
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error checking billing support:', error);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Get available products
|
|
57
|
+
|
|
58
|
+
Retrieve information about available products:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const getAvailableProducts = async () => {
|
|
62
|
+
try {
|
|
63
|
+
const { products } = await NativePurchases.getProducts({
|
|
64
|
+
productIdentifiers: ['product_id_1', 'product_id_2'],
|
|
65
|
+
productType: PURCHASE_TYPE.INAPP // or PURCHASE_TYPE.SUBS for subscriptions
|
|
66
|
+
});
|
|
67
|
+
console.log('Available products:', products);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Error getting products:', error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Purchase a product
|
|
75
|
+
|
|
76
|
+
To initiate a purchase:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const purchaseProduct = async (productId: string) => {
|
|
80
|
+
try {
|
|
81
|
+
const transaction = await NativePurchases.purchaseProduct({
|
|
82
|
+
productIdentifier: productId,
|
|
83
|
+
productType: PURCHASE_TYPE.INAPP // or PURCHASE_TYPE.SUBS for subscriptions
|
|
84
|
+
});
|
|
85
|
+
console.log('Purchase successful:', transaction);
|
|
86
|
+
// Handle the successful purchase (e.g., unlock content, update UI)
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('Purchase failed:', error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Restore purchases
|
|
94
|
+
|
|
95
|
+
To restore previously purchased products:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const restorePurchases = async () => {
|
|
99
|
+
try {
|
|
100
|
+
const { customerInfo } = await NativePurchases.restorePurchases();
|
|
101
|
+
console.log('Restored purchases:', customerInfo);
|
|
102
|
+
// Update your app's state based on the restored purchases
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('Failed to restore purchases:', error);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Example: Implementing a simple store
|
|
110
|
+
|
|
111
|
+
Here's a basic example of how you might implement a simple store in your app:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { Capacitor } from '@capacitor/core';
|
|
115
|
+
import { NativePurchases, PURCHASE_TYPE, Product } from '@capgo/native-purchases';
|
|
116
|
+
|
|
117
|
+
class Store {
|
|
118
|
+
private products: Product[] = [];
|
|
119
|
+
|
|
120
|
+
async initialize() {
|
|
121
|
+
if (Capacitor.isNativePlatform()) {
|
|
122
|
+
try {
|
|
123
|
+
await this.checkBillingSupport();
|
|
124
|
+
await this.loadProducts();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error('Store initialization failed:', error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private async checkBillingSupport() {
|
|
132
|
+
const { isBillingSupported } = await NativePurchases.isBillingSupported();
|
|
133
|
+
if (!isBillingSupported) {
|
|
134
|
+
throw new Error('Billing is not supported on this device');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private async loadProducts() {
|
|
139
|
+
const productIds = ['premium_subscription', 'remove_ads', 'coin_pack'];
|
|
140
|
+
const { products } = await NativePurchases.getProducts({
|
|
141
|
+
productIdentifiers: productIds,
|
|
142
|
+
productType: PURCHASE_TYPE.INAPP
|
|
143
|
+
});
|
|
144
|
+
this.products = products;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getProducts() {
|
|
148
|
+
return this.products;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async purchaseProduct(productId: string) {
|
|
152
|
+
try {
|
|
153
|
+
const transaction = await NativePurchases.purchaseProduct({
|
|
154
|
+
productIdentifier: productId,
|
|
155
|
+
productType: PURCHASE_TYPE.INAPP
|
|
156
|
+
});
|
|
157
|
+
console.log('Purchase successful:', transaction);
|
|
158
|
+
// Handle the successful purchase
|
|
159
|
+
return transaction;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error('Purchase failed:', error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async restorePurchases() {
|
|
167
|
+
try {
|
|
168
|
+
const { customerInfo } = await NativePurchases.restorePurchases();
|
|
169
|
+
console.log('Restored purchases:', customerInfo);
|
|
170
|
+
// Update app state based on restored purchases
|
|
171
|
+
return customerInfo;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error('Failed to restore purchases:', error);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Usage
|
|
180
|
+
const store = new Store();
|
|
181
|
+
await store.initialize();
|
|
182
|
+
|
|
183
|
+
// Display products
|
|
184
|
+
const products = store.getProducts();
|
|
185
|
+
console.log('Available products:', products);
|
|
186
|
+
|
|
187
|
+
// Purchase a product
|
|
188
|
+
try {
|
|
189
|
+
await store.purchaseProduct('premium_subscription');
|
|
190
|
+
console.log('Purchase completed successfully');
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error('Purchase failed:', error);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Restore purchases
|
|
196
|
+
try {
|
|
197
|
+
await store.restorePurchases();
|
|
198
|
+
console.log('Purchases restored successfully');
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error('Failed to restore purchases:', error);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
This example provides a basic structure for initializing the store, loading products, making purchases, and restoring previous purchases. You'll need to adapt this to fit your specific app's needs, handle UI updates, and implement proper error handling and user feedback.
|
|
205
|
+
|
|
206
|
+
## Backend Validation
|
|
207
|
+
|
|
208
|
+
It's crucial to validate receipts on your server to ensure the integrity of purchases. Here's an example of how to implement backend validation using a Cloudflare Worker:
|
|
209
|
+
|
|
210
|
+
Cloudflare Worker Setup
|
|
211
|
+
Create a new Cloudflare Worker and follow the instructions in folder (`validator`)[/validator/README.md]
|
|
212
|
+
|
|
213
|
+
Then in your app, modify the purchase function to validate the receipt on the server:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { Capacitor } from '@capacitor/core';
|
|
217
|
+
import { NativePurchases, PURCHASE_TYPE, Product, Transaction } from '@capgo/native-purchases';
|
|
218
|
+
import axios from 'axios'; // Make sure to install axios: npm install axios
|
|
219
|
+
|
|
220
|
+
class Store {
|
|
221
|
+
// ... (previous code remains the same)
|
|
222
|
+
|
|
223
|
+
async purchaseProduct(productId: string) {
|
|
224
|
+
try {
|
|
225
|
+
const transaction = await NativePurchases.purchaseProduct({
|
|
226
|
+
productIdentifier: productId,
|
|
227
|
+
productType: PURCHASE_TYPE.INAPP
|
|
228
|
+
});
|
|
229
|
+
console.log('Purchase successful:', transaction);
|
|
230
|
+
|
|
231
|
+
// Immediately grant access to the purchased content
|
|
232
|
+
await this.grantAccess(productId);
|
|
233
|
+
|
|
234
|
+
// Initiate server-side validation asynchronously
|
|
235
|
+
this.validatePurchaseOnServer(transaction).catch(console.error);
|
|
236
|
+
|
|
237
|
+
return transaction;
|
|
238
|
+
} catch (error) {
|
|
239
|
+
console.error('Purchase failed:', error);
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private async grantAccess(productId: string) {
|
|
245
|
+
// Implement logic to grant immediate access to the purchased content
|
|
246
|
+
console.log(`Granting access to ${productId}`);
|
|
247
|
+
// Update local app state, unlock features, etc.
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private async validatePurchaseOnServer(transaction: Transaction) {
|
|
251
|
+
const serverUrl = 'https://your-server-url.com/validate-purchase';
|
|
252
|
+
try {
|
|
253
|
+
const response = await axios.post(serverUrl, {
|
|
254
|
+
transactionId: transaction.transactionId,
|
|
255
|
+
platform: Capacitor.getPlatform(),
|
|
256
|
+
// Include any other relevant information
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
console.log('Server validation response:', response.data);
|
|
260
|
+
// The server will handle the actual validation with the Cloudflare Worker
|
|
261
|
+
} catch (error) {
|
|
262
|
+
console.error('Error in server-side validation:', error);
|
|
263
|
+
// Implement retry logic or notify the user if necessary
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Usage remains the same
|
|
269
|
+
const store = new Store();
|
|
270
|
+
await store.initialize();
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
await store.purchaseProduct('premium_subscription');
|
|
274
|
+
console.log('Purchase completed successfully');
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error('Purchase failed:', error);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Now, let's look at how the server-side (Node.js) code might handle the validation:
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
import express from 'express';
|
|
284
|
+
import axios from 'axios';
|
|
285
|
+
|
|
286
|
+
const app = express();
|
|
287
|
+
app.use(express.json());
|
|
288
|
+
|
|
289
|
+
const CLOUDFLARE_WORKER_URL = 'https://your-cloudflare-worker-url.workers.dev';
|
|
290
|
+
|
|
291
|
+
app.post('/validate-purchase', async (req, res) => {
|
|
292
|
+
const { transactionId, platform } = req.body;
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
const endpoint = platform === 'ios' ? '/apple' : '/google';
|
|
296
|
+
const validationResponse = await axios.post(`${CLOUDFLARE_WORKER_URL}${endpoint}`, {
|
|
297
|
+
receipt: transactionId
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const validationResult = validationResponse.data;
|
|
301
|
+
|
|
302
|
+
// Process the validation result
|
|
303
|
+
if (validationResult.isValid) {
|
|
304
|
+
// Update user status in the database
|
|
305
|
+
// await updateUserStatus(userId, 'paid');
|
|
306
|
+
|
|
307
|
+
// Log the successful validation
|
|
308
|
+
console.log(`Purchase validated for transaction ${transactionId}`);
|
|
309
|
+
|
|
310
|
+
// You might want to store the validation result for future reference
|
|
311
|
+
// await storeValidationResult(userId, transactionId, validationResult);
|
|
312
|
+
} else {
|
|
313
|
+
// Handle invalid purchase
|
|
314
|
+
console.warn(`Invalid purchase detected for transaction ${transactionId}`);
|
|
315
|
+
// You might want to flag this for further investigation
|
|
316
|
+
// await flagSuspiciousPurchase(userId, transactionId);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Always respond with a success to the app
|
|
320
|
+
// This ensures the app doesn't block the user's access
|
|
321
|
+
res.json({ success: true });
|
|
322
|
+
} catch (error) {
|
|
323
|
+
console.error('Error validating purchase:', error);
|
|
324
|
+
// Still respond with success to the app
|
|
325
|
+
res.json({ success: true });
|
|
326
|
+
// You might want to log this error or retry the validation later
|
|
327
|
+
// await logValidationError(userId, transactionId, error);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// Start the server
|
|
332
|
+
app.listen(3000, () => console.log('Server running on port 3000'));
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Key points about this approach:
|
|
336
|
+
|
|
337
|
+
1. The app immediately grants access after a successful purchase, ensuring a smooth user experience.
|
|
338
|
+
2. The app initiates server-side validation asynchronously, not blocking the user's access.
|
|
339
|
+
3. The server handles the actual validation by calling the Cloudflare Worker.
|
|
340
|
+
4. The server always responds with success to the app, even if validation fails or encounters an error.
|
|
341
|
+
5. The server can update the user's status in the database, log results, and handle any discrepancies without affecting the user's immediate experience.
|
|
342
|
+
|
|
343
|
+
Comments on best practices:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
// After successful validation:
|
|
347
|
+
// await updateUserStatus(userId, 'paid');
|
|
348
|
+
|
|
349
|
+
// It's crucial to not block or revoke access immediately if validation fails
|
|
350
|
+
// Instead, flag suspicious transactions for review:
|
|
351
|
+
// if (!validationResult.isValid) {
|
|
352
|
+
// await flagSuspiciousPurchase(userId, transactionId);
|
|
353
|
+
// }
|
|
354
|
+
|
|
355
|
+
// Implement a system to periodically re-check flagged purchases
|
|
356
|
+
// This could be a separate process that runs daily/weekly
|
|
357
|
+
|
|
358
|
+
// Consider implementing a grace period for new purchases
|
|
359
|
+
// This allows for potential delays in server communication or store processing
|
|
360
|
+
// const GRACE_PERIOD_DAYS = 3;
|
|
361
|
+
// if (daysSincePurchase < GRACE_PERIOD_DAYS) {
|
|
362
|
+
// grantAccess = true;
|
|
363
|
+
// }
|
|
364
|
+
|
|
365
|
+
// For subscriptions, regularly check their status with the stores
|
|
366
|
+
// This ensures you catch any cancelled or expired subscriptions
|
|
367
|
+
// setInterval(checkSubscriptionStatuses, 24 * 60 * 60 * 1000); // Daily check
|
|
368
|
+
|
|
369
|
+
// Implement proper error handling and retry logic for network failures
|
|
370
|
+
// This is especially important for the server-to-Cloudflare communication
|
|
371
|
+
|
|
372
|
+
// Consider caching validation results to reduce load on your server and the stores
|
|
373
|
+
// const cachedValidation = await getCachedValidation(transactionId);
|
|
374
|
+
// if (cachedValidation) return cachedValidation;
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
This approach balances immediate user gratification with proper server-side validation, adhering to Apple and Google's guidelines while still maintaining the integrity of your purchase system.
|
|
378
|
+
|
|
26
379
|
## API
|
|
27
380
|
|
|
28
381
|
<docgen-index>
|
|
@@ -30,6 +383,7 @@ Add this to manifest
|
|
|
30
383
|
* [`restorePurchases()`](#restorepurchases)
|
|
31
384
|
* [`purchaseProduct(...)`](#purchaseproduct)
|
|
32
385
|
* [`getProducts(...)`](#getproducts)
|
|
386
|
+
* [`getProduct(...)`](#getproduct)
|
|
33
387
|
* [`isBillingSupported()`](#isbillingsupported)
|
|
34
388
|
* [`getPluginVersion()`](#getpluginversion)
|
|
35
389
|
* [Interfaces](#interfaces)
|
|
@@ -73,14 +427,31 @@ Started purchase process for the given product.
|
|
|
73
427
|
### getProducts(...)
|
|
74
428
|
|
|
75
429
|
```typescript
|
|
76
|
-
getProducts(options: { productIdentifiers: string[];
|
|
430
|
+
getProducts(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE; }) => any
|
|
77
431
|
```
|
|
78
432
|
|
|
79
433
|
Gets the product info associated with a list of product identifiers.
|
|
80
434
|
|
|
81
|
-
| Param | Type
|
|
82
|
-
| ------------- |
|
|
83
|
-
| **`options`** | <code>{ productIdentifiers: {};
|
|
435
|
+
| Param | Type | Description |
|
|
436
|
+
| ------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
437
|
+
| **`options`** | <code>{ productIdentifiers: {}; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; }</code> | - The product identifiers you wish to retrieve information for |
|
|
438
|
+
|
|
439
|
+
**Returns:** <code>any</code>
|
|
440
|
+
|
|
441
|
+
--------------------
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
### getProduct(...)
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
getProduct(options: { productIdentifier: string; productType?: PURCHASE_TYPE; }) => any
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Gets the product info for a single product identifier.
|
|
451
|
+
|
|
452
|
+
| Param | Type | Description |
|
|
453
|
+
| ------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
454
|
+
| **`options`** | <code>{ productIdentifier: string; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; }</code> | - The product identifier you wish to retrieve information for |
|
|
84
455
|
|
|
85
456
|
**Returns:** <code>any</code>
|
|
86
457
|
|
|
@@ -21,6 +21,7 @@ import com.getcapacitor.PluginMethod;
|
|
|
21
21
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
22
22
|
import com.google.common.collect.ImmutableList;
|
|
23
23
|
import java.util.ArrayList;
|
|
24
|
+
import java.util.Collections;
|
|
24
25
|
import java.util.List;
|
|
25
26
|
import java.util.concurrent.CountDownLatch;
|
|
26
27
|
import java.util.concurrent.Phaser;
|
|
@@ -420,41 +421,17 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
420
421
|
call.resolve();
|
|
421
422
|
}
|
|
422
423
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (productType.equals("subs") && planIdentifier.isEmpty()) {
|
|
429
|
-
// Handle error: no planIdentifier with productType subs
|
|
430
|
-
call.reject("planIdentifier cannot be empty if productType is subs");
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
if (
|
|
434
|
-
productIdentifiersArray == null || productIdentifiersArray.length() == 0
|
|
435
|
-
) {
|
|
436
|
-
call.reject("productIdentifiers array missing");
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
List<String> productIdentifiers = new ArrayList<>();
|
|
440
|
-
|
|
441
|
-
for (int i = 0; i < productIdentifiersArray.length(); i++) {
|
|
442
|
-
try {
|
|
443
|
-
productIdentifiers.add(productIdentifiersArray.getString(i));
|
|
444
|
-
} catch (JSONException e) {
|
|
445
|
-
e.printStackTrace();
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
Log.d(NativePurchasesPlugin.TAG, "getProducts: " + productIdentifiers);
|
|
424
|
+
private void queryProductDetails(
|
|
425
|
+
List<String> productIdentifiers,
|
|
426
|
+
String productType,
|
|
427
|
+
PluginCall call
|
|
428
|
+
) {
|
|
450
429
|
List<QueryProductDetailsParams.Product> productList = new ArrayList<>();
|
|
451
430
|
for (String productIdentifier : productIdentifiers) {
|
|
452
431
|
productList.add(
|
|
453
432
|
QueryProductDetailsParams.Product
|
|
454
433
|
.newBuilder()
|
|
455
|
-
.setProductId(
|
|
456
|
-
productType.equals("inapp") ? productIdentifier : planIdentifier
|
|
457
|
-
)
|
|
434
|
+
.setProductId(productIdentifier)
|
|
458
435
|
.setProductType(
|
|
459
436
|
productType.equals("inapp")
|
|
460
437
|
? BillingClient.ProductType.INAPP
|
|
@@ -481,14 +458,7 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
481
458
|
call.reject("Product not found");
|
|
482
459
|
return;
|
|
483
460
|
}
|
|
484
|
-
Log.i(
|
|
485
|
-
NativePurchasesPlugin.TAG,
|
|
486
|
-
"onProductDetailsResponse" + billingResult + productDetailsList
|
|
487
|
-
);
|
|
488
|
-
// Process the result
|
|
489
|
-
JSObject ret = new JSObject();
|
|
490
461
|
JSONArray products = new JSONArray();
|
|
491
|
-
Number productIdIndex = 0;
|
|
492
462
|
for (ProductDetails productDetails : productDetailsList) {
|
|
493
463
|
JSObject product = new JSObject();
|
|
494
464
|
product.put("title", productDetails.getName());
|
|
@@ -515,28 +485,9 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
515
485
|
.getPriceCurrencyCode()
|
|
516
486
|
);
|
|
517
487
|
} else {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
);
|
|
522
|
-
productIdIndex = productIdIndex.intValue() + 1;
|
|
523
|
-
// get the SubscriptionOfferDetails who match the subscriptionOfferIdentifier
|
|
524
|
-
ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
|
|
525
|
-
null;
|
|
526
|
-
for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetails.getSubscriptionOfferDetails()) {
|
|
527
|
-
if (
|
|
528
|
-
offerDetails
|
|
529
|
-
.getBasePlanId()
|
|
530
|
-
.equals(subscriptionOfferIdentifier)
|
|
531
|
-
) {
|
|
532
|
-
selectedOfferDetails = offerDetails;
|
|
533
|
-
break;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
if (selectedOfferDetails == null) {
|
|
537
|
-
selectedOfferDetails =
|
|
538
|
-
productDetails.getSubscriptionOfferDetails().get(0);
|
|
539
|
-
}
|
|
488
|
+
ProductDetails.SubscriptionOfferDetails selectedOfferDetails = productDetails
|
|
489
|
+
.getSubscriptionOfferDetails()
|
|
490
|
+
.get(0);
|
|
540
491
|
product.put("planIdentifier", productDetails.getProductId());
|
|
541
492
|
product.put("identifier", selectedOfferDetails.getBasePlanId());
|
|
542
493
|
product.put(
|
|
@@ -565,10 +516,10 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
565
516
|
.getPriceCurrencyCode()
|
|
566
517
|
);
|
|
567
518
|
}
|
|
568
|
-
|
|
569
519
|
product.put("isFamilyShareable", false);
|
|
570
520
|
products.put(product);
|
|
571
521
|
}
|
|
522
|
+
JSObject ret = new JSObject();
|
|
572
523
|
ret.put("products", products);
|
|
573
524
|
closeBillingClient();
|
|
574
525
|
call.resolve(ret);
|
|
@@ -580,4 +531,36 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
580
531
|
call.reject(e.getMessage());
|
|
581
532
|
}
|
|
582
533
|
}
|
|
534
|
+
|
|
535
|
+
@PluginMethod
|
|
536
|
+
public void getProducts(PluginCall call) {
|
|
537
|
+
JSONArray productIdentifiersArray = call.getArray("productIdentifiers");
|
|
538
|
+
String productType = call.getString("productType", "inapp");
|
|
539
|
+
if (
|
|
540
|
+
productIdentifiersArray == null || productIdentifiersArray.length() == 0
|
|
541
|
+
) {
|
|
542
|
+
call.reject("productIdentifiers array missing");
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
List<String> productIdentifiers = new ArrayList<>();
|
|
546
|
+
for (int i = 0; i < productIdentifiersArray.length(); i++) {
|
|
547
|
+
productIdentifiers.add(productIdentifiersArray.optString(i, ""));
|
|
548
|
+
}
|
|
549
|
+
queryProductDetails(productIdentifiers, productType, call);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
@PluginMethod
|
|
553
|
+
public void getProduct(PluginCall call) {
|
|
554
|
+
String productIdentifier = call.getString("productIdentifier");
|
|
555
|
+
String productType = call.getString("productType", "inapp");
|
|
556
|
+
if (productIdentifier.isEmpty()) {
|
|
557
|
+
call.reject("productIdentifier is empty");
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
queryProductDetails(
|
|
561
|
+
Collections.singletonList(productIdentifier),
|
|
562
|
+
productType,
|
|
563
|
+
call
|
|
564
|
+
);
|
|
565
|
+
}
|
|
583
566
|
}
|
package/dist/docs.json
CHANGED
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"name": "getProducts",
|
|
62
|
-
"signature": "(options: { productIdentifiers: string[];
|
|
62
|
+
"signature": "(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE; }) => any",
|
|
63
63
|
"parameters": [
|
|
64
64
|
{
|
|
65
65
|
"name": "options",
|
|
66
66
|
"docs": "- The product identifiers you wish to retrieve information for",
|
|
67
|
-
"type": "{ productIdentifiers: {};
|
|
67
|
+
"type": "{ productIdentifiers: {}; productType?: PURCHASE_TYPE | undefined; }"
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
70
|
"returns": "any",
|
|
@@ -79,7 +79,39 @@
|
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"name": "param",
|
|
82
|
-
"text": "options.
|
|
82
|
+
"text": "options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default."
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "returns",
|
|
86
|
+
"text": "- The requested product info"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"docs": "Gets the product info associated with a list of product identifiers.",
|
|
90
|
+
"complexTypes": [
|
|
91
|
+
"PURCHASE_TYPE",
|
|
92
|
+
"Product"
|
|
93
|
+
],
|
|
94
|
+
"slug": "getproducts"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "getProduct",
|
|
98
|
+
"signature": "(options: { productIdentifier: string; productType?: PURCHASE_TYPE; }) => any",
|
|
99
|
+
"parameters": [
|
|
100
|
+
{
|
|
101
|
+
"name": "options",
|
|
102
|
+
"docs": "- The product identifier you wish to retrieve information for",
|
|
103
|
+
"type": "{ productIdentifier: string; productType?: PURCHASE_TYPE | undefined; }"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"returns": "any",
|
|
107
|
+
"tags": [
|
|
108
|
+
{
|
|
109
|
+
"name": "param",
|
|
110
|
+
"text": "options - The product identifier you wish to retrieve information for"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "param",
|
|
114
|
+
"text": "options.productIdentifier - The product identifier"
|
|
83
115
|
},
|
|
84
116
|
{
|
|
85
117
|
"name": "param",
|
|
@@ -90,12 +122,12 @@
|
|
|
90
122
|
"text": "- The requested product info"
|
|
91
123
|
}
|
|
92
124
|
],
|
|
93
|
-
"docs": "Gets the product info
|
|
125
|
+
"docs": "Gets the product info for a single product identifier.",
|
|
94
126
|
"complexTypes": [
|
|
95
127
|
"PURCHASE_TYPE",
|
|
96
128
|
"Product"
|
|
97
129
|
],
|
|
98
|
-
"slug": "
|
|
130
|
+
"slug": "getproduct"
|
|
99
131
|
},
|
|
100
132
|
{
|
|
101
133
|
"name": "isBillingSupported",
|
|
@@ -303,17 +303,29 @@ export interface NativePurchasesPlugin {
|
|
|
303
303
|
*
|
|
304
304
|
* @param options - The product identifiers you wish to retrieve information for
|
|
305
305
|
* @param options.productIdentifiers - Array of product identifiers
|
|
306
|
-
* @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.
|
|
307
306
|
* @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
|
|
308
307
|
* @returns - The requested product info
|
|
309
308
|
*/
|
|
310
309
|
getProducts(options: {
|
|
311
310
|
productIdentifiers: string[];
|
|
312
|
-
planIdentifier?: string;
|
|
313
311
|
productType?: PURCHASE_TYPE;
|
|
314
312
|
}): Promise<{
|
|
315
313
|
products: Product[];
|
|
316
314
|
}>;
|
|
315
|
+
/**
|
|
316
|
+
* Gets the product info for a single product identifier.
|
|
317
|
+
*
|
|
318
|
+
* @param options - The product identifier you wish to retrieve information for
|
|
319
|
+
* @param options.productIdentifier - The product identifier
|
|
320
|
+
* @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
|
|
321
|
+
* @returns - The requested product info
|
|
322
|
+
*/
|
|
323
|
+
getProduct(options: {
|
|
324
|
+
productIdentifier: string;
|
|
325
|
+
productType?: PURCHASE_TYPE;
|
|
326
|
+
}): Promise<{
|
|
327
|
+
product: Product;
|
|
328
|
+
}>;
|
|
317
329
|
/**
|
|
318
330
|
* Check if billing is supported for the current device.
|
|
319
331
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = \"inapp\",\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = \"subs\",\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = \"UNKNOWN\",\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = \"CUSTOM\",\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = \"LIFETIME\",\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = \"ANNUAL\",\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = \"SIX_MONTH\",\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = \"THREE_MONTH\",\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = \"TWO_MONTH\",\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = \"MONTHLY\",\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = \"WEEKLY\",\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Product Id associated with the transaction.\n */\n // readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n // readonly purchaseDate: string;\n}\n\nexport interface CustomerInfo {\n /**\n * Set of active subscription skus\n */\n readonly activeSubscriptions: [string];\n /**\n * Set of purchased skus, active and inactive\n */\n readonly allPurchasedProductIdentifiers: [string];\n /**\n * Returns all the non-subscription a user has made.\n * The are ordered by purchase date in ascending order.\n */\n readonly nonSubscriptionTransactions: Transaction[];\n /**\n * The latest expiration date of all purchased skus\n */\n readonly latestExpirationDate: string | null;\n /**\n * The date this user was first seen in RevenueCat.\n */\n readonly firstSeen: string;\n /**\n * The original App User Id recorded for this user.\n */\n readonly originalAppUserId: string;\n /**\n * Date when this info was requested\n */\n readonly requestDate: string;\n /**\n * Returns the version number for the version of the application when the\n * user bought the app. Use this for grandfathering users when migrating\n * to subscriptions.\n *\n * This corresponds to the value of CFBundleVersion (in iOS) in the\n * Info.plist file when the purchase was originally made. This is always null\n * in Android\n */\n readonly originalApplicationVersion: string | null;\n /**\n * Returns the purchase date for the version of the application when the user bought the app.\n * Use this for grandfathering users when migrating to subscriptions.\n */\n readonly originalPurchaseDate: string | null;\n /**\n * URL to manage the active subscription of the user. If this user has an active iOS\n * subscription, this will point to the App Store, if the user has an active Play Store subscription\n * it will point there. If there are no active subscriptions it will be null.\n * If there are multiple for different platforms, it will point to the device store.\n */\n readonly managementURL: string | null;\n}\nexport interface SubscriptionPeriod {\n /**\n * The Subscription Period number of unit.\n */\n readonly numberOfUnits: number;\n /**\n * The Subscription Period unit.\n */\n readonly unit: number;\n}\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\n */\n readonly type: number;\n /**\n * The Product discount price.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * The Product discount currency symbol.\n */\n readonly currencySymbol: string;\n /**\n * The Product discount currency code.\n */\n readonly currencyCode: string;\n /**\n * The Product discount paymentMode.\n */\n readonly paymentMode: number;\n /**\n * The Product discount number Of Periods.\n */\n readonly numberOfPeriods: number;\n /**\n * The Product discount subscription period.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n}\nexport interface Product {\n /**\n * Product Id.\n */\n readonly identifier: string;\n /**\n * Description of the product.\n */\n readonly description: string;\n /**\n * Title of the product.\n */\n readonly title: string;\n /**\n * Price of the product in the local currency.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * Currency code for price and original price.\n */\n readonly currencyCode: string;\n /**\n * Currency symbol for price and original price.\n */\n readonly currencySymbol: string;\n /**\n * Boolean indicating if the product is sharable with family\n */\n readonly isFamilyShareable: boolean;\n /**\n * Group identifier for the product.\n */\n readonly subscriptionGroupIdentifier: string;\n /**\n * The Product subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<{ customerInfo: CustomerInfo }>;\n\n /**\n * Started purchase process for the given product.\n *\n * @param options - The product to purchase\n * @param options.productIdentifier - The product identifier of the product you want to purchase.\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: {\n productIdentifiers: string[];\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = \"inapp\",\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = \"subs\",\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = \"UNKNOWN\",\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = \"CUSTOM\",\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = \"LIFETIME\",\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = \"ANNUAL\",\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = \"SIX_MONTH\",\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = \"THREE_MONTH\",\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = \"TWO_MONTH\",\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = \"MONTHLY\",\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = \"WEEKLY\",\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Product Id associated with the transaction.\n */\n // readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n // readonly purchaseDate: string;\n}\n\nexport interface CustomerInfo {\n /**\n * Set of active subscription skus\n */\n readonly activeSubscriptions: [string];\n /**\n * Set of purchased skus, active and inactive\n */\n readonly allPurchasedProductIdentifiers: [string];\n /**\n * Returns all the non-subscription a user has made.\n * The are ordered by purchase date in ascending order.\n */\n readonly nonSubscriptionTransactions: Transaction[];\n /**\n * The latest expiration date of all purchased skus\n */\n readonly latestExpirationDate: string | null;\n /**\n * The date this user was first seen in RevenueCat.\n */\n readonly firstSeen: string;\n /**\n * The original App User Id recorded for this user.\n */\n readonly originalAppUserId: string;\n /**\n * Date when this info was requested\n */\n readonly requestDate: string;\n /**\n * Returns the version number for the version of the application when the\n * user bought the app. Use this for grandfathering users when migrating\n * to subscriptions.\n *\n * This corresponds to the value of CFBundleVersion (in iOS) in the\n * Info.plist file when the purchase was originally made. This is always null\n * in Android\n */\n readonly originalApplicationVersion: string | null;\n /**\n * Returns the purchase date for the version of the application when the user bought the app.\n * Use this for grandfathering users when migrating to subscriptions.\n */\n readonly originalPurchaseDate: string | null;\n /**\n * URL to manage the active subscription of the user. If this user has an active iOS\n * subscription, this will point to the App Store, if the user has an active Play Store subscription\n * it will point there. If there are no active subscriptions it will be null.\n * If there are multiple for different platforms, it will point to the device store.\n */\n readonly managementURL: string | null;\n}\nexport interface SubscriptionPeriod {\n /**\n * The Subscription Period number of unit.\n */\n readonly numberOfUnits: number;\n /**\n * The Subscription Period unit.\n */\n readonly unit: number;\n}\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\n */\n readonly type: number;\n /**\n * The Product discount price.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * The Product discount currency symbol.\n */\n readonly currencySymbol: string;\n /**\n * The Product discount currency code.\n */\n readonly currencyCode: string;\n /**\n * The Product discount paymentMode.\n */\n readonly paymentMode: number;\n /**\n * The Product discount number Of Periods.\n */\n readonly numberOfPeriods: number;\n /**\n * The Product discount subscription period.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n}\nexport interface Product {\n /**\n * Product Id.\n */\n readonly identifier: string;\n /**\n * Description of the product.\n */\n readonly description: string;\n /**\n * Title of the product.\n */\n readonly title: string;\n /**\n * Price of the product in the local currency.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * Currency code for price and original price.\n */\n readonly currencyCode: string;\n /**\n * Currency symbol for price and original price.\n */\n readonly currencySymbol: string;\n /**\n * Boolean indicating if the product is sharable with family\n */\n readonly isFamilyShareable: boolean;\n /**\n * Group identifier for the product.\n */\n readonly subscriptionGroupIdentifier: string;\n /**\n * The Product subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<{ customerInfo: CustomerInfo }>;\n\n /**\n * Started purchase process for the given product.\n *\n * @param options - The product to purchase\n * @param options.productIdentifier - The product identifier of the product you want to purchase.\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\n *\n * @param options - The product identifier you wish to retrieve information for\n * @param options.productIdentifier - The product identifier\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProduct(options: {\n productIdentifier: string;\n productType?: PURCHASE_TYPE;\n }): Promise<{ product: Product }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export declare class NativePurchasesWeb extends WebPlugin implements NativePurch
|
|
|
10
10
|
}): Promise<{
|
|
11
11
|
products: Product[];
|
|
12
12
|
}>;
|
|
13
|
+
getProduct(options: {
|
|
14
|
+
productIdentifier: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
product: Product;
|
|
17
|
+
}>;
|
|
13
18
|
purchaseProduct(options: {
|
|
14
19
|
productIdentifier: string;
|
|
15
20
|
planIdentifier: string;
|
package/dist/esm/web.js
CHANGED
|
@@ -20,6 +20,10 @@ export class NativePurchasesWeb extends WebPlugin {
|
|
|
20
20
|
console.error("getProducts only mocked in web " + options);
|
|
21
21
|
return { products: [] };
|
|
22
22
|
}
|
|
23
|
+
async getProduct(options) {
|
|
24
|
+
console.error("getProduct only mocked in web " + options);
|
|
25
|
+
return { product: {} };
|
|
26
|
+
}
|
|
23
27
|
async purchaseProduct(options) {
|
|
24
28
|
console.error("purchaseProduct only mocked in web" + options);
|
|
25
29
|
return { transactionId: "transactionId" };
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,mBAAmB,EAAE,CAAC,EAAE,CAAC;IACzB,8BAA8B,EAAE,CAAC,EAAE,CAAC;IACpC,2BAA2B,EAAE,EAAE;IAC/B,oBAAoB,EAAE,IAAI;IAC1B,SAAS,EAAE,0BAA0B;IACrC,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,0BAA0B;IACvC,0BAA0B,EAAE,EAAE;IAC9B,oBAAoB,EAAE,IAAI;IAC1B,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativePurchasesPlugin,\n CustomerInfo,\n Product,\n} from \"./definitions\";\n\nexport const mockCustomerInfo: CustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\n\nexport class NativePurchasesWeb\n extends WebPlugin\n implements NativePurchasesPlugin\n{\n async restorePurchases(): Promise<{ customerInfo: CustomerInfo }> {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n }): Promise<{ products: Product[] }> {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n\n async purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier: string;\n quantity: number;\n }): Promise<{ transactionId: string }> {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n\n async isBillingSupported(): Promise<{ isBillingSupported: boolean }> {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion(): Promise<{ version: string }> {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,mBAAmB,EAAE,CAAC,EAAE,CAAC;IACzB,8BAA8B,EAAE,CAAC,EAAE,CAAC;IACpC,2BAA2B,EAAE,EAAE;IAC/B,oBAAoB,EAAE,IAAI;IAC1B,SAAS,EAAE,0BAA0B;IACrC,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,0BAA0B;IACvC,0BAA0B,EAAE,EAAE;IAC9B,oBAAoB,EAAE,IAAI;IAC1B,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACpD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAEhB;QACC,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativePurchasesPlugin,\n CustomerInfo,\n Product,\n} from \"./definitions\";\n\nexport const mockCustomerInfo: CustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\n\nexport class NativePurchasesWeb\n extends WebPlugin\n implements NativePurchasesPlugin\n{\n async restorePurchases(): Promise<{ customerInfo: CustomerInfo }> {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n }): Promise<{ products: Product[] }> {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n\n async getProduct(options: {\n productIdentifier: string;\n }): Promise<{ product: Product }> {\n console.error(\"getProduct only mocked in web \" + options);\n return { product: {} as any };\n }\n\n async purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier: string;\n quantity: number;\n }): Promise<{ transactionId: string }> {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n\n async isBillingSupported(): Promise<{ isBillingSupported: boolean }> {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion(): Promise<{ version: string }> {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -157,6 +157,10 @@ class NativePurchasesWeb extends core.WebPlugin {
|
|
|
157
157
|
console.error("getProducts only mocked in web " + options);
|
|
158
158
|
return { products: [] };
|
|
159
159
|
}
|
|
160
|
+
async getProduct(options) {
|
|
161
|
+
console.error("getProduct only mocked in web " + options);
|
|
162
|
+
return { product: {} };
|
|
163
|
+
}
|
|
160
164
|
async purchaseProduct(options) {
|
|
161
165
|
console.error("purchaseProduct only mocked in web" + options);
|
|
162
166
|
return { transactionId: "transactionId" };
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ATTRIBUTION_NETWORK;\n(function (ATTRIBUTION_NETWORK) {\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPLE_SEARCH_ADS\"] = 0] = \"APPLE_SEARCH_ADS\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"ADJUST\"] = 1] = \"ADJUST\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPSFLYER\"] = 2] = \"APPSFLYER\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"BRANCH\"] = 3] = \"BRANCH\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"TENJIN\"] = 4] = \"TENJIN\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"FACEBOOK\"] = 5] = \"FACEBOOK\";\n})(ATTRIBUTION_NETWORK || (ATTRIBUTION_NETWORK = {}));\nexport var PURCHASE_TYPE;\n(function (PURCHASE_TYPE) {\n /**\n * A type of SKU for in-app products.\n */\n PURCHASE_TYPE[\"INAPP\"] = \"inapp\";\n /**\n * A type of SKU for subscriptions.\n */\n PURCHASE_TYPE[\"SUBS\"] = \"subs\";\n})(PURCHASE_TYPE || (PURCHASE_TYPE = {}));\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport var BILLING_FEATURE;\n(function (BILLING_FEATURE) {\n /**\n * Purchase/query for subscriptions.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS\"] = 0] = \"SUBSCRIPTIONS\";\n /**\n * Subscriptions update/replace.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_UPDATE\"] = 1] = \"SUBSCRIPTIONS_UPDATE\";\n /**\n * Purchase/query for in-app items on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"IN_APP_ITEMS_ON_VR\"] = 2] = \"IN_APP_ITEMS_ON_VR\";\n /**\n * Purchase/query for subscriptions on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_ON_VR\"] = 3] = \"SUBSCRIPTIONS_ON_VR\";\n /**\n * Launch a price change confirmation flow.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"PRICE_CHANGE_CONFIRMATION\"] = 4] = \"PRICE_CHANGE_CONFIRMATION\";\n})(BILLING_FEATURE || (BILLING_FEATURE = {}));\nexport var PRORATION_MODE;\n(function (PRORATION_MODE) {\n PRORATION_MODE[PRORATION_MODE[\"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\"] = 0] = \"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\";\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITH_TIME_PRORATION\"] = 1] = \"IMMEDIATE_WITH_TIME_PRORATION\";\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\"] = 2] = \"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\";\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITHOUT_PRORATION\"] = 3] = \"IMMEDIATE_WITHOUT_PRORATION\";\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n PRORATION_MODE[PRORATION_MODE[\"DEFERRED\"] = 4] = \"DEFERRED\";\n})(PRORATION_MODE || (PRORATION_MODE = {}));\nexport var PACKAGE_TYPE;\n(function (PACKAGE_TYPE) {\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"UNKNOWN\"] = \"UNKNOWN\";\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"CUSTOM\"] = \"CUSTOM\";\n /**\n * A package configured with the predefined lifetime identifier.\n */\n PACKAGE_TYPE[\"LIFETIME\"] = \"LIFETIME\";\n /**\n * A package configured with the predefined annual identifier.\n */\n PACKAGE_TYPE[\"ANNUAL\"] = \"ANNUAL\";\n /**\n * A package configured with the predefined six month identifier.\n */\n PACKAGE_TYPE[\"SIX_MONTH\"] = \"SIX_MONTH\";\n /**\n * A package configured with the predefined three month identifier.\n */\n PACKAGE_TYPE[\"THREE_MONTH\"] = \"THREE_MONTH\";\n /**\n * A package configured with the predefined two month identifier.\n */\n PACKAGE_TYPE[\"TWO_MONTH\"] = \"TWO_MONTH\";\n /**\n * A package configured with the predefined monthly identifier.\n */\n PACKAGE_TYPE[\"MONTHLY\"] = \"MONTHLY\";\n /**\n * A package configured with the predefined weekly identifier.\n */\n PACKAGE_TYPE[\"WEEKLY\"] = \"WEEKLY\";\n})(PACKAGE_TYPE || (PACKAGE_TYPE = {}));\nexport var INTRO_ELIGIBILITY_STATUS;\n(function (INTRO_ELIGIBILITY_STATUS) {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_UNKNOWN\"] = 0] = \"INTRO_ELIGIBILITY_STATUS_UNKNOWN\";\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\"] = 1] = \"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\";\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\"] = 2] = \"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\";\n})(INTRO_ELIGIBILITY_STATUS || (INTRO_ELIGIBILITY_STATUS = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NativePurchases = registerPlugin(\"NativePurchases\", {\n web: () => import(\"./web\").then((m) => new m.NativePurchasesWeb()),\n});\nexport * from \"./definitions\";\nexport { NativePurchases };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport const mockCustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\nexport class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n async getProducts(options) {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n async purchaseProduct(options) {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n async isBillingSupported() {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion() {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ATTRIBUTION_NETWORK","PURCHASE_TYPE","BILLING_FEATURE","PRORATION_MODE","PACKAGE_TYPE","INTRO_ELIGIBILITY_STATUS","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAWA,qCAAoB;AAC/B,CAAC,UAAU,mBAAmB,EAAE;AAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB,CAAC;AAC1F,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;AAC5E,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC1E,CAAC,EAAEA,2BAAmB,KAAKA,2BAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;AAC3CC,+BAAc;AACzB,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACrC;AACA;AACA;AACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACnC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1C;AACA;AACA;AACA;AACA;AACWC,iCAAgB;AAC3B,CAAC,UAAU,eAA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K,EAAE,CAAC;AAC7C,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AACzD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACtC,KAAK;AACL;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ATTRIBUTION_NETWORK;\n(function (ATTRIBUTION_NETWORK) {\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPLE_SEARCH_ADS\"] = 0] = \"APPLE_SEARCH_ADS\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"ADJUST\"] = 1] = \"ADJUST\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPSFLYER\"] = 2] = \"APPSFLYER\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"BRANCH\"] = 3] = \"BRANCH\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"TENJIN\"] = 4] = \"TENJIN\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"FACEBOOK\"] = 5] = \"FACEBOOK\";\n})(ATTRIBUTION_NETWORK || (ATTRIBUTION_NETWORK = {}));\nexport var PURCHASE_TYPE;\n(function (PURCHASE_TYPE) {\n /**\n * A type of SKU for in-app products.\n */\n PURCHASE_TYPE[\"INAPP\"] = \"inapp\";\n /**\n * A type of SKU for subscriptions.\n */\n PURCHASE_TYPE[\"SUBS\"] = \"subs\";\n})(PURCHASE_TYPE || (PURCHASE_TYPE = {}));\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport var BILLING_FEATURE;\n(function (BILLING_FEATURE) {\n /**\n * Purchase/query for subscriptions.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS\"] = 0] = \"SUBSCRIPTIONS\";\n /**\n * Subscriptions update/replace.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_UPDATE\"] = 1] = \"SUBSCRIPTIONS_UPDATE\";\n /**\n * Purchase/query for in-app items on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"IN_APP_ITEMS_ON_VR\"] = 2] = \"IN_APP_ITEMS_ON_VR\";\n /**\n * Purchase/query for subscriptions on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_ON_VR\"] = 3] = \"SUBSCRIPTIONS_ON_VR\";\n /**\n * Launch a price change confirmation flow.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"PRICE_CHANGE_CONFIRMATION\"] = 4] = \"PRICE_CHANGE_CONFIRMATION\";\n})(BILLING_FEATURE || (BILLING_FEATURE = {}));\nexport var PRORATION_MODE;\n(function (PRORATION_MODE) {\n PRORATION_MODE[PRORATION_MODE[\"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\"] = 0] = \"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\";\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITH_TIME_PRORATION\"] = 1] = \"IMMEDIATE_WITH_TIME_PRORATION\";\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\"] = 2] = \"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\";\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITHOUT_PRORATION\"] = 3] = \"IMMEDIATE_WITHOUT_PRORATION\";\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n PRORATION_MODE[PRORATION_MODE[\"DEFERRED\"] = 4] = \"DEFERRED\";\n})(PRORATION_MODE || (PRORATION_MODE = {}));\nexport var PACKAGE_TYPE;\n(function (PACKAGE_TYPE) {\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"UNKNOWN\"] = \"UNKNOWN\";\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"CUSTOM\"] = \"CUSTOM\";\n /**\n * A package configured with the predefined lifetime identifier.\n */\n PACKAGE_TYPE[\"LIFETIME\"] = \"LIFETIME\";\n /**\n * A package configured with the predefined annual identifier.\n */\n PACKAGE_TYPE[\"ANNUAL\"] = \"ANNUAL\";\n /**\n * A package configured with the predefined six month identifier.\n */\n PACKAGE_TYPE[\"SIX_MONTH\"] = \"SIX_MONTH\";\n /**\n * A package configured with the predefined three month identifier.\n */\n PACKAGE_TYPE[\"THREE_MONTH\"] = \"THREE_MONTH\";\n /**\n * A package configured with the predefined two month identifier.\n */\n PACKAGE_TYPE[\"TWO_MONTH\"] = \"TWO_MONTH\";\n /**\n * A package configured with the predefined monthly identifier.\n */\n PACKAGE_TYPE[\"MONTHLY\"] = \"MONTHLY\";\n /**\n * A package configured with the predefined weekly identifier.\n */\n PACKAGE_TYPE[\"WEEKLY\"] = \"WEEKLY\";\n})(PACKAGE_TYPE || (PACKAGE_TYPE = {}));\nexport var INTRO_ELIGIBILITY_STATUS;\n(function (INTRO_ELIGIBILITY_STATUS) {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_UNKNOWN\"] = 0] = \"INTRO_ELIGIBILITY_STATUS_UNKNOWN\";\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\"] = 1] = \"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\";\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\"] = 2] = \"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\";\n})(INTRO_ELIGIBILITY_STATUS || (INTRO_ELIGIBILITY_STATUS = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NativePurchases = registerPlugin(\"NativePurchases\", {\n web: () => import(\"./web\").then((m) => new m.NativePurchasesWeb()),\n});\nexport * from \"./definitions\";\nexport { NativePurchases };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport const mockCustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\nexport class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n async getProducts(options) {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n async getProduct(options) {\n console.error(\"getProduct only mocked in web \" + options);\n return { product: {} };\n }\n async purchaseProduct(options) {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n async isBillingSupported() {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion() {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ATTRIBUTION_NETWORK","PURCHASE_TYPE","BILLING_FEATURE","P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E,kBAAkB,EAAE,KAAK,EAAE,CAAC;AAC7C,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AACzD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACtC,KAAK;AACL;;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -154,6 +154,10 @@ var capacitorNativePurchases = (function (exports, core) {
|
|
|
154
154
|
console.error("getProducts only mocked in web " + options);
|
|
155
155
|
return { products: [] };
|
|
156
156
|
}
|
|
157
|
+
async getProduct(options) {
|
|
158
|
+
console.error("getProduct only mocked in web " + options);
|
|
159
|
+
return { product: {} };
|
|
160
|
+
}
|
|
157
161
|
async purchaseProduct(options) {
|
|
158
162
|
console.error("purchaseProduct only mocked in web" + options);
|
|
159
163
|
return { transactionId: "transactionId" };
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ATTRIBUTION_NETWORK;\n(function (ATTRIBUTION_NETWORK) {\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPLE_SEARCH_ADS\"] = 0] = \"APPLE_SEARCH_ADS\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"ADJUST\"] = 1] = \"ADJUST\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPSFLYER\"] = 2] = \"APPSFLYER\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"BRANCH\"] = 3] = \"BRANCH\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"TENJIN\"] = 4] = \"TENJIN\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"FACEBOOK\"] = 5] = \"FACEBOOK\";\n})(ATTRIBUTION_NETWORK || (ATTRIBUTION_NETWORK = {}));\nexport var PURCHASE_TYPE;\n(function (PURCHASE_TYPE) {\n /**\n * A type of SKU for in-app products.\n */\n PURCHASE_TYPE[\"INAPP\"] = \"inapp\";\n /**\n * A type of SKU for subscriptions.\n */\n PURCHASE_TYPE[\"SUBS\"] = \"subs\";\n})(PURCHASE_TYPE || (PURCHASE_TYPE = {}));\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport var BILLING_FEATURE;\n(function (BILLING_FEATURE) {\n /**\n * Purchase/query for subscriptions.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS\"] = 0] = \"SUBSCRIPTIONS\";\n /**\n * Subscriptions update/replace.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_UPDATE\"] = 1] = \"SUBSCRIPTIONS_UPDATE\";\n /**\n * Purchase/query for in-app items on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"IN_APP_ITEMS_ON_VR\"] = 2] = \"IN_APP_ITEMS_ON_VR\";\n /**\n * Purchase/query for subscriptions on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_ON_VR\"] = 3] = \"SUBSCRIPTIONS_ON_VR\";\n /**\n * Launch a price change confirmation flow.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"PRICE_CHANGE_CONFIRMATION\"] = 4] = \"PRICE_CHANGE_CONFIRMATION\";\n})(BILLING_FEATURE || (BILLING_FEATURE = {}));\nexport var PRORATION_MODE;\n(function (PRORATION_MODE) {\n PRORATION_MODE[PRORATION_MODE[\"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\"] = 0] = \"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\";\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITH_TIME_PRORATION\"] = 1] = \"IMMEDIATE_WITH_TIME_PRORATION\";\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\"] = 2] = \"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\";\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITHOUT_PRORATION\"] = 3] = \"IMMEDIATE_WITHOUT_PRORATION\";\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n PRORATION_MODE[PRORATION_MODE[\"DEFERRED\"] = 4] = \"DEFERRED\";\n})(PRORATION_MODE || (PRORATION_MODE = {}));\nexport var PACKAGE_TYPE;\n(function (PACKAGE_TYPE) {\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"UNKNOWN\"] = \"UNKNOWN\";\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"CUSTOM\"] = \"CUSTOM\";\n /**\n * A package configured with the predefined lifetime identifier.\n */\n PACKAGE_TYPE[\"LIFETIME\"] = \"LIFETIME\";\n /**\n * A package configured with the predefined annual identifier.\n */\n PACKAGE_TYPE[\"ANNUAL\"] = \"ANNUAL\";\n /**\n * A package configured with the predefined six month identifier.\n */\n PACKAGE_TYPE[\"SIX_MONTH\"] = \"SIX_MONTH\";\n /**\n * A package configured with the predefined three month identifier.\n */\n PACKAGE_TYPE[\"THREE_MONTH\"] = \"THREE_MONTH\";\n /**\n * A package configured with the predefined two month identifier.\n */\n PACKAGE_TYPE[\"TWO_MONTH\"] = \"TWO_MONTH\";\n /**\n * A package configured with the predefined monthly identifier.\n */\n PACKAGE_TYPE[\"MONTHLY\"] = \"MONTHLY\";\n /**\n * A package configured with the predefined weekly identifier.\n */\n PACKAGE_TYPE[\"WEEKLY\"] = \"WEEKLY\";\n})(PACKAGE_TYPE || (PACKAGE_TYPE = {}));\nexport var INTRO_ELIGIBILITY_STATUS;\n(function (INTRO_ELIGIBILITY_STATUS) {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_UNKNOWN\"] = 0] = \"INTRO_ELIGIBILITY_STATUS_UNKNOWN\";\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\"] = 1] = \"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\";\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\"] = 2] = \"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\";\n})(INTRO_ELIGIBILITY_STATUS || (INTRO_ELIGIBILITY_STATUS = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NativePurchases = registerPlugin(\"NativePurchases\", {\n web: () => import(\"./web\").then((m) => new m.NativePurchasesWeb()),\n});\nexport * from \"./definitions\";\nexport { NativePurchases };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport const mockCustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\nexport class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n async getProducts(options) {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n async purchaseProduct(options) {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n async isBillingSupported() {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion() {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ATTRIBUTION_NETWORK","PURCHASE_TYPE","BILLING_FEATURE","PRORATION_MODE","PACKAGE_TYPE","INTRO_ELIGIBILITY_STATUS","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,yCAAoB;IAC/B,CAAC,UAAU,mBAAmB,EAAE;IAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB,CAAC;IAC1F,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;IAC5E,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAC1E,CAAC,EAAEA,2BAAmB,KAAKA,2BAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;AAC3CC,mCAAc;IACzB,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACrC;IACA;IACA;IACA,IAAI,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aAAa,EAAE,eAAe,EAAE,CAAC;IAClD,KAAK;IACL,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC/D,QAAQ,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IAC7C,KAAK;IACL,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACzD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACtC,KAAK;IACL;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ATTRIBUTION_NETWORK;\n(function (ATTRIBUTION_NETWORK) {\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPLE_SEARCH_ADS\"] = 0] = \"APPLE_SEARCH_ADS\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"ADJUST\"] = 1] = \"ADJUST\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"APPSFLYER\"] = 2] = \"APPSFLYER\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"BRANCH\"] = 3] = \"BRANCH\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"TENJIN\"] = 4] = \"TENJIN\";\n ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK[\"FACEBOOK\"] = 5] = \"FACEBOOK\";\n})(ATTRIBUTION_NETWORK || (ATTRIBUTION_NETWORK = {}));\nexport var PURCHASE_TYPE;\n(function (PURCHASE_TYPE) {\n /**\n * A type of SKU for in-app products.\n */\n PURCHASE_TYPE[\"INAPP\"] = \"inapp\";\n /**\n * A type of SKU for subscriptions.\n */\n PURCHASE_TYPE[\"SUBS\"] = \"subs\";\n})(PURCHASE_TYPE || (PURCHASE_TYPE = {}));\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport var BILLING_FEATURE;\n(function (BILLING_FEATURE) {\n /**\n * Purchase/query for subscriptions.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS\"] = 0] = \"SUBSCRIPTIONS\";\n /**\n * Subscriptions update/replace.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_UPDATE\"] = 1] = \"SUBSCRIPTIONS_UPDATE\";\n /**\n * Purchase/query for in-app items on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"IN_APP_ITEMS_ON_VR\"] = 2] = \"IN_APP_ITEMS_ON_VR\";\n /**\n * Purchase/query for subscriptions on VR.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"SUBSCRIPTIONS_ON_VR\"] = 3] = \"SUBSCRIPTIONS_ON_VR\";\n /**\n * Launch a price change confirmation flow.\n */\n BILLING_FEATURE[BILLING_FEATURE[\"PRICE_CHANGE_CONFIRMATION\"] = 4] = \"PRICE_CHANGE_CONFIRMATION\";\n})(BILLING_FEATURE || (BILLING_FEATURE = {}));\nexport var PRORATION_MODE;\n(function (PRORATION_MODE) {\n PRORATION_MODE[PRORATION_MODE[\"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\"] = 0] = \"UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY\";\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITH_TIME_PRORATION\"] = 1] = \"IMMEDIATE_WITH_TIME_PRORATION\";\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\"] = 2] = \"IMMEDIATE_AND_CHARGE_PRORATED_PRICE\";\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n PRORATION_MODE[PRORATION_MODE[\"IMMEDIATE_WITHOUT_PRORATION\"] = 3] = \"IMMEDIATE_WITHOUT_PRORATION\";\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n PRORATION_MODE[PRORATION_MODE[\"DEFERRED\"] = 4] = \"DEFERRED\";\n})(PRORATION_MODE || (PRORATION_MODE = {}));\nexport var PACKAGE_TYPE;\n(function (PACKAGE_TYPE) {\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"UNKNOWN\"] = \"UNKNOWN\";\n /**\n * A package that was defined with a custom identifier.\n */\n PACKAGE_TYPE[\"CUSTOM\"] = \"CUSTOM\";\n /**\n * A package configured with the predefined lifetime identifier.\n */\n PACKAGE_TYPE[\"LIFETIME\"] = \"LIFETIME\";\n /**\n * A package configured with the predefined annual identifier.\n */\n PACKAGE_TYPE[\"ANNUAL\"] = \"ANNUAL\";\n /**\n * A package configured with the predefined six month identifier.\n */\n PACKAGE_TYPE[\"SIX_MONTH\"] = \"SIX_MONTH\";\n /**\n * A package configured with the predefined three month identifier.\n */\n PACKAGE_TYPE[\"THREE_MONTH\"] = \"THREE_MONTH\";\n /**\n * A package configured with the predefined two month identifier.\n */\n PACKAGE_TYPE[\"TWO_MONTH\"] = \"TWO_MONTH\";\n /**\n * A package configured with the predefined monthly identifier.\n */\n PACKAGE_TYPE[\"MONTHLY\"] = \"MONTHLY\";\n /**\n * A package configured with the predefined weekly identifier.\n */\n PACKAGE_TYPE[\"WEEKLY\"] = \"WEEKLY\";\n})(PACKAGE_TYPE || (PACKAGE_TYPE = {}));\nexport var INTRO_ELIGIBILITY_STATUS;\n(function (INTRO_ELIGIBILITY_STATUS) {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_UNKNOWN\"] = 0] = \"INTRO_ELIGIBILITY_STATUS_UNKNOWN\";\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\"] = 1] = \"INTRO_ELIGIBILITY_STATUS_INELIGIBLE\";\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS[\"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\"] = 2] = \"INTRO_ELIGIBILITY_STATUS_ELIGIBLE\";\n})(INTRO_ELIGIBILITY_STATUS || (INTRO_ELIGIBILITY_STATUS = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from \"@capacitor/core\";\nconst NativePurchases = registerPlugin(\"NativePurchases\", {\n web: () => import(\"./web\").then((m) => new m.NativePurchasesWeb()),\n});\nexport * from \"./definitions\";\nexport { NativePurchases };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport const mockCustomerInfo = {\n activeSubscriptions: [\"\"],\n allPurchasedProductIdentifiers: [\"\"],\n nonSubscriptionTransactions: [],\n latestExpirationDate: null,\n firstSeen: \"2020-01-01T00:00:00.000Z\",\n originalAppUserId: \"\",\n requestDate: \"2020-01-01T00:00:00.000Z\",\n originalApplicationVersion: \"\",\n originalPurchaseDate: null,\n managementURL: null,\n};\nexport class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error(\"purchasePackage only mocked in web\");\n return { customerInfo: mockCustomerInfo };\n }\n async getProducts(options) {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n async getProduct(options) {\n console.error(\"getProduct only mocked in web \" + options);\n return { product: {} };\n }\n async purchaseProduct(options) {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\n }\n async isBillingSupported() {\n console.error(\"isBillingSupported only mocked in web\");\n return { isBillingSupported: false };\n }\n async getPluginVersion() {\n console.warn(\"Cannot get plugin version in web\");\n return { version: \"default\" };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ATTRIBUTION_NETWORK","PURCHASE_TYPE","BILLING_FEATURE","PRORATION_MODE","PACKAGE_TYPE","INTRO_ELIGIBILITY_STATUS","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,yCAAoB;IAC/B,CAAC,UAAU,mBAAmB,EAAE;IAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB,CAAC;IAC1F,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;IAC5E,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACtE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAC1E,CAAC,EAAEA,2BAAmB,KAAKA,2BAAmB,GAAG,EAAE,CAAC,CAAC,CAAC;AAC3CC,mCAAc;IACzB,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACrC;IACA;IACA;IACA,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACnC,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1C;IACA;IACA;IACA;IACA;AACWC,qCAAgB;IAC3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E,QAAQ,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;IAClD,KAAK;IACL,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC/D,QAAQ,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IAC7C,KAAK;IACL,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACzD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACtC,KAAK;IACL;;;;;;;;;;;;;;;;;;"}
|
|
@@ -40,7 +40,10 @@ public class NativePurchasesPlugin: CAPPlugin {
|
|
|
40
40
|
Task {
|
|
41
41
|
do {
|
|
42
42
|
let products = try await Product.products(for: [productIdentifier])
|
|
43
|
-
let product = products
|
|
43
|
+
guard let product = products.first else {
|
|
44
|
+
call.reject("Cannot find product for id \(productIdentifier)")
|
|
45
|
+
return
|
|
46
|
+
}
|
|
44
47
|
var purchaseOptions = Set<Product.PurchaseOption>()
|
|
45
48
|
purchaseOptions.insert(Product.PurchaseOption.quantity(quantity))
|
|
46
49
|
let result = try await product.purchase(options: purchaseOptions)
|
|
@@ -121,4 +124,34 @@ public class NativePurchasesPlugin: CAPPlugin {
|
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
@objc func getProduct(_ call: CAPPluginCall) {
|
|
128
|
+
if #available(iOS 15.0, *) {
|
|
129
|
+
let productIdentifier = call.getString("productIdentifier") ?? ""
|
|
130
|
+
if productIdentifier.isEmpty {
|
|
131
|
+
call.reject("productIdentifier is empty")
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
DispatchQueue.global().async {
|
|
136
|
+
Task {
|
|
137
|
+
do {
|
|
138
|
+
let products = try await Product.products(for: [productIdentifier])
|
|
139
|
+
if let product = products.first {
|
|
140
|
+
let productJson = product.dictionary
|
|
141
|
+
call.resolve(["product": productJson])
|
|
142
|
+
} else {
|
|
143
|
+
call.reject("Product not found")
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
print(error)
|
|
147
|
+
call.reject(error.localizedDescription)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
print("Not implemented under iOS 15")
|
|
153
|
+
call.reject("Not implemented under iOS 15")
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
124
157
|
}
|