capacitor-native-purchases 0.1.1
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/CapacitorPurchases.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +295 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/jok/purchases/capacitor/Purchases.java +400 -0
- package/android/src/main/java/jok/purchases/capacitor/PurchasesPlugin.java +169 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +701 -0
- package/dist/esm/definitions.d.ts +88 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +26 -0
- package/dist/esm/web.js +43 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +57 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +60 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/PurchasesPlugin/Purchases.swift +341 -0
- package/ios/Sources/PurchasesPlugin/PurchasesPlugin.swift +116 -0
- package/ios/Tests/PurchasesPluginTests/PurchasesTests.swift +15 -0
- package/package.json +83 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorPurchases'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/Package.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "CapacitorPurchases",
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "CapacitorPurchases",
|
|
10
|
+
targets: ["PurchasesPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "PurchasesPlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/PurchasesPlugin"),
|
|
23
|
+
.testTarget(
|
|
24
|
+
name: "PurchasesPluginTests",
|
|
25
|
+
dependencies: ["PurchasesPlugin"],
|
|
26
|
+
path: "ios/Tests/PurchasesPluginTests")
|
|
27
|
+
]
|
|
28
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# capacitor-purchases
|
|
2
|
+
|
|
3
|
+
IAP Purchases integration for iOS and Android
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install capacitor-purchases
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`echo(...)`](#echo)
|
|
17
|
+
* [`getProductDetails(...)`](#getproductdetails)
|
|
18
|
+
* [`purchaseProduct(...)`](#purchaseproduct)
|
|
19
|
+
* [`getCurrentEntitlements()`](#getcurrententitlements)
|
|
20
|
+
* [`getLatestTransaction(...)`](#getlatesttransaction)
|
|
21
|
+
* [`manageSubscriptions()`](#managesubscriptions)
|
|
22
|
+
* [`setGoogleVerificationDetails(...)`](#setgoogleverificationdetails)
|
|
23
|
+
* [`addListener('ANDROID-PURCHASE-RESPONSE', ...)`](#addlistenerandroid-purchase-response-)
|
|
24
|
+
* [`restorePurchases()`](#restorepurchases)
|
|
25
|
+
* [Interfaces](#interfaces)
|
|
26
|
+
* [Type Aliases](#type-aliases)
|
|
27
|
+
|
|
28
|
+
</docgen-index>
|
|
29
|
+
|
|
30
|
+
<docgen-api>
|
|
31
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
32
|
+
|
|
33
|
+
### echo(...)
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
echo(options: { value: string; }) => Promise<{ value: string; }>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A test method which just returns what is passed in
|
|
40
|
+
|
|
41
|
+
| Param | Type |
|
|
42
|
+
| ------------- | ------------------------------- |
|
|
43
|
+
| **`options`** | <code>{ value: string; }</code> |
|
|
44
|
+
|
|
45
|
+
**Returns:** <code>Promise<{ value: string; }></code>
|
|
46
|
+
|
|
47
|
+
--------------------
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### getProductDetails(...)
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
getProductDetails(options: { productIdentifier: string; }) => Promise<ProductDetailsResponse>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Receives a product ID and returns the product details
|
|
57
|
+
|
|
58
|
+
| Param | Type |
|
|
59
|
+
| ------------- | ------------------------------------------- |
|
|
60
|
+
| **`options`** | <code>{ productIdentifier: string; }</code> |
|
|
61
|
+
|
|
62
|
+
**Returns:** <code>Promise<<a href="#productdetailsresponse">ProductDetailsResponse</a>></code>
|
|
63
|
+
|
|
64
|
+
--------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### purchaseProduct(...)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
purchaseProduct(options: { productIdentifier: string; userId?: string; }) => Promise<PurchaseProductResponse>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Receives the product ID which the user wants to purchase and returns the transaction ID
|
|
74
|
+
|
|
75
|
+
| Param | Type |
|
|
76
|
+
| ------------- | ------------------------------------------------------------ |
|
|
77
|
+
| **`options`** | <code>{ productIdentifier: string; userId?: string; }</code> |
|
|
78
|
+
|
|
79
|
+
**Returns:** <code>Promise<<a href="#purchaseproductresponse">PurchaseProductResponse</a>></code>
|
|
80
|
+
|
|
81
|
+
--------------------
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### getCurrentEntitlements()
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
getCurrentEntitlements() => Promise<CurrentEntitlementsResponse>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Returns:** <code>Promise<<a href="#currententitlementsresponse">CurrentEntitlementsResponse</a>></code>
|
|
91
|
+
|
|
92
|
+
--------------------
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### getLatestTransaction(...)
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
getLatestTransaction(options: { productIdentifier: string; }) => Promise<LatestTransactionResponse>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
| Param | Type |
|
|
102
|
+
| ------------- | ------------------------------------------- |
|
|
103
|
+
| **`options`** | <code>{ productIdentifier: string; }</code> |
|
|
104
|
+
|
|
105
|
+
**Returns:** <code>Promise<<a href="#latesttransactionresponse">LatestTransactionResponse</a>></code>
|
|
106
|
+
|
|
107
|
+
--------------------
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### manageSubscriptions()
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
manageSubscriptions() => any
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Returns:** <code>any</code>
|
|
117
|
+
|
|
118
|
+
--------------------
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### setGoogleVerificationDetails(...)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
setGoogleVerificationDetails(options: { googleVerifyEndpoint: string; bid: string; }) => void
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
| Param | Type |
|
|
128
|
+
| ------------- | ----------------------------------------------------------- |
|
|
129
|
+
| **`options`** | <code>{ googleVerifyEndpoint: string; bid: string; }</code> |
|
|
130
|
+
|
|
131
|
+
--------------------
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### addListener('ANDROID-PURCHASE-RESPONSE', ...)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
addListener(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void) => Promise<PluginListenerHandle>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
| Param | Type |
|
|
141
|
+
| ------------------ | -------------------------------------------------------------------------------------------------- |
|
|
142
|
+
| **`eventName`** | <code>'ANDROID-PURCHASE-RESPONSE'</code> |
|
|
143
|
+
| **`listenerFunc`** | <code>(response: <a href="#androidpurchasedtrigger">AndroidPurchasedTrigger</a>) => void</code> |
|
|
144
|
+
|
|
145
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
146
|
+
|
|
147
|
+
--------------------
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### restorePurchases()
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
restorePurchases() => Promise<RestorePurchasesResponse>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Returns:** <code>Promise<<a href="#restorepurchasesresponse">RestorePurchasesResponse</a>></code>
|
|
157
|
+
|
|
158
|
+
--------------------
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Interfaces
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
#### ProductDetailsResponse
|
|
165
|
+
|
|
166
|
+
| Prop | Type |
|
|
167
|
+
| --------------------- | --------------------------------------------------------------------------------------- |
|
|
168
|
+
| **`responseCode`** | <code><a href="#productdetailsresponsecode">ProductDetailsResponseCode</a></code> |
|
|
169
|
+
| **`responseMessage`** | <code><a href="#productdetailsresponsemessage">ProductDetailsResponseMessage</a></code> |
|
|
170
|
+
| **`data`** | <code><a href="#product">Product</a></code> |
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
#### Product
|
|
174
|
+
|
|
175
|
+
| Prop | Type |
|
|
176
|
+
| ----------------------- | ------------------- |
|
|
177
|
+
| **`productIdentifier`** | <code>string</code> |
|
|
178
|
+
| **`price`** | <code>string</code> |
|
|
179
|
+
| **`displayName`** | <code>string</code> |
|
|
180
|
+
| **`description`** | <code>string</code> |
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
#### PurchaseProductResponse
|
|
184
|
+
|
|
185
|
+
| Prop | Type |
|
|
186
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
187
|
+
| **`responseCode`** | <code>0 \| 1 \| 2 \| 5 \| 4 \| 3 \| -1</code> |
|
|
188
|
+
| **`responseMessage`** | <code>'Incompatible with web' \| 'Could not find a product matching the given productIdentifier' \| 'Successfully purchased product' \| '<a href="#product">Product</a> seems to have been purchased but the transaction failed verification' \| 'User closed the native popover before purchasing' \| '<a href="#product">Product</a> request made but is currently pending - likely due to parental restrictions' \| 'An unknown error occurred whilst in the purchasing process' \| 'Successfully opened native popover' \| 'Failed to open native popover'</code> |
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
#### CurrentEntitlementsResponse
|
|
192
|
+
|
|
193
|
+
| Prop | Type |
|
|
194
|
+
| --------------------- | ------------------------------------------------------------------------------------------------- |
|
|
195
|
+
| **`responseCode`** | <code><a href="#currententitlementsresponsecode">CurrentEntitlementsResponseCode</a></code> |
|
|
196
|
+
| **`responseMessage`** | <code><a href="#currententitlementsresponsemessage">CurrentEntitlementsResponseMessage</a></code> |
|
|
197
|
+
| **`data`** | <code>Transaction[]</code> |
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
#### Transaction
|
|
201
|
+
|
|
202
|
+
| Prop | Type |
|
|
203
|
+
| ----------------------- | -------------------- |
|
|
204
|
+
| **`productIdentifier`** | <code>string</code> |
|
|
205
|
+
| **`expiryDate`** | <code>string</code> |
|
|
206
|
+
| **`originalId`** | <code>string</code> |
|
|
207
|
+
| **`transactionId`** | <code>string</code> |
|
|
208
|
+
| **`originalStartDate`** | <code>string</code> |
|
|
209
|
+
| **`isTrial`** | <code>boolean</code> |
|
|
210
|
+
| **`purchaseToken`** | <code>string</code> |
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
#### LatestTransactionResponse
|
|
214
|
+
|
|
215
|
+
| Prop | Type |
|
|
216
|
+
| --------------------- | --------------------------------------------------------------------------------------------- |
|
|
217
|
+
| **`responseCode`** | <code><a href="#latesttransactionresponsecode">LatestTransactionResponseCode</a></code> |
|
|
218
|
+
| **`responseMessage`** | <code><a href="#latesttransactionresponsemessage">LatestTransactionResponseMessage</a></code> |
|
|
219
|
+
| **`data`** | <code><a href="#transaction">Transaction</a></code> |
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
#### PluginListenerHandle
|
|
223
|
+
|
|
224
|
+
| Prop | Type |
|
|
225
|
+
| ------------ | ----------------------------------------- |
|
|
226
|
+
| **`remove`** | <code>() => Promise<void></code> |
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
#### AndroidPurchasedTrigger
|
|
230
|
+
|
|
231
|
+
| Prop | Type |
|
|
232
|
+
| ----------- | -------------------- |
|
|
233
|
+
| **`fired`** | <code>boolean</code> |
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
#### RestorePurchasesResponse
|
|
237
|
+
|
|
238
|
+
| Prop | Type |
|
|
239
|
+
| --------------- | -------------------- |
|
|
240
|
+
| **`completed`** | <code>boolean</code> |
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Type Aliases
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
#### ProductDetailsResponseCode
|
|
247
|
+
|
|
248
|
+
<code>-1 | 0 | 1</code>
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
#### ProductDetailsResponseMessage
|
|
252
|
+
|
|
253
|
+
<code>'Incompatible with web' | 'Successfully found the product details for given productIdentifier' | 'Could not find a product matching the given productIdentifier'</code>
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
#### PurchaseProductIOSResponseCode
|
|
257
|
+
|
|
258
|
+
<code>-1 | 0 | 1 | 2 | 3 | 4 | 5</code>
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
#### PurchaseProductAndroidResponseCode
|
|
262
|
+
|
|
263
|
+
<code>-1 | 0 | 1</code>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
#### PurchaseProductIOSResponseMessage
|
|
267
|
+
|
|
268
|
+
<code>'Incompatible with web' | 'Successfully purchased product' | 'Could not find a product matching the given productIdentifier' | '<a href="#product">Product</a> seems to have been purchased but the transaction failed verification' | 'User closed the native popover before purchasing' | '<a href="#product">Product</a> request made but is currently pending - likely due to parental restrictions' | 'An unknown error occurred whilst in the purchasing process'</code>
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
#### PurchaseProductAndroidResponseMessage
|
|
272
|
+
|
|
273
|
+
<code>'Incompatible with web' | 'Successfully opened native popover' | 'Failed to open native popover'</code>
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
#### CurrentEntitlementsResponseCode
|
|
277
|
+
|
|
278
|
+
<code>-1 | 0 | 1 | 2</code>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
#### CurrentEntitlementsResponseMessage
|
|
282
|
+
|
|
283
|
+
<code>'Incompatible with web' | 'Successfully found all entitlements across all product types' | 'No entitlements were found' | 'Unknown problem trying to retrieve entitlements'</code>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
#### LatestTransactionResponseCode
|
|
287
|
+
|
|
288
|
+
<code>-1 | 0 | 1 | 2 | 3</code>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
#### LatestTransactionResponseMessage
|
|
292
|
+
|
|
293
|
+
<code>'Incompatible with web' | 'Successfully found the latest transaction matching given productIdentifier' | 'Could not find a product matching the given productIdentifier' | 'No transaction for given productIdentifier, or it could not be verified' | 'Unknown problem trying to retrieve latest transaction'</code>
|
|
294
|
+
|
|
295
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace = "jok.purchases.capacitor"
|
|
22
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError = false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|