@capgo/native-purchases 7.15.5 → 7.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +152 -1
- package/dist/docs.json +228 -0
- package/dist/esm/definitions.d.ts +144 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +10 -1
- package/dist/esm/web.js +19 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +19 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +19 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin.swift +118 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1421,6 +1421,8 @@ This approach balances immediate user gratification with proper server-side vali
|
|
|
1421
1421
|
<docgen-index>
|
|
1422
1422
|
|
|
1423
1423
|
* [`restorePurchases()`](#restorepurchases)
|
|
1424
|
+
* [`getAppTransaction()`](#getapptransaction)
|
|
1425
|
+
* [`isEntitledToOldBusinessModel(...)`](#isentitledtooldbusinessmodel)
|
|
1424
1426
|
* [`purchaseProduct(...)`](#purchaseproduct)
|
|
1425
1427
|
* [`getProducts(...)`](#getproducts)
|
|
1426
1428
|
* [`getProduct(...)`](#getproduct)
|
|
@@ -1451,6 +1453,61 @@ Restores a user's previous and links their appUserIDs to any user's also using
|
|
|
1451
1453
|
--------------------
|
|
1452
1454
|
|
|
1453
1455
|
|
|
1456
|
+
### getAppTransaction()
|
|
1457
|
+
|
|
1458
|
+
```typescript
|
|
1459
|
+
getAppTransaction() => Promise<{ appTransaction: AppTransaction; }>
|
|
1460
|
+
```
|
|
1461
|
+
|
|
1462
|
+
Gets the App <a href="#transaction">Transaction</a> information, which provides details about when the user
|
|
1463
|
+
originally downloaded or purchased the app.
|
|
1464
|
+
|
|
1465
|
+
This is useful for implementing business model changes where you want to
|
|
1466
|
+
grandfather users who originally downloaded an earlier version of the app.
|
|
1467
|
+
|
|
1468
|
+
**Use Case Example:**
|
|
1469
|
+
If your app was originally free but you're adding a subscription, you can use
|
|
1470
|
+
`originalAppVersion` to check if users downloaded before the subscription was added
|
|
1471
|
+
and give them free access.
|
|
1472
|
+
|
|
1473
|
+
**Platform Notes:**
|
|
1474
|
+
- **iOS**: Requires iOS 16.0+. Uses StoreKit 2's <a href="#apptransaction">`AppTransaction</a>.shared`.
|
|
1475
|
+
- **Android**: Uses Google Play's install referrer data when available.
|
|
1476
|
+
|
|
1477
|
+
**Returns:** <code>Promise<{ appTransaction: <a href="#apptransaction">AppTransaction</a>; }></code>
|
|
1478
|
+
|
|
1479
|
+
**Since:** 7.16.0
|
|
1480
|
+
|
|
1481
|
+
--------------------
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
### isEntitledToOldBusinessModel(...)
|
|
1485
|
+
|
|
1486
|
+
```typescript
|
|
1487
|
+
isEntitledToOldBusinessModel(options: { targetVersion: string; }) => Promise<{ isOlderVersion: boolean; originalAppVersion: string; }>
|
|
1488
|
+
```
|
|
1489
|
+
|
|
1490
|
+
Compares the original app version from the App <a href="#transaction">Transaction</a> against a target version
|
|
1491
|
+
to determine if the user is entitled to features from an earlier business model.
|
|
1492
|
+
|
|
1493
|
+
This is a utility method that performs the version comparison natively, which can be
|
|
1494
|
+
more reliable than JavaScript-based comparison for semantic versioning.
|
|
1495
|
+
|
|
1496
|
+
**Use Case:**
|
|
1497
|
+
Check if the user's original download version is older than a specific version
|
|
1498
|
+
to determine if they should be grandfathered into free features.
|
|
1499
|
+
|
|
1500
|
+
| Param | Type | Description |
|
|
1501
|
+
| ------------- | --------------------------------------- | ------------------------ |
|
|
1502
|
+
| **`options`** | <code>{ targetVersion: string; }</code> | - The comparison options |
|
|
1503
|
+
|
|
1504
|
+
**Returns:** <code>Promise<{ isOlderVersion: boolean; originalAppVersion: string; }></code>
|
|
1505
|
+
|
|
1506
|
+
**Since:** 7.16.0
|
|
1507
|
+
|
|
1508
|
+
--------------------
|
|
1509
|
+
|
|
1510
|
+
|
|
1454
1511
|
### purchaseProduct(...)
|
|
1455
1512
|
|
|
1456
1513
|
```typescript
|
|
@@ -1664,6 +1721,22 @@ Remove all registered listeners
|
|
|
1664
1721
|
### Interfaces
|
|
1665
1722
|
|
|
1666
1723
|
|
|
1724
|
+
#### AppTransaction
|
|
1725
|
+
|
|
1726
|
+
Represents the App <a href="#transaction">Transaction</a> information from StoreKit 2.
|
|
1727
|
+
This provides details about when the user originally downloaded or purchased the app,
|
|
1728
|
+
which is useful for determining if users are entitled to features from earlier business models.
|
|
1729
|
+
|
|
1730
|
+
| Prop | Type | Description | Since |
|
|
1731
|
+
| -------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
|
|
1732
|
+
| **`originalAppVersion`** | <code>string</code> | The app version that the user originally purchased or downloaded. Use this to determine if users who originally downloaded an earlier version should be entitled to features that were previously free or included. For iOS: This is the `CFBundleShortVersionString` (e.g., "1.0.0") For Android: This is the `versionName` from Google Play (e.g., "1.0.0") | 7.16.0 |
|
|
1733
|
+
| **`originalPurchaseDate`** | <code>string</code> | The date when the user originally purchased or downloaded the app. ISO 8601 format. | 7.16.0 |
|
|
1734
|
+
| **`bundleId`** | <code>string</code> | The bundle identifier of the app. | 7.16.0 |
|
|
1735
|
+
| **`appVersion`** | <code>string</code> | The current app version installed on the device. | 7.16.0 |
|
|
1736
|
+
| **`environment`** | <code>'Sandbox' \| 'Production' \| 'Xcode' \| null</code> | The server environment where the app was originally purchased. | 7.16.0 |
|
|
1737
|
+
| **`jwsRepresentation`** | <code>string</code> | The JWS (JSON Web Signature) representation of the app transaction. Can be sent to your backend for server-side verification. | 7.16.0 |
|
|
1738
|
+
|
|
1739
|
+
|
|
1667
1740
|
#### Transaction
|
|
1668
1741
|
|
|
1669
1742
|
| Prop | Type | Description | Default | Since |
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
package ee.forgr.nativepurchases;
|
|
2
2
|
|
|
3
|
+
import android.content.pm.PackageInfo;
|
|
4
|
+
import android.content.pm.PackageManager;
|
|
5
|
+
import android.os.Build;
|
|
3
6
|
import android.util.Log;
|
|
4
7
|
import androidx.annotation.NonNull;
|
|
5
8
|
import com.android.billingclient.api.AccountIdentifiers;
|
|
@@ -39,7 +42,7 @@ import org.json.JSONArray;
|
|
|
39
42
|
@CapacitorPlugin(name = "NativePurchases")
|
|
40
43
|
public class NativePurchasesPlugin extends Plugin {
|
|
41
44
|
|
|
42
|
-
private final String pluginVersion = "7.
|
|
45
|
+
private final String pluginVersion = "7.16.0";
|
|
43
46
|
public static final String TAG = "NativePurchases";
|
|
44
47
|
private static final Phaser semaphoreReady = new Phaser(1);
|
|
45
48
|
private BillingClient billingClient;
|
|
@@ -1012,4 +1015,152 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
1012
1015
|
call.reject(e.getMessage());
|
|
1013
1016
|
}
|
|
1014
1017
|
}
|
|
1018
|
+
|
|
1019
|
+
@PluginMethod
|
|
1020
|
+
public void getAppTransaction(PluginCall call) {
|
|
1021
|
+
Log.d(TAG, "getAppTransaction() called");
|
|
1022
|
+
try {
|
|
1023
|
+
PackageManager pm = getContext().getPackageManager();
|
|
1024
|
+
String packageName = getContext().getPackageName();
|
|
1025
|
+
|
|
1026
|
+
PackageInfo packageInfo;
|
|
1027
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
1028
|
+
packageInfo = pm.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0));
|
|
1029
|
+
} else {
|
|
1030
|
+
packageInfo = pm.getPackageInfo(packageName, 0);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
JSObject appTransaction = new JSObject();
|
|
1034
|
+
|
|
1035
|
+
// Get version name (e.g., "1.0.0")
|
|
1036
|
+
String versionName = packageInfo.versionName != null ? packageInfo.versionName : "1.0.0";
|
|
1037
|
+
appTransaction.put("appVersion", versionName);
|
|
1038
|
+
|
|
1039
|
+
// For Android, we can't get the "original" version when the user first downloaded
|
|
1040
|
+
// from Google Play like iOS can. The firstInstallTime is per-device, not per-account.
|
|
1041
|
+
// We use firstInstallTime date and current version as "original" which is the best we can do.
|
|
1042
|
+
// For accurate original version tracking, developers should implement server-side tracking
|
|
1043
|
+
// using Google Play Developer API or their own backend.
|
|
1044
|
+
appTransaction.put("originalAppVersion", versionName);
|
|
1045
|
+
|
|
1046
|
+
// First install time on this device (milliseconds since epoch)
|
|
1047
|
+
long firstInstallTime = packageInfo.firstInstallTime;
|
|
1048
|
+
String originalPurchaseDate = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", java.util.Locale.US).format(
|
|
1049
|
+
new java.util.Date(firstInstallTime)
|
|
1050
|
+
);
|
|
1051
|
+
appTransaction.put("originalPurchaseDate", originalPurchaseDate);
|
|
1052
|
+
|
|
1053
|
+
// Package name (bundle ID equivalent)
|
|
1054
|
+
appTransaction.put("bundleId", packageName);
|
|
1055
|
+
|
|
1056
|
+
// Android doesn't have environment like iOS (Sandbox/Production)
|
|
1057
|
+
appTransaction.put("environment", null);
|
|
1058
|
+
|
|
1059
|
+
// Android doesn't have JWS representation
|
|
1060
|
+
// jwsRepresentation is not set (will be undefined in JS)
|
|
1061
|
+
|
|
1062
|
+
Log.d(TAG, "App transaction - version: " + versionName + ", firstInstall: " + originalPurchaseDate);
|
|
1063
|
+
|
|
1064
|
+
JSObject result = new JSObject();
|
|
1065
|
+
result.put("appTransaction", appTransaction);
|
|
1066
|
+
call.resolve(result);
|
|
1067
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
1068
|
+
Log.d(TAG, "getAppTransaction() error: " + e.getMessage());
|
|
1069
|
+
call.reject("Failed to get package info: " + e.getMessage());
|
|
1070
|
+
} catch (Exception e) {
|
|
1071
|
+
Log.d(TAG, "getAppTransaction() error: " + e.getMessage());
|
|
1072
|
+
call.reject("Failed to get app transaction: " + e.getMessage());
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
@PluginMethod
|
|
1077
|
+
public void isEntitledToOldBusinessModel(PluginCall call) {
|
|
1078
|
+
Log.d(TAG, "isEntitledToOldBusinessModel() called");
|
|
1079
|
+
String targetVersion = call.getString("targetVersion");
|
|
1080
|
+
|
|
1081
|
+
if (targetVersion == null || targetVersion.isEmpty()) {
|
|
1082
|
+
Log.d(TAG, "Error: targetVersion is empty");
|
|
1083
|
+
call.reject("targetVersion is required");
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
try {
|
|
1088
|
+
PackageManager pm = getContext().getPackageManager();
|
|
1089
|
+
String packageName = getContext().getPackageName();
|
|
1090
|
+
|
|
1091
|
+
PackageInfo packageInfo;
|
|
1092
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
1093
|
+
packageInfo = pm.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0));
|
|
1094
|
+
} else {
|
|
1095
|
+
packageInfo = pm.getPackageInfo(packageName, 0);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Get current version name as "original" version
|
|
1099
|
+
// Note: On Android, we can't get the actual original version from Google Play
|
|
1100
|
+
// This uses the current installed version which may not be accurate
|
|
1101
|
+
String originalVersion = packageInfo.versionName != null ? packageInfo.versionName : "1.0.0";
|
|
1102
|
+
|
|
1103
|
+
// Compare versions
|
|
1104
|
+
boolean isOlder = compareVersions(originalVersion, targetVersion) < 0;
|
|
1105
|
+
|
|
1106
|
+
Log.d(
|
|
1107
|
+
TAG,
|
|
1108
|
+
"isEntitledToOldBusinessModel - original: " + originalVersion + ", target: " + targetVersion + ", isOlder: " + isOlder
|
|
1109
|
+
);
|
|
1110
|
+
|
|
1111
|
+
JSObject result = new JSObject();
|
|
1112
|
+
result.put("isOlderVersion", isOlder);
|
|
1113
|
+
result.put("originalAppVersion", originalVersion);
|
|
1114
|
+
call.resolve(result);
|
|
1115
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
1116
|
+
Log.d(TAG, "isEntitledToOldBusinessModel() error: " + e.getMessage());
|
|
1117
|
+
call.reject("Failed to get package info: " + e.getMessage());
|
|
1118
|
+
} catch (Exception e) {
|
|
1119
|
+
Log.d(TAG, "isEntitledToOldBusinessModel() error: " + e.getMessage());
|
|
1120
|
+
call.reject("Failed to check business model entitlement: " + e.getMessage());
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Compares two semantic version strings.
|
|
1126
|
+
* Returns: negative if v1 < v2, zero if v1 == v2, positive if v1 > v2
|
|
1127
|
+
*/
|
|
1128
|
+
private int compareVersions(String version1, String version2) {
|
|
1129
|
+
String[] v1Parts = version1.split("\\.");
|
|
1130
|
+
String[] v2Parts = version2.split("\\.");
|
|
1131
|
+
|
|
1132
|
+
int maxLength = Math.max(v1Parts.length, v2Parts.length);
|
|
1133
|
+
|
|
1134
|
+
for (int i = 0; i < maxLength; i++) {
|
|
1135
|
+
int v1Value = 0;
|
|
1136
|
+
int v2Value = 0;
|
|
1137
|
+
|
|
1138
|
+
if (i < v1Parts.length) {
|
|
1139
|
+
try {
|
|
1140
|
+
// Handle versions with non-numeric suffixes like "1.0.0-beta"
|
|
1141
|
+
String v1Part = v1Parts[i].replaceAll("[^0-9].*", "");
|
|
1142
|
+
v1Value = v1Part.isEmpty() ? 0 : Integer.parseInt(v1Part);
|
|
1143
|
+
} catch (NumberFormatException e) {
|
|
1144
|
+
v1Value = 0;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
if (i < v2Parts.length) {
|
|
1149
|
+
try {
|
|
1150
|
+
String v2Part = v2Parts[i].replaceAll("[^0-9].*", "");
|
|
1151
|
+
v2Value = v2Part.isEmpty() ? 0 : Integer.parseInt(v2Part);
|
|
1152
|
+
} catch (NumberFormatException e) {
|
|
1153
|
+
v2Value = 0;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
if (v1Value < v2Value) {
|
|
1158
|
+
return -1;
|
|
1159
|
+
} else if (v1Value > v2Value) {
|
|
1160
|
+
return 1;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
return 0;
|
|
1165
|
+
}
|
|
1015
1166
|
}
|
package/dist/docs.json
CHANGED
|
@@ -15,6 +15,80 @@
|
|
|
15
15
|
"complexTypes": [],
|
|
16
16
|
"slug": "restorepurchases"
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
"name": "getAppTransaction",
|
|
20
|
+
"signature": "() => Promise<{ appTransaction: AppTransaction; }>",
|
|
21
|
+
"parameters": [],
|
|
22
|
+
"returns": "Promise<{ appTransaction: AppTransaction; }>",
|
|
23
|
+
"tags": [
|
|
24
|
+
{
|
|
25
|
+
"name": "returns",
|
|
26
|
+
"text": "The app transaction info"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "throws",
|
|
30
|
+
"text": "An error if the app transaction cannot be retrieved (iOS 15 or earlier)"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "since",
|
|
34
|
+
"text": "7.16.0"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "example",
|
|
38
|
+
"text": "```typescript\nconst { appTransaction } = await NativePurchases.getAppTransaction();\n\n// Check if user downloaded before version 2.0.0 (when subscription was added)\nif (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {\n // User gets free access - they downloaded before subscriptions\n grantFreeAccess();\n}\n```"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "see",
|
|
42
|
+
"text": "https ://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"docs": "Gets the App Transaction information, which provides details about when the user\noriginally downloaded or purchased the app.\n\nThis is useful for implementing business model changes where you want to\ngrandfather users who originally downloaded an earlier version of the app.\n\n**Use Case Example:**\nIf your app was originally free but you're adding a subscription, you can use\n`originalAppVersion` to check if users downloaded before the subscription was added\nand give them free access.\n\n**Platform Notes:**\n- **iOS**: Requires iOS 16.0+. Uses StoreKit 2's `AppTransaction.shared`.\n- **Android**: Uses Google Play's install referrer data when available.",
|
|
46
|
+
"complexTypes": [
|
|
47
|
+
"AppTransaction"
|
|
48
|
+
],
|
|
49
|
+
"slug": "getapptransaction"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "isEntitledToOldBusinessModel",
|
|
53
|
+
"signature": "(options: { targetVersion: string; }) => Promise<{ isOlderVersion: boolean; originalAppVersion: string; }>",
|
|
54
|
+
"parameters": [
|
|
55
|
+
{
|
|
56
|
+
"name": "options",
|
|
57
|
+
"docs": "- The comparison options",
|
|
58
|
+
"type": "{ targetVersion: string; }"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"returns": "Promise<{ isOlderVersion: boolean; originalAppVersion: string; }>",
|
|
62
|
+
"tags": [
|
|
63
|
+
{
|
|
64
|
+
"name": "param",
|
|
65
|
+
"text": "options - The comparison options"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "param",
|
|
69
|
+
"text": "options.targetVersion - The version to compare against (e.g., \"2.0.0\")"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "returns",
|
|
73
|
+
"text": "- `isOlderVersion`: true if the user's original version is older than targetVersion\n- `originalAppVersion`: The user's original app version for reference"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "throws",
|
|
77
|
+
"text": "An error if the app transaction cannot be retrieved"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "since",
|
|
81
|
+
"text": "7.16.0"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "example",
|
|
85
|
+
"text": "```typescript\n// Check if user downloaded before version 2.0.0 (when subscription was added)\nconst result = await NativePurchases.isEntitledToOldBusinessModel({\n targetVersion: '2.0.0'\n});\n\nif (result.isOlderVersion) {\n console.log(`User downloaded v${result.originalAppVersion}, granting free access`);\n grantFreeAccess();\n}\n```"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"docs": "Compares the original app version from the App Transaction against a target version\nto determine if the user is entitled to features from an earlier business model.\n\nThis is a utility method that performs the version comparison natively, which can be\nmore reliable than JavaScript-based comparison for semantic versioning.\n\n**Use Case:**\nCheck if the user's original download version is older than a specific version\nto determine if they should be grandfathered into free features.",
|
|
89
|
+
"complexTypes": [],
|
|
90
|
+
"slug": "isentitledtooldbusinessmodel"
|
|
91
|
+
},
|
|
18
92
|
{
|
|
19
93
|
"name": "purchaseProduct",
|
|
20
94
|
"signature": "(options: { productIdentifier: string; planIdentifier?: string; productType?: PURCHASE_TYPE; quantity?: number; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }) => Promise<Transaction>",
|
|
@@ -346,6 +420,160 @@
|
|
|
346
420
|
"properties": []
|
|
347
421
|
},
|
|
348
422
|
"interfaces": [
|
|
423
|
+
{
|
|
424
|
+
"name": "AppTransaction",
|
|
425
|
+
"slug": "apptransaction",
|
|
426
|
+
"docs": "Represents the App Transaction information from StoreKit 2.\nThis provides details about when the user originally downloaded or purchased the app,\nwhich is useful for determining if users are entitled to features from earlier business models.",
|
|
427
|
+
"tags": [
|
|
428
|
+
{
|
|
429
|
+
"text": "https ://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction",
|
|
430
|
+
"name": "see"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"text": "7.16.0",
|
|
434
|
+
"name": "since"
|
|
435
|
+
}
|
|
436
|
+
],
|
|
437
|
+
"methods": [],
|
|
438
|
+
"properties": [
|
|
439
|
+
{
|
|
440
|
+
"name": "originalAppVersion",
|
|
441
|
+
"tags": [
|
|
442
|
+
{
|
|
443
|
+
"text": "\"1.0.0\"",
|
|
444
|
+
"name": "example"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"text": "7.16.0",
|
|
448
|
+
"name": "since"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"text": "ios Always present (iOS 16+)",
|
|
452
|
+
"name": "platform"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"text": "android Always present",
|
|
456
|
+
"name": "platform"
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
"docs": "The app version that the user originally purchased or downloaded.\n\nUse this to determine if users who originally downloaded an earlier version\nshould be entitled to features that were previously free or included.\n\nFor iOS: This is the `CFBundleShortVersionString` (e.g., \"1.0.0\")\nFor Android: This is the `versionName` from Google Play (e.g., \"1.0.0\")",
|
|
460
|
+
"complexTypes": [],
|
|
461
|
+
"type": "string"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"name": "originalPurchaseDate",
|
|
465
|
+
"tags": [
|
|
466
|
+
{
|
|
467
|
+
"text": "\"2023-06-15T10:30:00Z\"",
|
|
468
|
+
"name": "example"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"text": "7.16.0",
|
|
472
|
+
"name": "since"
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
"text": "ios Always present (iOS 16+)",
|
|
476
|
+
"name": "platform"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"text": "android Always present",
|
|
480
|
+
"name": "platform"
|
|
481
|
+
}
|
|
482
|
+
],
|
|
483
|
+
"docs": "The date when the user originally purchased or downloaded the app.\nISO 8601 format.",
|
|
484
|
+
"complexTypes": [],
|
|
485
|
+
"type": "string"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"name": "bundleId",
|
|
489
|
+
"tags": [
|
|
490
|
+
{
|
|
491
|
+
"text": "\"com.example.myapp\"",
|
|
492
|
+
"name": "example"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"text": "7.16.0",
|
|
496
|
+
"name": "since"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"text": "ios Always present (iOS 16+)",
|
|
500
|
+
"name": "platform"
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"text": "android Always present (package name)",
|
|
504
|
+
"name": "platform"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
"docs": "The bundle identifier of the app.",
|
|
508
|
+
"complexTypes": [],
|
|
509
|
+
"type": "string"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"name": "appVersion",
|
|
513
|
+
"tags": [
|
|
514
|
+
{
|
|
515
|
+
"text": "\"2.0.0\"",
|
|
516
|
+
"name": "example"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
"text": "7.16.0",
|
|
520
|
+
"name": "since"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
"text": "ios Always present",
|
|
524
|
+
"name": "platform"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"text": "android Always present",
|
|
528
|
+
"name": "platform"
|
|
529
|
+
}
|
|
530
|
+
],
|
|
531
|
+
"docs": "The current app version installed on the device.",
|
|
532
|
+
"complexTypes": [],
|
|
533
|
+
"type": "string"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"name": "environment",
|
|
537
|
+
"tags": [
|
|
538
|
+
{
|
|
539
|
+
"text": "7.16.0",
|
|
540
|
+
"name": "since"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
"text": "ios Present (iOS 16+)",
|
|
544
|
+
"name": "platform"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"text": "android Not available (always null)",
|
|
548
|
+
"name": "platform"
|
|
549
|
+
}
|
|
550
|
+
],
|
|
551
|
+
"docs": "The server environment where the app was originally purchased.",
|
|
552
|
+
"complexTypes": [],
|
|
553
|
+
"type": "'Sandbox' | 'Production' | 'Xcode' | null | undefined"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"name": "jwsRepresentation",
|
|
557
|
+
"tags": [
|
|
558
|
+
{
|
|
559
|
+
"text": "7.16.0",
|
|
560
|
+
"name": "since"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"text": "ios Present (iOS 16+)",
|
|
564
|
+
"name": "platform"
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
"text": "android Not available",
|
|
568
|
+
"name": "platform"
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
"docs": "The JWS (JSON Web Signature) representation of the app transaction.\nCan be sent to your backend for server-side verification.",
|
|
572
|
+
"complexTypes": [],
|
|
573
|
+
"type": "string | undefined"
|
|
574
|
+
}
|
|
575
|
+
]
|
|
576
|
+
},
|
|
349
577
|
{
|
|
350
578
|
"name": "Transaction",
|
|
351
579
|
"slug": "transaction",
|
|
@@ -468,6 +468,76 @@ export interface TransactionVerificationFailedEvent {
|
|
|
468
468
|
*/
|
|
469
469
|
readonly error: string;
|
|
470
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Represents the App Transaction information from StoreKit 2.
|
|
473
|
+
* This provides details about when the user originally downloaded or purchased the app,
|
|
474
|
+
* which is useful for determining if users are entitled to features from earlier business models.
|
|
475
|
+
*
|
|
476
|
+
* @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction
|
|
477
|
+
* @since 7.16.0
|
|
478
|
+
*/
|
|
479
|
+
export interface AppTransaction {
|
|
480
|
+
/**
|
|
481
|
+
* The app version that the user originally purchased or downloaded.
|
|
482
|
+
*
|
|
483
|
+
* Use this to determine if users who originally downloaded an earlier version
|
|
484
|
+
* should be entitled to features that were previously free or included.
|
|
485
|
+
*
|
|
486
|
+
* For iOS: This is the `CFBundleShortVersionString` (e.g., "1.0.0")
|
|
487
|
+
* For Android: This is the `versionName` from Google Play (e.g., "1.0.0")
|
|
488
|
+
*
|
|
489
|
+
* @example "1.0.0"
|
|
490
|
+
* @since 7.16.0
|
|
491
|
+
* @platform ios Always present (iOS 16+)
|
|
492
|
+
* @platform android Always present
|
|
493
|
+
*/
|
|
494
|
+
readonly originalAppVersion: string;
|
|
495
|
+
/**
|
|
496
|
+
* The date when the user originally purchased or downloaded the app.
|
|
497
|
+
* ISO 8601 format.
|
|
498
|
+
*
|
|
499
|
+
* @example "2023-06-15T10:30:00Z"
|
|
500
|
+
* @since 7.16.0
|
|
501
|
+
* @platform ios Always present (iOS 16+)
|
|
502
|
+
* @platform android Always present
|
|
503
|
+
*/
|
|
504
|
+
readonly originalPurchaseDate: string;
|
|
505
|
+
/**
|
|
506
|
+
* The bundle identifier of the app.
|
|
507
|
+
*
|
|
508
|
+
* @example "com.example.myapp"
|
|
509
|
+
* @since 7.16.0
|
|
510
|
+
* @platform ios Always present (iOS 16+)
|
|
511
|
+
* @platform android Always present (package name)
|
|
512
|
+
*/
|
|
513
|
+
readonly bundleId: string;
|
|
514
|
+
/**
|
|
515
|
+
* The current app version installed on the device.
|
|
516
|
+
*
|
|
517
|
+
* @example "2.0.0"
|
|
518
|
+
* @since 7.16.0
|
|
519
|
+
* @platform ios Always present
|
|
520
|
+
* @platform android Always present
|
|
521
|
+
*/
|
|
522
|
+
readonly appVersion: string;
|
|
523
|
+
/**
|
|
524
|
+
* The server environment where the app was originally purchased.
|
|
525
|
+
*
|
|
526
|
+
* @since 7.16.0
|
|
527
|
+
* @platform ios Present (iOS 16+)
|
|
528
|
+
* @platform android Not available (always null)
|
|
529
|
+
*/
|
|
530
|
+
readonly environment?: 'Sandbox' | 'Production' | 'Xcode' | null;
|
|
531
|
+
/**
|
|
532
|
+
* The JWS (JSON Web Signature) representation of the app transaction.
|
|
533
|
+
* Can be sent to your backend for server-side verification.
|
|
534
|
+
*
|
|
535
|
+
* @since 7.16.0
|
|
536
|
+
* @platform ios Present (iOS 16+)
|
|
537
|
+
* @platform android Not available
|
|
538
|
+
*/
|
|
539
|
+
readonly jwsRepresentation?: string;
|
|
540
|
+
}
|
|
471
541
|
export interface SubscriptionPeriod {
|
|
472
542
|
/**
|
|
473
543
|
* The Subscription Period number of unit.
|
|
@@ -571,6 +641,80 @@ export interface NativePurchasesPlugin {
|
|
|
571
641
|
* Restores a user's previous and links their appUserIDs to any user's also using those .
|
|
572
642
|
*/
|
|
573
643
|
restorePurchases(): Promise<void>;
|
|
644
|
+
/**
|
|
645
|
+
* Gets the App Transaction information, which provides details about when the user
|
|
646
|
+
* originally downloaded or purchased the app.
|
|
647
|
+
*
|
|
648
|
+
* This is useful for implementing business model changes where you want to
|
|
649
|
+
* grandfather users who originally downloaded an earlier version of the app.
|
|
650
|
+
*
|
|
651
|
+
* **Use Case Example:**
|
|
652
|
+
* If your app was originally free but you're adding a subscription, you can use
|
|
653
|
+
* `originalAppVersion` to check if users downloaded before the subscription was added
|
|
654
|
+
* and give them free access.
|
|
655
|
+
*
|
|
656
|
+
* **Platform Notes:**
|
|
657
|
+
* - **iOS**: Requires iOS 16.0+. Uses StoreKit 2's `AppTransaction.shared`.
|
|
658
|
+
* - **Android**: Uses Google Play's install referrer data when available.
|
|
659
|
+
*
|
|
660
|
+
* @returns {Promise<{ appTransaction: AppTransaction }>} The app transaction info
|
|
661
|
+
* @throws An error if the app transaction cannot be retrieved (iOS 15 or earlier)
|
|
662
|
+
* @since 7.16.0
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* ```typescript
|
|
666
|
+
* const { appTransaction } = await NativePurchases.getAppTransaction();
|
|
667
|
+
*
|
|
668
|
+
* // Check if user downloaded before version 2.0.0 (when subscription was added)
|
|
669
|
+
* if (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {
|
|
670
|
+
* // User gets free access - they downloaded before subscriptions
|
|
671
|
+
* grantFreeAccess();
|
|
672
|
+
* }
|
|
673
|
+
* ```
|
|
674
|
+
*
|
|
675
|
+
* @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction
|
|
676
|
+
*/
|
|
677
|
+
getAppTransaction(): Promise<{
|
|
678
|
+
appTransaction: AppTransaction;
|
|
679
|
+
}>;
|
|
680
|
+
/**
|
|
681
|
+
* Compares the original app version from the App Transaction against a target version
|
|
682
|
+
* to determine if the user is entitled to features from an earlier business model.
|
|
683
|
+
*
|
|
684
|
+
* This is a utility method that performs the version comparison natively, which can be
|
|
685
|
+
* more reliable than JavaScript-based comparison for semantic versioning.
|
|
686
|
+
*
|
|
687
|
+
* **Use Case:**
|
|
688
|
+
* Check if the user's original download version is older than a specific version
|
|
689
|
+
* to determine if they should be grandfathered into free features.
|
|
690
|
+
*
|
|
691
|
+
* @param options - The comparison options
|
|
692
|
+
* @param options.targetVersion - The version to compare against (e.g., "2.0.0")
|
|
693
|
+
* @returns {Promise<{ isOlderVersion: boolean; originalAppVersion: string }>}
|
|
694
|
+
* - `isOlderVersion`: true if the user's original version is older than targetVersion
|
|
695
|
+
* - `originalAppVersion`: The user's original app version for reference
|
|
696
|
+
* @throws An error if the app transaction cannot be retrieved
|
|
697
|
+
* @since 7.16.0
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```typescript
|
|
701
|
+
* // Check if user downloaded before version 2.0.0 (when subscription was added)
|
|
702
|
+
* const result = await NativePurchases.isEntitledToOldBusinessModel({
|
|
703
|
+
* targetVersion: '2.0.0'
|
|
704
|
+
* });
|
|
705
|
+
*
|
|
706
|
+
* if (result.isOlderVersion) {
|
|
707
|
+
* console.log(`User downloaded v${result.originalAppVersion}, granting free access`);
|
|
708
|
+
* grantFreeAccess();
|
|
709
|
+
* }
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
712
|
+
isEntitledToOldBusinessModel(options: {
|
|
713
|
+
targetVersion: string;
|
|
714
|
+
}): Promise<{
|
|
715
|
+
isOlderVersion: boolean;
|
|
716
|
+
originalAppVersion: string;
|
|
717
|
+
}>;
|
|
574
718
|
/**
|
|
575
719
|
* Started purchase process for the given product.
|
|
576
720
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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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":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport 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 * 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 * Unique identifier for the transaction.\n *\n * @since 1.0.0\n * @platform ios Numeric string (e.g., \"2000001043762129\")\n * @platform android Alphanumeric string (e.g., \"GPA.1234-5678-9012-34567\")\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (base64 encoded StoreKit receipt).\n *\n * Send this to your backend for server-side validation with Apple's receipt verification API.\n * The receipt remains available even after refund - server validation is required to detect refunded transactions.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Not available (use purchaseToken instead)\n */\n readonly receipt?: string;\n /**\n * StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.\n *\n * Send this to your backend when using Apple's App Store Server API v2 instead of raw receipts.\n * Only available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).\n *\n * @since 7.13.2\n * @platform ios Present for StoreKit 2 transactions (iOS 15+)\n * @platform android Not available\n */\n readonly jwsRepresentation?: string;\n /**\n * An optional obfuscated identifier that uniquely associates the transaction with a user account in your app.\n *\n * PURPOSE:\n * - Fraud detection: Helps platforms detect irregular activity (e.g., many devices purchasing on the same account)\n * - User linking: Links purchases to in-game characters, avatars, or in-app profiles\n *\n * PLATFORM DIFFERENCES:\n * - iOS: Must be a valid UUID format (e.g., \"550e8400-e29b-41d4-a716-446655440000\")\n * Apple's StoreKit 2 requires UUID format for the appAccountToken parameter\n * - Android: Can be any obfuscated string (max 64 chars), maps to Google Play's ObfuscatedAccountId\n * Google recommends using encryption or one-way hash\n *\n * SECURITY REQUIREMENTS (especially for Android):\n * - DO NOT store Personally Identifiable Information (PII) like emails in cleartext\n * - Use encryption or a one-way hash to generate an obfuscated identifier\n * - Maximum length: 64 characters (both platforms)\n * - Storing PII in cleartext will result in purchases being blocked by Google Play\n *\n * IMPLEMENTATION EXAMPLE:\n * ```typescript\n * // For iOS: Generate a deterministic UUID from user ID\n * import { v5 as uuidv5 } from 'uuid';\n * const NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; // Your app's namespace UUID\n * const appAccountToken = uuidv5(userId, NAMESPACE);\n *\n * // For Android: Can also use UUID or any hashed value\n * // The same UUID approach works for both platforms\n * ```\n */\n readonly appAccountToken?: string | null;\n /**\n * Product identifier associated with the transaction.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n *\n * @since 1.0.0\n * @example \"2025-10-28T06:03:19Z\"\n * @platform ios Always present\n * @platform android Always present\n */\n readonly purchaseDate: string;\n /**\n * Indicates whether this transaction is the result of a subscription upgrade.\n *\n * Useful for understanding when StoreKit generated the transaction because\n * the customer moved from a lower tier to a higher tier plan.\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly isUpgraded?: boolean;\n /**\n * Original purchase date of the transaction in ISO 8601 format.\n *\n * For subscription renewals, this shows the date of the original subscription purchase,\n * while purchaseDate shows the date of the current renewal.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format.\n *\n * Check this date to determine if a subscription is still valid.\n * Compare with current date: if expirationDate > now, subscription is active.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available (query Google Play Developer API instead)\n */\n readonly expirationDate?: string;\n /**\n * Whether the subscription is still active/valid.\n *\n * For iOS subscriptions, check if isActive === true to verify an active subscription.\n * For expired or refunded iOS subscriptions, this will be false.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only (true if expiration date is in the future)\n * @platform android Not available (check purchaseState === \"1\" instead)\n */\n readonly isActive?: boolean;\n /**\n * Date the transaction was revoked/refunded, in ISO 8601 format.\n *\n * Present when Apple revokes access due to an issue (e.g., refund or developer issue).\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationDate?: string;\n /**\n * Reason why Apple revoked the transaction.\n *\n * Possible values:\n * - `\"developerIssue\"`: Developer-initiated refund or issue\n * - `\"other\"`: Apple-initiated (customer refund, billing problem, etc.)\n * - `\"unknown\"`: StoreKit didn't report a specific reason\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationReason?: 'developerIssue' | 'other' | 'unknown';\n /**\n * Whether the subscription will be cancelled at the end of the billing cycle.\n *\n * - `true`: User has cancelled but subscription remains active until expiration\n * - `false`: Subscription will auto-renew\n * - `null`: Status unknown or not available\n *\n * @since 1.0.0\n * @default null\n * @platform ios Present for subscriptions only (boolean or null)\n * @platform android Always null (use Google Play Developer API for cancellation status)\n */\n readonly willCancel: boolean | null;\n /**\n * Current subscription state reported by StoreKit.\n *\n * Possible values:\n * - `\"subscribed\"`: Auto-renewing and in good standing\n * - `\"expired\"`: Lapsed with no access\n * - `\"revoked\"`: Access removed due to refund or issue\n * - `\"inGracePeriod\"`: Payment issue but still in grace access window\n * - `\"inBillingRetryPeriod\"`: StoreKit retrying failed billing\n * - `\"unknown\"`: StoreKit did not report a state\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly subscriptionState?:\n | 'subscribed'\n | 'expired'\n | 'revoked'\n | 'inGracePeriod'\n | 'inBillingRetryPeriod'\n | 'unknown';\n /**\n * Purchase state of the transaction (numeric string value).\n *\n * **Android Values:**\n * - `\"1\"`: Purchase completed and valid (PURCHASED state)\n * - `\"0\"`: Payment pending (PENDING state, e.g., cash payment processing)\n * - Other numeric values: Various other states\n *\n * Always check `purchaseState === \"1\"` on Android to verify a valid purchase.\n * Refunded purchases typically disappear from getPurchases() rather than showing a different state.\n *\n * @since 1.0.0\n * @platform ios Not available (use isActive for subscriptions or receipt validation for IAP)\n * @platform android Always present\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction.\n *\n * Use this for server-side verification on Android. This is the Google Play order ID.\n *\n * @since 1.0.0\n * @example \"GPA.1234-5678-9012-34567\"\n * @platform ios Not available\n * @platform android Always present\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction.\n *\n * Send this to your backend for server-side validation with Google Play Developer API.\n * This is the Android equivalent of iOS's receipt field.\n *\n * @since 1.0.0\n * @platform ios Not available (use receipt instead)\n * @platform android Always present\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged.\n *\n * Purchases must be acknowledged within 3 days or they will be refunded.\n * By default, this plugin automatically acknowledges purchases unless you set\n * `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * @since 1.0.0\n * @platform ios Not available\n * @platform android Always present (should be true after successful purchase or manual acknowledgment)\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n *\n * @since 1.0.0\n * @default 1\n * @platform ios 1 or higher (as specified in purchaseProduct call)\n * @platform android Always 1 (Google Play doesn't support quantity > 1)\n */\n readonly quantity?: number;\n /**\n * Product type.\n *\n * - `\"inapp\"`: One-time in-app purchase\n * - `\"subs\"`: Subscription\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productType?: string;\n /**\n * Indicates how the user obtained access to the product.\n *\n * - `\"purchased\"`: The user purchased the product directly\n * - `\"familyShared\"`: The user has access through Family Sharing (another family member purchased it)\n *\n * This property is useful for:\n * - Detecting family sharing usage for analytics\n * - Implementing different features/limits for family-shared vs. directly purchased products\n * - Understanding your user acquisition channels\n *\n * @since 7.12.8\n * @platform ios Always present (iOS 15.0+, StoreKit 2)\n * @platform android Not available\n */\n readonly ownershipType?: 'purchased' | 'familyShared';\n /**\n * Indicates the server environment where the transaction was processed.\n *\n * - `\"Sandbox\"`: Transaction belongs to testing in the sandbox environment\n * - `\"Production\"`: Transaction belongs to a customer in the production environment\n * - `\"Xcode\"`: Transaction from StoreKit Testing in Xcode\n *\n * This property is useful for:\n * - Debugging and identifying test vs. production purchases\n * - Analytics and reporting (filtering out sandbox transactions)\n * - Server-side validation (knowing which Apple endpoint to use)\n * - Preventing test purchases from affecting production metrics\n *\n * @since 7.12.8\n * @platform ios Present on iOS 16.0+ only (not available on iOS 15)\n * @platform android Not available\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode';\n /**\n * Reason StoreKit generated the transaction.\n *\n * - `\"purchase\"`: Initial purchase that user made manually\n * - `\"renewal\"`: Automatically generated renewal for an auto-renewable subscription\n * - `\"unknown\"`: StoreKit did not return a reason\n *\n * @since 7.13.2\n * @platform ios Present on iOS 17.0+ (StoreKit 2 transactions)\n * @platform android Not available\n */\n readonly transactionReason?: 'purchase' | 'renewal' | 'unknown';\n /**\n * Whether the transaction is in a trial period.\n *\n * - `true`: Currently in free trial period\n * - `false`: Not in trial period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with trial offers\n * @platform android Present for subscriptions with trial offers\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in an introductory price period.\n *\n * Introductory pricing is a discounted rate, different from a free trial.\n *\n * - `true`: Currently using introductory pricing\n * - `false`: Not in intro period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with intro pricing\n * @platform android Present for subscriptions with intro pricing\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in a grace period.\n *\n * Grace period allows users to fix payment issues while maintaining access.\n * You typically want to continue providing access during this time.\n *\n * - `true`: Subscription payment failed but user still has access\n * - `false`: Not in grace period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions in grace period\n * @platform android Present for subscriptions in grace period\n */\n readonly isInGracePeriod?: boolean;\n}\n\nexport interface TransactionVerificationFailedEvent {\n /**\n * Identifier of the transaction that failed verification.\n *\n * @since 7.13.2\n * @platform ios Present when StoreKit reports an unverified transaction\n * @platform android Not available\n */\n readonly transactionId: string;\n /**\n * Localized error message describing why verification failed.\n *\n * @since 7.13.2\n * @platform ios Always present\n * @platform android Not available\n */\n readonly error: string;\n}\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 subscription 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<void>;\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 base plan you want to purchase from Google Play Console. REQUIRED for Android subscriptions, ignored on iOS.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.\n * PLATFORM REQUIREMENTS:\n * - iOS: Must be a valid UUID format (StoreKit 2 requirement)\n * - Android: Can be any obfuscated string (max 64 chars), maps to ObfuscatedAccountId\n * SECURITY: DO NOT use PII like emails in cleartext - use UUID or hashed value.\n * RECOMMENDED: Use UUID v5 with deterministic generation for cross-platform compatibility.\n * @param options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false.\n * @param options.autoAcknowledgePurchases - When false, the purchase/transaction will NOT be automatically acknowledged/finished. You must manually call acknowledgePurchase() or the purchase may be refunded. Defaults to true.\n * - **Android**: Must acknowledge within 3 days or Google Play will refund\n * - **iOS**: Unfinished transactions remain in the queue and may block future purchases\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\n isConsumable?: boolean;\n autoAcknowledgePurchases?: boolean;\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: { productIdentifiers: string[]; productType?: PURCHASE_TYPE }): 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: { productIdentifier: string; productType?: PURCHASE_TYPE }): 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 /**\n * Gets all the user's purchases (both in-app purchases and subscriptions).\n * This method queries the platform's purchase history for the current user.\n *\n * @param options - Optional parameters for filtering purchases\n * @param options.productType - Only Android, filter by product type (inapp or subs). If not specified, returns both types.\n * @param options.appAccountToken - Optional filter to restrict results to purchases that used the provided account token.\n * Must be the same identifier used during purchase (UUID format for iOS, any obfuscated string for Android).\n * iOS: UUID format required. Android: Maps to ObfuscatedAccountId.\n * @returns {Promise<{ purchases: Transaction[] }>} Promise that resolves with array of user's purchases\n * @throws An error if the purchase query fails\n * @since 7.2.0\n */\n getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n }): Promise<{ purchases: Transaction[] }>;\n\n /**\n * Opens the platform's native subscription management page.\n * This allows users to view, modify, or cancel their subscriptions.\n *\n * - iOS: Opens the App Store subscription management page for the current app\n * - Android: Opens the Google Play subscription management page\n *\n * @returns {Promise<void>} Promise that resolves when the management page is opened\n * @throws An error if the subscription management page cannot be opened\n * @since 7.10.0\n */\n manageSubscriptions(): Promise<void>;\n\n /**\n * Manually acknowledge/finish a purchase transaction.\n *\n * This method is only needed when you set `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * **Platform Behavior:**\n * - **Android**: Acknowledges the purchase with Google Play. Must be called within 3 days or the purchase will be refunded.\n * - **iOS**: Finishes the transaction with StoreKit 2. Unfinished transactions remain in the queue and may block future purchases.\n *\n * **Acknowledgment Options:**\n *\n * **1. Client-side (this method)**: Call from your app after validation\n * ```typescript\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken // Android: purchaseToken, iOS: transactionId\n * });\n * ```\n *\n * **2. Server-side (Android only, recommended for security)**: Use Google Play Developer API v3\n * - Endpoint: `POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge`\n * - Requires OAuth 2.0 authentication with appropriate scopes\n * - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge\n * - For subscriptions: Use `/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge` instead\n * - Note: iOS has no server-side finish API\n *\n * **When to use manual acknowledgment:**\n * - Server-side validation: Verify the purchase with your backend before acknowledging\n * - Entitlement delivery: Ensure user receives content/features before acknowledging\n * - Multi-step workflows: Complete all steps before final acknowledgment\n * - Security: Prevent client-side manipulation by handling acknowledgment server-side (Android only)\n *\n * @param options - The purchase to acknowledge\n * @param options.purchaseToken - The purchase token (Android) or transaction ID as string (iOS) from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is acknowledged/finished\n * @throws An error if acknowledgment/finishing fails or transaction not found\n * @platform android Acknowledges the purchase with Google Play\n * @platform ios Finishes the transaction with StoreKit 2\n * @since 7.14.0\n *\n * @example\n * ```typescript\n * // Client-side acknowledgment\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'premium_feature',\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend\n * const isValid = await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({ purchaseToken: transaction.purchaseToken })\n * });\n *\n * if (isValid) {\n * // Option 1: Acknowledge from client\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken\n * });\n *\n * // Option 2: Or let your backend acknowledge via Google Play API\n * // Your backend calls Google Play Developer API\n * }\n * ```\n */\n acknowledgePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Listen for StoreKit transaction updates delivered by Apple's Transaction.updates.\n * Fires on app launch if there are unfinished transactions, and for any updates afterward.\n * iOS only.\n */\n addListener(\n eventName: 'transactionUpdated',\n listenerFunc: (transaction: Transaction) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.\n * Fires when the verification result is unverified.\n * iOS only.\n */\n addListener(\n eventName: 'transactionVerificationFailed',\n listenerFunc: (payload: TransactionVerificationFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /** Remove all registered listeners */\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7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;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":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport 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 * 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 * Unique identifier for the transaction.\n *\n * @since 1.0.0\n * @platform ios Numeric string (e.g., \"2000001043762129\")\n * @platform android Alphanumeric string (e.g., \"GPA.1234-5678-9012-34567\")\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (base64 encoded StoreKit receipt).\n *\n * Send this to your backend for server-side validation with Apple's receipt verification API.\n * The receipt remains available even after refund - server validation is required to detect refunded transactions.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Not available (use purchaseToken instead)\n */\n readonly receipt?: string;\n /**\n * StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.\n *\n * Send this to your backend when using Apple's App Store Server API v2 instead of raw receipts.\n * Only available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).\n *\n * @since 7.13.2\n * @platform ios Present for StoreKit 2 transactions (iOS 15+)\n * @platform android Not available\n */\n readonly jwsRepresentation?: string;\n /**\n * An optional obfuscated identifier that uniquely associates the transaction with a user account in your app.\n *\n * PURPOSE:\n * - Fraud detection: Helps platforms detect irregular activity (e.g., many devices purchasing on the same account)\n * - User linking: Links purchases to in-game characters, avatars, or in-app profiles\n *\n * PLATFORM DIFFERENCES:\n * - iOS: Must be a valid UUID format (e.g., \"550e8400-e29b-41d4-a716-446655440000\")\n * Apple's StoreKit 2 requires UUID format for the appAccountToken parameter\n * - Android: Can be any obfuscated string (max 64 chars), maps to Google Play's ObfuscatedAccountId\n * Google recommends using encryption or one-way hash\n *\n * SECURITY REQUIREMENTS (especially for Android):\n * - DO NOT store Personally Identifiable Information (PII) like emails in cleartext\n * - Use encryption or a one-way hash to generate an obfuscated identifier\n * - Maximum length: 64 characters (both platforms)\n * - Storing PII in cleartext will result in purchases being blocked by Google Play\n *\n * IMPLEMENTATION EXAMPLE:\n * ```typescript\n * // For iOS: Generate a deterministic UUID from user ID\n * import { v5 as uuidv5 } from 'uuid';\n * const NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; // Your app's namespace UUID\n * const appAccountToken = uuidv5(userId, NAMESPACE);\n *\n * // For Android: Can also use UUID or any hashed value\n * // The same UUID approach works for both platforms\n * ```\n */\n readonly appAccountToken?: string | null;\n /**\n * Product identifier associated with the transaction.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n *\n * @since 1.0.0\n * @example \"2025-10-28T06:03:19Z\"\n * @platform ios Always present\n * @platform android Always present\n */\n readonly purchaseDate: string;\n /**\n * Indicates whether this transaction is the result of a subscription upgrade.\n *\n * Useful for understanding when StoreKit generated the transaction because\n * the customer moved from a lower tier to a higher tier plan.\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly isUpgraded?: boolean;\n /**\n * Original purchase date of the transaction in ISO 8601 format.\n *\n * For subscription renewals, this shows the date of the original subscription purchase,\n * while purchaseDate shows the date of the current renewal.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format.\n *\n * Check this date to determine if a subscription is still valid.\n * Compare with current date: if expirationDate > now, subscription is active.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available (query Google Play Developer API instead)\n */\n readonly expirationDate?: string;\n /**\n * Whether the subscription is still active/valid.\n *\n * For iOS subscriptions, check if isActive === true to verify an active subscription.\n * For expired or refunded iOS subscriptions, this will be false.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only (true if expiration date is in the future)\n * @platform android Not available (check purchaseState === \"1\" instead)\n */\n readonly isActive?: boolean;\n /**\n * Date the transaction was revoked/refunded, in ISO 8601 format.\n *\n * Present when Apple revokes access due to an issue (e.g., refund or developer issue).\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationDate?: string;\n /**\n * Reason why Apple revoked the transaction.\n *\n * Possible values:\n * - `\"developerIssue\"`: Developer-initiated refund or issue\n * - `\"other\"`: Apple-initiated (customer refund, billing problem, etc.)\n * - `\"unknown\"`: StoreKit didn't report a specific reason\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationReason?: 'developerIssue' | 'other' | 'unknown';\n /**\n * Whether the subscription will be cancelled at the end of the billing cycle.\n *\n * - `true`: User has cancelled but subscription remains active until expiration\n * - `false`: Subscription will auto-renew\n * - `null`: Status unknown or not available\n *\n * @since 1.0.0\n * @default null\n * @platform ios Present for subscriptions only (boolean or null)\n * @platform android Always null (use Google Play Developer API for cancellation status)\n */\n readonly willCancel: boolean | null;\n /**\n * Current subscription state reported by StoreKit.\n *\n * Possible values:\n * - `\"subscribed\"`: Auto-renewing and in good standing\n * - `\"expired\"`: Lapsed with no access\n * - `\"revoked\"`: Access removed due to refund or issue\n * - `\"inGracePeriod\"`: Payment issue but still in grace access window\n * - `\"inBillingRetryPeriod\"`: StoreKit retrying failed billing\n * - `\"unknown\"`: StoreKit did not report a state\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly subscriptionState?:\n | 'subscribed'\n | 'expired'\n | 'revoked'\n | 'inGracePeriod'\n | 'inBillingRetryPeriod'\n | 'unknown';\n /**\n * Purchase state of the transaction (numeric string value).\n *\n * **Android Values:**\n * - `\"1\"`: Purchase completed and valid (PURCHASED state)\n * - `\"0\"`: Payment pending (PENDING state, e.g., cash payment processing)\n * - Other numeric values: Various other states\n *\n * Always check `purchaseState === \"1\"` on Android to verify a valid purchase.\n * Refunded purchases typically disappear from getPurchases() rather than showing a different state.\n *\n * @since 1.0.0\n * @platform ios Not available (use isActive for subscriptions or receipt validation for IAP)\n * @platform android Always present\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction.\n *\n * Use this for server-side verification on Android. This is the Google Play order ID.\n *\n * @since 1.0.0\n * @example \"GPA.1234-5678-9012-34567\"\n * @platform ios Not available\n * @platform android Always present\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction.\n *\n * Send this to your backend for server-side validation with Google Play Developer API.\n * This is the Android equivalent of iOS's receipt field.\n *\n * @since 1.0.0\n * @platform ios Not available (use receipt instead)\n * @platform android Always present\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged.\n *\n * Purchases must be acknowledged within 3 days or they will be refunded.\n * By default, this plugin automatically acknowledges purchases unless you set\n * `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * @since 1.0.0\n * @platform ios Not available\n * @platform android Always present (should be true after successful purchase or manual acknowledgment)\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n *\n * @since 1.0.0\n * @default 1\n * @platform ios 1 or higher (as specified in purchaseProduct call)\n * @platform android Always 1 (Google Play doesn't support quantity > 1)\n */\n readonly quantity?: number;\n /**\n * Product type.\n *\n * - `\"inapp\"`: One-time in-app purchase\n * - `\"subs\"`: Subscription\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productType?: string;\n /**\n * Indicates how the user obtained access to the product.\n *\n * - `\"purchased\"`: The user purchased the product directly\n * - `\"familyShared\"`: The user has access through Family Sharing (another family member purchased it)\n *\n * This property is useful for:\n * - Detecting family sharing usage for analytics\n * - Implementing different features/limits for family-shared vs. directly purchased products\n * - Understanding your user acquisition channels\n *\n * @since 7.12.8\n * @platform ios Always present (iOS 15.0+, StoreKit 2)\n * @platform android Not available\n */\n readonly ownershipType?: 'purchased' | 'familyShared';\n /**\n * Indicates the server environment where the transaction was processed.\n *\n * - `\"Sandbox\"`: Transaction belongs to testing in the sandbox environment\n * - `\"Production\"`: Transaction belongs to a customer in the production environment\n * - `\"Xcode\"`: Transaction from StoreKit Testing in Xcode\n *\n * This property is useful for:\n * - Debugging and identifying test vs. production purchases\n * - Analytics and reporting (filtering out sandbox transactions)\n * - Server-side validation (knowing which Apple endpoint to use)\n * - Preventing test purchases from affecting production metrics\n *\n * @since 7.12.8\n * @platform ios Present on iOS 16.0+ only (not available on iOS 15)\n * @platform android Not available\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode';\n /**\n * Reason StoreKit generated the transaction.\n *\n * - `\"purchase\"`: Initial purchase that user made manually\n * - `\"renewal\"`: Automatically generated renewal for an auto-renewable subscription\n * - `\"unknown\"`: StoreKit did not return a reason\n *\n * @since 7.13.2\n * @platform ios Present on iOS 17.0+ (StoreKit 2 transactions)\n * @platform android Not available\n */\n readonly transactionReason?: 'purchase' | 'renewal' | 'unknown';\n /**\n * Whether the transaction is in a trial period.\n *\n * - `true`: Currently in free trial period\n * - `false`: Not in trial period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with trial offers\n * @platform android Present for subscriptions with trial offers\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in an introductory price period.\n *\n * Introductory pricing is a discounted rate, different from a free trial.\n *\n * - `true`: Currently using introductory pricing\n * - `false`: Not in intro period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with intro pricing\n * @platform android Present for subscriptions with intro pricing\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in a grace period.\n *\n * Grace period allows users to fix payment issues while maintaining access.\n * You typically want to continue providing access during this time.\n *\n * - `true`: Subscription payment failed but user still has access\n * - `false`: Not in grace period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions in grace period\n * @platform android Present for subscriptions in grace period\n */\n readonly isInGracePeriod?: boolean;\n}\n\nexport interface TransactionVerificationFailedEvent {\n /**\n * Identifier of the transaction that failed verification.\n *\n * @since 7.13.2\n * @platform ios Present when StoreKit reports an unverified transaction\n * @platform android Not available\n */\n readonly transactionId: string;\n /**\n * Localized error message describing why verification failed.\n *\n * @since 7.13.2\n * @platform ios Always present\n * @platform android Not available\n */\n readonly error: string;\n}\n\n/**\n * Represents the App Transaction information from StoreKit 2.\n * This provides details about when the user originally downloaded or purchased the app,\n * which is useful for determining if users are entitled to features from earlier business models.\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n * @since 7.16.0\n */\nexport interface AppTransaction {\n /**\n * The app version that the user originally purchased or downloaded.\n *\n * Use this to determine if users who originally downloaded an earlier version\n * should be entitled to features that were previously free or included.\n *\n * For iOS: This is the `CFBundleShortVersionString` (e.g., \"1.0.0\")\n * For Android: This is the `versionName` from Google Play (e.g., \"1.0.0\")\n *\n * @example \"1.0.0\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalAppVersion: string;\n\n /**\n * The date when the user originally purchased or downloaded the app.\n * ISO 8601 format.\n *\n * @example \"2023-06-15T10:30:00Z\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalPurchaseDate: string;\n\n /**\n * The bundle identifier of the app.\n *\n * @example \"com.example.myapp\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present (package name)\n */\n readonly bundleId: string;\n\n /**\n * The current app version installed on the device.\n *\n * @example \"2.0.0\"\n * @since 7.16.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly appVersion: string;\n\n /**\n * The server environment where the app was originally purchased.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available (always null)\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode' | null;\n\n /**\n * The JWS (JSON Web Signature) representation of the app transaction.\n * Can be sent to your backend for server-side verification.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available\n */\n readonly jwsRepresentation?: string;\n}\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 subscription 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<void>;\n\n /**\n * Gets the App Transaction information, which provides details about when the user\n * originally downloaded or purchased the app.\n *\n * This is useful for implementing business model changes where you want to\n * grandfather users who originally downloaded an earlier version of the app.\n *\n * **Use Case Example:**\n * If your app was originally free but you're adding a subscription, you can use\n * `originalAppVersion` to check if users downloaded before the subscription was added\n * and give them free access.\n *\n * **Platform Notes:**\n * - **iOS**: Requires iOS 16.0+. Uses StoreKit 2's `AppTransaction.shared`.\n * - **Android**: Uses Google Play's install referrer data when available.\n *\n * @returns {Promise<{ appTransaction: AppTransaction }>} The app transaction info\n * @throws An error if the app transaction cannot be retrieved (iOS 15 or earlier)\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * const { appTransaction } = await NativePurchases.getAppTransaction();\n *\n * // Check if user downloaded before version 2.0.0 (when subscription was added)\n * if (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {\n * // User gets free access - they downloaded before subscriptions\n * grantFreeAccess();\n * }\n * ```\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n */\n getAppTransaction(): Promise<{ appTransaction: AppTransaction }>;\n\n /**\n * Compares the original app version from the App Transaction against a target version\n * to determine if the user is entitled to features from an earlier business model.\n *\n * This is a utility method that performs the version comparison natively, which can be\n * more reliable than JavaScript-based comparison for semantic versioning.\n *\n * **Use Case:**\n * Check if the user's original download version is older than a specific version\n * to determine if they should be grandfathered into free features.\n *\n * @param options - The comparison options\n * @param options.targetVersion - The version to compare against (e.g., \"2.0.0\")\n * @returns {Promise<{ isOlderVersion: boolean; originalAppVersion: string }>}\n * - `isOlderVersion`: true if the user's original version is older than targetVersion\n * - `originalAppVersion`: The user's original app version for reference\n * @throws An error if the app transaction cannot be retrieved\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * // Check if user downloaded before version 2.0.0 (when subscription was added)\n * const result = await NativePurchases.isEntitledToOldBusinessModel({\n * targetVersion: '2.0.0'\n * });\n *\n * if (result.isOlderVersion) {\n * console.log(`User downloaded v${result.originalAppVersion}, granting free access`);\n * grantFreeAccess();\n * }\n * ```\n */\n isEntitledToOldBusinessModel(options: {\n targetVersion: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }>;\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 base plan you want to purchase from Google Play Console. REQUIRED for Android subscriptions, ignored on iOS.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.\n * PLATFORM REQUIREMENTS:\n * - iOS: Must be a valid UUID format (StoreKit 2 requirement)\n * - Android: Can be any obfuscated string (max 64 chars), maps to ObfuscatedAccountId\n * SECURITY: DO NOT use PII like emails in cleartext - use UUID or hashed value.\n * RECOMMENDED: Use UUID v5 with deterministic generation for cross-platform compatibility.\n * @param options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false.\n * @param options.autoAcknowledgePurchases - When false, the purchase/transaction will NOT be automatically acknowledged/finished. You must manually call acknowledgePurchase() or the purchase may be refunded. Defaults to true.\n * - **Android**: Must acknowledge within 3 days or Google Play will refund\n * - **iOS**: Unfinished transactions remain in the queue and may block future purchases\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\n isConsumable?: boolean;\n autoAcknowledgePurchases?: boolean;\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: { productIdentifiers: string[]; productType?: PURCHASE_TYPE }): 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: { productIdentifier: string; productType?: PURCHASE_TYPE }): 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 /**\n * Gets all the user's purchases (both in-app purchases and subscriptions).\n * This method queries the platform's purchase history for the current user.\n *\n * @param options - Optional parameters for filtering purchases\n * @param options.productType - Only Android, filter by product type (inapp or subs). If not specified, returns both types.\n * @param options.appAccountToken - Optional filter to restrict results to purchases that used the provided account token.\n * Must be the same identifier used during purchase (UUID format for iOS, any obfuscated string for Android).\n * iOS: UUID format required. Android: Maps to ObfuscatedAccountId.\n * @returns {Promise<{ purchases: Transaction[] }>} Promise that resolves with array of user's purchases\n * @throws An error if the purchase query fails\n * @since 7.2.0\n */\n getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n }): Promise<{ purchases: Transaction[] }>;\n\n /**\n * Opens the platform's native subscription management page.\n * This allows users to view, modify, or cancel their subscriptions.\n *\n * - iOS: Opens the App Store subscription management page for the current app\n * - Android: Opens the Google Play subscription management page\n *\n * @returns {Promise<void>} Promise that resolves when the management page is opened\n * @throws An error if the subscription management page cannot be opened\n * @since 7.10.0\n */\n manageSubscriptions(): Promise<void>;\n\n /**\n * Manually acknowledge/finish a purchase transaction.\n *\n * This method is only needed when you set `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * **Platform Behavior:**\n * - **Android**: Acknowledges the purchase with Google Play. Must be called within 3 days or the purchase will be refunded.\n * - **iOS**: Finishes the transaction with StoreKit 2. Unfinished transactions remain in the queue and may block future purchases.\n *\n * **Acknowledgment Options:**\n *\n * **1. Client-side (this method)**: Call from your app after validation\n * ```typescript\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken // Android: purchaseToken, iOS: transactionId\n * });\n * ```\n *\n * **2. Server-side (Android only, recommended for security)**: Use Google Play Developer API v3\n * - Endpoint: `POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge`\n * - Requires OAuth 2.0 authentication with appropriate scopes\n * - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge\n * - For subscriptions: Use `/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge` instead\n * - Note: iOS has no server-side finish API\n *\n * **When to use manual acknowledgment:**\n * - Server-side validation: Verify the purchase with your backend before acknowledging\n * - Entitlement delivery: Ensure user receives content/features before acknowledging\n * - Multi-step workflows: Complete all steps before final acknowledgment\n * - Security: Prevent client-side manipulation by handling acknowledgment server-side (Android only)\n *\n * @param options - The purchase to acknowledge\n * @param options.purchaseToken - The purchase token (Android) or transaction ID as string (iOS) from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is acknowledged/finished\n * @throws An error if acknowledgment/finishing fails or transaction not found\n * @platform android Acknowledges the purchase with Google Play\n * @platform ios Finishes the transaction with StoreKit 2\n * @since 7.14.0\n *\n * @example\n * ```typescript\n * // Client-side acknowledgment\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'premium_feature',\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend\n * const isValid = await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({ purchaseToken: transaction.purchaseToken })\n * });\n *\n * if (isValid) {\n * // Option 1: Acknowledge from client\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken\n * });\n *\n * // Option 2: Or let your backend acknowledge via Google Play API\n * // Your backend calls Google Play Developer API\n * }\n * ```\n */\n acknowledgePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Listen for StoreKit transaction updates delivered by Apple's Transaction.updates.\n * Fires on app launch if there are unfinished transactions, and for any updates afterward.\n * iOS only.\n */\n addListener(\n eventName: 'transactionUpdated',\n listenerFunc: (transaction: Transaction) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.\n * Fires when the verification result is unverified.\n * iOS only.\n */\n addListener(\n eventName: 'transactionVerificationFailed',\n listenerFunc: (payload: TransactionVerificationFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /** Remove all registered listeners */\n removeAllListeners(): Promise<void>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';
|
|
2
|
+
import type { AppTransaction, NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';
|
|
3
3
|
export declare class NativePurchasesWeb extends WebPlugin implements NativePurchasesPlugin {
|
|
4
4
|
restorePurchases(): Promise<void>;
|
|
5
5
|
getProducts(options: {
|
|
@@ -32,4 +32,13 @@ export declare class NativePurchasesWeb extends WebPlugin implements NativePurch
|
|
|
32
32
|
acknowledgePurchase(_options: {
|
|
33
33
|
purchaseToken: string;
|
|
34
34
|
}): Promise<void>;
|
|
35
|
+
getAppTransaction(): Promise<{
|
|
36
|
+
appTransaction: AppTransaction;
|
|
37
|
+
}>;
|
|
38
|
+
isEntitledToOldBusinessModel(_options: {
|
|
39
|
+
targetVersion: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
isOlderVersion: boolean;
|
|
42
|
+
originalAppVersion: string;
|
|
43
|
+
}>;
|
|
35
44
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -33,5 +33,24 @@ export class NativePurchasesWeb extends WebPlugin {
|
|
|
33
33
|
async acknowledgePurchase(_options) {
|
|
34
34
|
console.error('acknowledgePurchase only mocked in web');
|
|
35
35
|
}
|
|
36
|
+
async getAppTransaction() {
|
|
37
|
+
console.error('getAppTransaction only mocked in web');
|
|
38
|
+
return {
|
|
39
|
+
appTransaction: {
|
|
40
|
+
originalAppVersion: '1.0.0',
|
|
41
|
+
originalPurchaseDate: new Date().toISOString(),
|
|
42
|
+
bundleId: 'com.example.app',
|
|
43
|
+
appVersion: '1.0.0',
|
|
44
|
+
environment: null,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async isEntitledToOldBusinessModel(_options) {
|
|
49
|
+
console.error('isEntitledToOldBusinessModel only mocked in web');
|
|
50
|
+
return {
|
|
51
|
+
isOlderVersion: false,
|
|
52
|
+
originalAppVersion: '1.0.0',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
36
55
|
}
|
|
37
56
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,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O,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';\n\nexport class NativePurchasesWeb extends WebPlugin implements NativePurchasesPlugin {\n async restorePurchases(): Promise<void> {\n console.error('restorePurchases only mocked in web');\n }\n\n async getProducts(options: { productIdentifiers: string[] }): Promise<{ products: Product[] }> {\n console.error('getProducts only mocked in web ' + options);\n return { products: [] };\n }\n\n async getProduct(options: { productIdentifier: string }): 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<Transaction> {\n console.error('purchaseProduct only mocked in web' + options);\n return { transactionId: 'transactionId' } as any;\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 async getPurchases(options?: { productType?: PURCHASE_TYPE }): Promise<{ purchases: Transaction[] }> {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions(): Promise<void> {\n console.error('manageSubscriptions only mocked in web');\n }\n\n async acknowledgePurchase(_options: { purchaseToken: string }): Promise<void> {\n console.error('acknowledgePurchase only mocked in web');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAyC;QACzD,O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,EAAE,CAAC,WAAW,EAAE;gBAC9C,QAAQ,EAAE,iBAAiB;gBAC3B,UAAU,EAAE,OAAO;gBACnB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,QAElC;QACC,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,kBAAkB,EAAE,OAAO;SAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { AppTransaction, NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';\n\nexport class NativePurchasesWeb extends WebPlugin implements NativePurchasesPlugin {\n async restorePurchases(): Promise<void> {\n console.error('restorePurchases only mocked in web');\n }\n\n async getProducts(options: { productIdentifiers: string[] }): Promise<{ products: Product[] }> {\n console.error('getProducts only mocked in web ' + options);\n return { products: [] };\n }\n\n async getProduct(options: { productIdentifier: string }): 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<Transaction> {\n console.error('purchaseProduct only mocked in web' + options);\n return { transactionId: 'transactionId' } as any;\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 async getPurchases(options?: { productType?: PURCHASE_TYPE }): Promise<{ purchases: Transaction[] }> {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions(): Promise<void> {\n console.error('manageSubscriptions only mocked in web');\n }\n\n async acknowledgePurchase(_options: { purchaseToken: string }): Promise<void> {\n console.error('acknowledgePurchase only mocked in web');\n }\n\n async getAppTransaction(): Promise<{ appTransaction: AppTransaction }> {\n console.error('getAppTransaction only mocked in web');\n return {\n appTransaction: {\n originalAppVersion: '1.0.0',\n originalPurchaseDate: new Date().toISOString(),\n bundleId: 'com.example.app',\n appVersion: '1.0.0',\n environment: null,\n },\n };\n }\n\n async isEntitledToOldBusinessModel(_options: {\n targetVersion: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }> {\n console.error('isEntitledToOldBusinessModel only mocked in web');\n return {\n isOlderVersion: false,\n originalAppVersion: '1.0.0',\n };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -168,6 +168,25 @@ class NativePurchasesWeb extends core.WebPlugin {
|
|
|
168
168
|
async acknowledgePurchase(_options) {
|
|
169
169
|
console.error('acknowledgePurchase only mocked in web');
|
|
170
170
|
}
|
|
171
|
+
async getAppTransaction() {
|
|
172
|
+
console.error('getAppTransaction only mocked in web');
|
|
173
|
+
return {
|
|
174
|
+
appTransaction: {
|
|
175
|
+
originalAppVersion: '1.0.0',
|
|
176
|
+
originalPurchaseDate: new Date().toISOString(),
|
|
177
|
+
bundleId: 'com.example.app',
|
|
178
|
+
appVersion: '1.0.0',
|
|
179
|
+
environment: null,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
async isEntitledToOldBusinessModel(_options) {
|
|
184
|
+
console.error('isEntitledToOldBusinessModel only mocked in web');
|
|
185
|
+
return {
|
|
186
|
+
isOlderVersion: false,
|
|
187
|
+
originalAppVersion: '1.0.0',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
171
190
|
}
|
|
172
191
|
|
|
173
192
|
var web = /*#__PURE__*/Object.freeze({
|
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 * 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 class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error('restorePurchases only mocked in web');\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 async getPurchases(options) {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions() {\n console.error('manageSubscriptions only mocked in web');\n }\n async acknowledgePurchase(_options) {\n console.error('acknowledgePurchase only mocked in web');\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;AACX,CAAC,UAAU,mBAAmB,EAAE;AAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB;AACzF,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;AACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW;AAC3E,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;AACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GA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AAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;AACxD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;AACrC,IAAI;AACJ,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;AAChC,QAAQ,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC;AACnE,QAAQ,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;AAChC,IAAI;AACJ,IAAI,MAAM,mBAAmB,GAAG;AAChC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAC/D,IAAI;AACJ,IAAI,MAAM,mBAAmB,CAAC,QAAQ,EAAE;AACxC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAC/D,IAAI;AACJ;;;;;;;;;"}
|
|
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 * 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 class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error('restorePurchases only mocked in web');\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 async getPurchases(options) {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions() {\n console.error('manageSubscriptions only mocked in web');\n }\n async acknowledgePurchase(_options) {\n console.error('acknowledgePurchase only mocked in web');\n }\n async getAppTransaction() {\n console.error('getAppTransaction only mocked in web');\n return {\n appTransaction: {\n originalAppVersion: '1.0.0',\n originalPurchaseDate: new Date().toISOString(),\n bundleId: 'com.example.app',\n appVersion: '1.0.0',\n environment: null,\n },\n };\n }\n async isEntitledToOldBusinessModel(_options) {\n console.error('isEntitledToOldBusinessModel only mocked in web');\n return {\n isOlderVersion: false,\n originalAppVersion: '1.0.0',\n };\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;AACX,CAAC,UAAU,mBAAmB,EAAE;AAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB;AACzF,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;AACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW;AAC3E,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;AACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;AACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;AACzE,CAAC,EAAEA,2BAAmB,KAAKA,2BAAmB,GAAG,EAAE,CAAC,CAAC;AAC1CC;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA;AACA;AACA,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;AACpC;AACA;AACA;AACA,IA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,IAAI,MAAM,mBAAmB,GAAG;AAChC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAC/D,IAAI;AACJ,IAAI,MAAM,mBAAmB,CAAC,QAAQ,EAAE;AACxC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;AAC/D,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC;AAC7D,QAAQ,OAAO;AACf,YAAY,cAAc,EAAE;AAC5B,gBAAgB,kBAAkB,EAAE,OAAO;AAC3C,gBAAgB,oBAAoB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC9D,gBAAgB,QAAQ,EAAE,iBAAiB;AAC3C,gBAAgB,UAAU,EAAE,OAAO;AACnC,gBAAgB,WAAW,EAAE,IAAI;AACjC,aAAa;AACb,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,4BAA4B,CAAC,QAAQ,EAAE;AACjD,QAAQ,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC;AACxE,QAAQ,OAAO;AACf,YAAY,cAAc,EAAE,KAAK;AACjC,YAAY,kBAAkB,EAAE,OAAO;AACvC,SAAS;AACT,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -167,6 +167,25 @@ var capacitorNativePurchases = (function (exports, core) {
|
|
|
167
167
|
async acknowledgePurchase(_options) {
|
|
168
168
|
console.error('acknowledgePurchase only mocked in web');
|
|
169
169
|
}
|
|
170
|
+
async getAppTransaction() {
|
|
171
|
+
console.error('getAppTransaction only mocked in web');
|
|
172
|
+
return {
|
|
173
|
+
appTransaction: {
|
|
174
|
+
originalAppVersion: '1.0.0',
|
|
175
|
+
originalPurchaseDate: new Date().toISOString(),
|
|
176
|
+
bundleId: 'com.example.app',
|
|
177
|
+
appVersion: '1.0.0',
|
|
178
|
+
environment: null,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async isEntitledToOldBusinessModel(_options) {
|
|
183
|
+
console.error('isEntitledToOldBusinessModel only mocked in web');
|
|
184
|
+
return {
|
|
185
|
+
isOlderVersion: false,
|
|
186
|
+
originalAppVersion: '1.0.0',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
170
189
|
}
|
|
171
190
|
|
|
172
191
|
var web = /*#__PURE__*/Object.freeze({
|
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 * 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 class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error('restorePurchases only mocked in web');\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 async getPurchases(options) {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions() {\n console.error('manageSubscriptions only mocked in web');\n }\n async acknowledgePurchase(_options) {\n console.error('acknowledgePurchase only mocked in web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ATTRIBUTION_NETWORK","PURCHASE_TYPE","BILLING_FEATURE","PRORATION_MODE","PACKAGE_TYPE","INTRO_ELIGIBILITY_STATUS","registerPlugin","WebPlugin"],"m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AAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC;IACjE,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;IAC9B,IAAI;IACJ,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;IACnC,QAAQ,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC;IACrE,QAAQ,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE;IACjD,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC;IAC9D,QAAQ,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE;IAC5C,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;IACxD,QAAQ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE;IACrC,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;IAChC,QAAQ,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC;IACnE,QAAQ,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;IAChC,IAAI;IACJ,IAAI,MAAM,mBAAmB,GAAG;IAChC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;IAC/D,IAAI;IACJ,IAAI,MAAM,mBAAmB,CAAC,QAAQ,EAAE;IACxC,QAAQ,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC;IAC/D,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
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 * 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 class NativePurchasesWeb extends WebPlugin {\n async restorePurchases() {\n console.error('restorePurchases only mocked in web');\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 async getPurchases(options) {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions() {\n console.error('manageSubscriptions only mocked in web');\n }\n async acknowledgePurchase(_options) {\n console.error('acknowledgePurchase only mocked in web');\n }\n async getAppTransaction() {\n console.error('getAppTransaction only mocked in web');\n return {\n appTransaction: {\n originalAppVersion: '1.0.0',\n originalPurchaseDate: new Date().toISOString(),\n bundleId: 'com.example.app',\n appVersion: '1.0.0',\n environment: null,\n },\n };\n }\n async isEntitledToOldBusinessModel(_options) {\n console.error('isEntitledToOldBusinessModel only mocked in web');\n return {\n isOlderVersion: false,\n originalAppVersion: '1.0.0',\n };\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;IACX,CAAC,UAAU,mBAAmB,EAAE;IAChC,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,kBAAkB;IACzF,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;IACrE,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,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IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -19,10 +19,12 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
19
19
|
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
20
20
|
CAPPluginMethod(name: "getPurchases", returnType: CAPPluginReturnPromise),
|
|
21
21
|
CAPPluginMethod(name: "manageSubscriptions", returnType: CAPPluginReturnPromise),
|
|
22
|
-
CAPPluginMethod(name: "acknowledgePurchase", returnType: CAPPluginReturnPromise)
|
|
22
|
+
CAPPluginMethod(name: "acknowledgePurchase", returnType: CAPPluginReturnPromise),
|
|
23
|
+
CAPPluginMethod(name: "getAppTransaction", returnType: CAPPluginReturnPromise),
|
|
24
|
+
CAPPluginMethod(name: "isEntitledToOldBusinessModel", returnType: CAPPluginReturnPromise)
|
|
23
25
|
]
|
|
24
26
|
|
|
25
|
-
private let pluginVersion: String = "7.
|
|
27
|
+
private let pluginVersion: String = "7.16.0"
|
|
26
28
|
private var transactionUpdatesTask: Task<Void, Never>?
|
|
27
29
|
|
|
28
30
|
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
@@ -359,4 +361,118 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
359
361
|
}
|
|
360
362
|
}
|
|
361
363
|
|
|
364
|
+
@objc func getAppTransaction(_ call: CAPPluginCall) {
|
|
365
|
+
if #available(iOS 16.0, *) {
|
|
366
|
+
print("getAppTransaction called on iOS")
|
|
367
|
+
Task { @MainActor in
|
|
368
|
+
do {
|
|
369
|
+
let verificationResult = try await AppTransaction.shared
|
|
370
|
+
switch verificationResult {
|
|
371
|
+
case .verified(let appTransaction):
|
|
372
|
+
var response: [String: Any] = [:]
|
|
373
|
+
|
|
374
|
+
// originalAppVersion is the CFBundleShortVersionString at the time of original download
|
|
375
|
+
response["originalAppVersion"] = appTransaction.originalAppVersion
|
|
376
|
+
|
|
377
|
+
// Original purchase date
|
|
378
|
+
response["originalPurchaseDate"] = ISO8601DateFormatter().string(from: appTransaction.originalPurchaseDate)
|
|
379
|
+
|
|
380
|
+
// Bundle ID
|
|
381
|
+
response["bundleId"] = appTransaction.bundleID
|
|
382
|
+
|
|
383
|
+
// Current app version
|
|
384
|
+
response["appVersion"] = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
|
|
385
|
+
|
|
386
|
+
// Environment
|
|
387
|
+
switch appTransaction.environment {
|
|
388
|
+
case .sandbox:
|
|
389
|
+
response["environment"] = "Sandbox"
|
|
390
|
+
case .production:
|
|
391
|
+
response["environment"] = "Production"
|
|
392
|
+
case .xcode:
|
|
393
|
+
response["environment"] = "Xcode"
|
|
394
|
+
default:
|
|
395
|
+
response["environment"] = "Production"
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// JWS representation for server-side verification
|
|
399
|
+
response["jwsRepresentation"] = verificationResult.jwsRepresentation
|
|
400
|
+
|
|
401
|
+
call.resolve(["appTransaction": response])
|
|
402
|
+
|
|
403
|
+
case .unverified(_, let error):
|
|
404
|
+
call.reject("App transaction verification failed: \(error.localizedDescription)")
|
|
405
|
+
}
|
|
406
|
+
} catch {
|
|
407
|
+
print("getAppTransaction error: \(error)")
|
|
408
|
+
call.reject("Failed to get app transaction: \(error.localizedDescription)")
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
print("getAppTransaction not implemented under iOS 16")
|
|
413
|
+
call.reject("App Transaction requires iOS 16.0 or later")
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@objc func isEntitledToOldBusinessModel(_ call: CAPPluginCall) {
|
|
418
|
+
guard let targetVersion = call.getString("targetVersion"), !targetVersion.isEmpty else {
|
|
419
|
+
call.reject("targetVersion is required")
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if #available(iOS 16.0, *) {
|
|
424
|
+
print("isEntitledToOldBusinessModel called with targetVersion: \(targetVersion)")
|
|
425
|
+
Task { @MainActor in
|
|
426
|
+
do {
|
|
427
|
+
let verificationResult = try await AppTransaction.shared
|
|
428
|
+
switch verificationResult {
|
|
429
|
+
case .verified(let appTransaction):
|
|
430
|
+
let originalVersion = appTransaction.originalAppVersion
|
|
431
|
+
|
|
432
|
+
// Compare versions using semantic versioning
|
|
433
|
+
let isOlder = self.compareVersions(originalVersion, targetVersion) < 0
|
|
434
|
+
|
|
435
|
+
call.resolve([
|
|
436
|
+
"isOlderVersion": isOlder,
|
|
437
|
+
"originalAppVersion": originalVersion
|
|
438
|
+
])
|
|
439
|
+
|
|
440
|
+
case .unverified(_, let error):
|
|
441
|
+
call.reject("App transaction verification failed: \(error.localizedDescription)")
|
|
442
|
+
}
|
|
443
|
+
} catch {
|
|
444
|
+
print("isEntitledToOldBusinessModel error: \(error)")
|
|
445
|
+
call.reject("Failed to get app transaction: \(error.localizedDescription)")
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
print("isEntitledToOldBusinessModel not implemented under iOS 16")
|
|
450
|
+
call.reject("App Transaction requires iOS 16.0 or later")
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// MARK: - Version Comparison Helper
|
|
455
|
+
|
|
456
|
+
/// Compares two semantic version strings.
|
|
457
|
+
/// Returns: negative if v1 < v2, zero if v1 == v2, positive if v1 > v2
|
|
458
|
+
private func compareVersions(_ version1: String, _ version2: String) -> Int {
|
|
459
|
+
let v1Components = version1.split(separator: ".").compactMap { Int($0) }
|
|
460
|
+
let v2Components = version2.split(separator: ".").compactMap { Int($0) }
|
|
461
|
+
|
|
462
|
+
let maxLength = max(v1Components.count, v2Components.count)
|
|
463
|
+
|
|
464
|
+
for i in 0..<maxLength {
|
|
465
|
+
let v1Value = i < v1Components.count ? v1Components[i] : 0
|
|
466
|
+
let v2Value = i < v2Components.count ? v2Components[i] : 0
|
|
467
|
+
|
|
468
|
+
if v1Value < v2Value {
|
|
469
|
+
return -1
|
|
470
|
+
} else if v1Value > v2Value {
|
|
471
|
+
return 1
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return 0
|
|
476
|
+
}
|
|
477
|
+
|
|
362
478
|
}
|