@capgo/native-purchases 7.3.1 → 7.4.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 +21 -4
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +98 -0
- package/dist/docs.json +119 -0
- package/dist/esm/definitions.d.ts +68 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -3
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/NativePurchasesPlugin.swift +69 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -848,10 +848,27 @@ This method queries the platform's purchase history for the current user.
|
|
|
848
848
|
|
|
849
849
|
#### Transaction
|
|
850
850
|
|
|
851
|
-
| Prop
|
|
852
|
-
|
|
|
853
|
-
| **`transactionId`**
|
|
854
|
-
| **`receipt`**
|
|
851
|
+
| Prop | Type | Description |
|
|
852
|
+
| -------------------------- | -------------------- | --------------------------------------------------------------------------------- |
|
|
853
|
+
| **`transactionId`** | <code>string</code> | RevenueCat Id associated to the transaction. |
|
|
854
|
+
| **`receipt`** | <code>string</code> | Receipt data for validation (iOS only - base64 encoded receipt) |
|
|
855
|
+
| **`productIdentifier`** | <code>string</code> | <a href="#product">Product</a> Id associated with the transaction. |
|
|
856
|
+
| **`purchaseDate`** | <code>string</code> | Purchase date of the transaction in ISO 8601 format. |
|
|
857
|
+
| **`originalPurchaseDate`** | <code>string</code> | Original purchase date of the transaction in ISO 8601 format (for subscriptions). |
|
|
858
|
+
| **`expirationDate`** | <code>string</code> | Expiration date of the transaction in ISO 8601 format (for subscriptions). |
|
|
859
|
+
| **`isActive`** | <code>boolean</code> | Whether the transaction is still active/valid. |
|
|
860
|
+
| **`purchaseState`** | <code>string</code> | Purchase state of the transaction. |
|
|
861
|
+
| **`orderId`** | <code>string</code> | Order ID associated with the transaction (Android). |
|
|
862
|
+
| **`purchaseToken`** | <code>string</code> | Purchase token associated with the transaction (Android). |
|
|
863
|
+
| **`isAcknowledged`** | <code>boolean</code> | Whether the purchase has been acknowledged (Android). |
|
|
864
|
+
| **`quantity`** | <code>number</code> | Quantity purchased. |
|
|
865
|
+
| **`productType`** | <code>string</code> | <a href="#product">Product</a> type (inapp or subs). |
|
|
866
|
+
| **`isTrialPeriod`** | <code>boolean</code> | Whether the transaction is a trial period. |
|
|
867
|
+
| **`isInIntroPricePeriod`** | <code>boolean</code> | Whether the transaction is in intro price period. |
|
|
868
|
+
| **`isInGracePeriod`** | <code>boolean</code> | Whether the transaction is in grace period. |
|
|
869
|
+
| **`isRevoked`** | <code>boolean</code> | Whether the transaction is revoked. |
|
|
870
|
+
| **`revocationDate`** | <code>string</code> | Revocation date if the transaction was revoked. |
|
|
871
|
+
| **`revocationReason`** | <code>string</code> | Revocation reason if the transaction was revoked. |
|
|
855
872
|
|
|
856
873
|
|
|
857
874
|
#### Product
|
|
@@ -145,6 +145,38 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
145
145
|
|
|
146
146
|
JSObject ret = new JSObject();
|
|
147
147
|
ret.put("transactionId", purchase.getPurchaseToken());
|
|
148
|
+
ret.put("productIdentifier", purchase.getProducts().get(0));
|
|
149
|
+
ret.put(
|
|
150
|
+
"purchaseDate",
|
|
151
|
+
new java.text.SimpleDateFormat(
|
|
152
|
+
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
153
|
+
java.util.Locale.US
|
|
154
|
+
).format(new java.util.Date(purchase.getPurchaseTime()))
|
|
155
|
+
);
|
|
156
|
+
ret.put("quantity", purchase.getQuantity());
|
|
157
|
+
ret.put(
|
|
158
|
+
"productType",
|
|
159
|
+
purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED
|
|
160
|
+
? "inapp"
|
|
161
|
+
: "subs"
|
|
162
|
+
);
|
|
163
|
+
ret.put("orderId", purchase.getOrderId());
|
|
164
|
+
ret.put("purchaseToken", purchase.getPurchaseToken());
|
|
165
|
+
ret.put("isAcknowledged", purchase.isAcknowledged());
|
|
166
|
+
ret.put("purchaseState", String.valueOf(purchase.getPurchaseState()));
|
|
167
|
+
|
|
168
|
+
// For subscriptions, try to get additional information
|
|
169
|
+
if (
|
|
170
|
+
purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED &&
|
|
171
|
+
purchase.getProducts().get(0).contains("sub")
|
|
172
|
+
) {
|
|
173
|
+
// Note: Android doesn't provide direct expiration date in Purchase object
|
|
174
|
+
// This would need to be calculated based on subscription period or fetched from Google Play API
|
|
175
|
+
ret.put("productType", "subs");
|
|
176
|
+
// For subscriptions, we can't get expiration date directly from Purchase object
|
|
177
|
+
// This would require additional Google Play API calls to get subscription details
|
|
178
|
+
}
|
|
179
|
+
|
|
148
180
|
Log.d(
|
|
149
181
|
TAG,
|
|
150
182
|
"Resolving purchase call with transactionId: " +
|
|
@@ -899,6 +931,26 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
899
931
|
);
|
|
900
932
|
JSObject purchaseData = new JSObject();
|
|
901
933
|
purchaseData.put("transactionId", purchase.getPurchaseToken());
|
|
934
|
+
purchaseData.put(
|
|
935
|
+
"productIdentifier",
|
|
936
|
+
purchase.getProducts().get(0)
|
|
937
|
+
);
|
|
938
|
+
purchaseData.put(
|
|
939
|
+
"purchaseDate",
|
|
940
|
+
new java.text.SimpleDateFormat(
|
|
941
|
+
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
942
|
+
java.util.Locale.US
|
|
943
|
+
).format(new java.util.Date(purchase.getPurchaseTime()))
|
|
944
|
+
);
|
|
945
|
+
purchaseData.put("quantity", purchase.getQuantity());
|
|
946
|
+
purchaseData.put("productType", "inapp");
|
|
947
|
+
purchaseData.put("orderId", purchase.getOrderId());
|
|
948
|
+
purchaseData.put("purchaseToken", purchase.getPurchaseToken());
|
|
949
|
+
purchaseData.put("isAcknowledged", purchase.isAcknowledged());
|
|
950
|
+
purchaseData.put(
|
|
951
|
+
"purchaseState",
|
|
952
|
+
String.valueOf(purchase.getPurchaseState())
|
|
953
|
+
);
|
|
902
954
|
allPurchases.put(purchaseData);
|
|
903
955
|
}
|
|
904
956
|
}
|
|
@@ -935,6 +987,32 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
935
987
|
"transactionId",
|
|
936
988
|
purchase.getPurchaseToken()
|
|
937
989
|
);
|
|
990
|
+
purchaseData.put(
|
|
991
|
+
"productIdentifier",
|
|
992
|
+
purchase.getProducts().get(0)
|
|
993
|
+
);
|
|
994
|
+
purchaseData.put(
|
|
995
|
+
"purchaseDate",
|
|
996
|
+
new java.text.SimpleDateFormat(
|
|
997
|
+
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
998
|
+
java.util.Locale.US
|
|
999
|
+
).format(new java.util.Date(purchase.getPurchaseTime()))
|
|
1000
|
+
);
|
|
1001
|
+
purchaseData.put("quantity", purchase.getQuantity());
|
|
1002
|
+
purchaseData.put("productType", "subs");
|
|
1003
|
+
purchaseData.put("orderId", purchase.getOrderId());
|
|
1004
|
+
purchaseData.put(
|
|
1005
|
+
"purchaseToken",
|
|
1006
|
+
purchase.getPurchaseToken()
|
|
1007
|
+
);
|
|
1008
|
+
purchaseData.put(
|
|
1009
|
+
"isAcknowledged",
|
|
1010
|
+
purchase.isAcknowledged()
|
|
1011
|
+
);
|
|
1012
|
+
purchaseData.put(
|
|
1013
|
+
"purchaseState",
|
|
1014
|
+
String.valueOf(purchase.getPurchaseState())
|
|
1015
|
+
);
|
|
938
1016
|
allPurchases.put(purchaseData);
|
|
939
1017
|
}
|
|
940
1018
|
}
|
|
@@ -990,6 +1068,26 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
990
1068
|
);
|
|
991
1069
|
JSObject purchaseData = new JSObject();
|
|
992
1070
|
purchaseData.put("transactionId", purchase.getPurchaseToken());
|
|
1071
|
+
purchaseData.put(
|
|
1072
|
+
"productIdentifier",
|
|
1073
|
+
purchase.getProducts().get(0)
|
|
1074
|
+
);
|
|
1075
|
+
purchaseData.put(
|
|
1076
|
+
"purchaseDate",
|
|
1077
|
+
new java.text.SimpleDateFormat(
|
|
1078
|
+
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
1079
|
+
java.util.Locale.US
|
|
1080
|
+
).format(new java.util.Date(purchase.getPurchaseTime()))
|
|
1081
|
+
);
|
|
1082
|
+
purchaseData.put("quantity", purchase.getQuantity());
|
|
1083
|
+
purchaseData.put("productType", "subs");
|
|
1084
|
+
purchaseData.put("orderId", purchase.getOrderId());
|
|
1085
|
+
purchaseData.put("purchaseToken", purchase.getPurchaseToken());
|
|
1086
|
+
purchaseData.put("isAcknowledged", purchase.isAcknowledged());
|
|
1087
|
+
purchaseData.put(
|
|
1088
|
+
"purchaseState",
|
|
1089
|
+
String.valueOf(purchase.getPurchaseState())
|
|
1090
|
+
);
|
|
993
1091
|
allPurchases.put(purchaseData);
|
|
994
1092
|
}
|
|
995
1093
|
}
|
package/dist/docs.json
CHANGED
|
@@ -224,6 +224,125 @@
|
|
|
224
224
|
"docs": "Receipt data for validation (iOS only - base64 encoded receipt)",
|
|
225
225
|
"complexTypes": [],
|
|
226
226
|
"type": "string | undefined"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "productIdentifier",
|
|
230
|
+
"tags": [],
|
|
231
|
+
"docs": "Product Id associated with the transaction.",
|
|
232
|
+
"complexTypes": [],
|
|
233
|
+
"type": "string"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"name": "purchaseDate",
|
|
237
|
+
"tags": [],
|
|
238
|
+
"docs": "Purchase date of the transaction in ISO 8601 format.",
|
|
239
|
+
"complexTypes": [],
|
|
240
|
+
"type": "string"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "originalPurchaseDate",
|
|
244
|
+
"tags": [],
|
|
245
|
+
"docs": "Original purchase date of the transaction in ISO 8601 format (for subscriptions).",
|
|
246
|
+
"complexTypes": [],
|
|
247
|
+
"type": "string | undefined"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"name": "expirationDate",
|
|
251
|
+
"tags": [],
|
|
252
|
+
"docs": "Expiration date of the transaction in ISO 8601 format (for subscriptions).",
|
|
253
|
+
"complexTypes": [],
|
|
254
|
+
"type": "string | undefined"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "isActive",
|
|
258
|
+
"tags": [],
|
|
259
|
+
"docs": "Whether the transaction is still active/valid.",
|
|
260
|
+
"complexTypes": [],
|
|
261
|
+
"type": "boolean | undefined"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "purchaseState",
|
|
265
|
+
"tags": [],
|
|
266
|
+
"docs": "Purchase state of the transaction.",
|
|
267
|
+
"complexTypes": [],
|
|
268
|
+
"type": "string | undefined"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "orderId",
|
|
272
|
+
"tags": [],
|
|
273
|
+
"docs": "Order ID associated with the transaction (Android).",
|
|
274
|
+
"complexTypes": [],
|
|
275
|
+
"type": "string | undefined"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "purchaseToken",
|
|
279
|
+
"tags": [],
|
|
280
|
+
"docs": "Purchase token associated with the transaction (Android).",
|
|
281
|
+
"complexTypes": [],
|
|
282
|
+
"type": "string | undefined"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"name": "isAcknowledged",
|
|
286
|
+
"tags": [],
|
|
287
|
+
"docs": "Whether the purchase has been acknowledged (Android).",
|
|
288
|
+
"complexTypes": [],
|
|
289
|
+
"type": "boolean | undefined"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"name": "quantity",
|
|
293
|
+
"tags": [],
|
|
294
|
+
"docs": "Quantity purchased.",
|
|
295
|
+
"complexTypes": [],
|
|
296
|
+
"type": "number | undefined"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"name": "productType",
|
|
300
|
+
"tags": [],
|
|
301
|
+
"docs": "Product type (inapp or subs).",
|
|
302
|
+
"complexTypes": [],
|
|
303
|
+
"type": "string | undefined"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"name": "isTrialPeriod",
|
|
307
|
+
"tags": [],
|
|
308
|
+
"docs": "Whether the transaction is a trial period.",
|
|
309
|
+
"complexTypes": [],
|
|
310
|
+
"type": "boolean | undefined"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "isInIntroPricePeriod",
|
|
314
|
+
"tags": [],
|
|
315
|
+
"docs": "Whether the transaction is in intro price period.",
|
|
316
|
+
"complexTypes": [],
|
|
317
|
+
"type": "boolean | undefined"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"name": "isInGracePeriod",
|
|
321
|
+
"tags": [],
|
|
322
|
+
"docs": "Whether the transaction is in grace period.",
|
|
323
|
+
"complexTypes": [],
|
|
324
|
+
"type": "boolean | undefined"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"name": "isRevoked",
|
|
328
|
+
"tags": [],
|
|
329
|
+
"docs": "Whether the transaction is revoked.",
|
|
330
|
+
"complexTypes": [],
|
|
331
|
+
"type": "boolean | undefined"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"name": "revocationDate",
|
|
335
|
+
"tags": [],
|
|
336
|
+
"docs": "Revocation date if the transaction was revoked.",
|
|
337
|
+
"complexTypes": [],
|
|
338
|
+
"type": "string | undefined"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "revocationReason",
|
|
342
|
+
"tags": [],
|
|
343
|
+
"docs": "Revocation reason if the transaction was revoked.",
|
|
344
|
+
"complexTypes": [],
|
|
345
|
+
"type": "string | undefined"
|
|
227
346
|
}
|
|
228
347
|
]
|
|
229
348
|
},
|
|
@@ -128,6 +128,74 @@ export interface Transaction {
|
|
|
128
128
|
* Receipt data for validation (iOS only - base64 encoded receipt)
|
|
129
129
|
*/
|
|
130
130
|
readonly receipt?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Product Id associated with the transaction.
|
|
133
|
+
*/
|
|
134
|
+
readonly productIdentifier: string;
|
|
135
|
+
/**
|
|
136
|
+
* Purchase date of the transaction in ISO 8601 format.
|
|
137
|
+
*/
|
|
138
|
+
readonly purchaseDate: string;
|
|
139
|
+
/**
|
|
140
|
+
* Original purchase date of the transaction in ISO 8601 format (for subscriptions).
|
|
141
|
+
*/
|
|
142
|
+
readonly originalPurchaseDate?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Expiration date of the transaction in ISO 8601 format (for subscriptions).
|
|
145
|
+
*/
|
|
146
|
+
readonly expirationDate?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the transaction is still active/valid.
|
|
149
|
+
*/
|
|
150
|
+
readonly isActive?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Purchase state of the transaction.
|
|
153
|
+
*/
|
|
154
|
+
readonly purchaseState?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Order ID associated with the transaction (Android).
|
|
157
|
+
*/
|
|
158
|
+
readonly orderId?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Purchase token associated with the transaction (Android).
|
|
161
|
+
*/
|
|
162
|
+
readonly purchaseToken?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the purchase has been acknowledged (Android).
|
|
165
|
+
*/
|
|
166
|
+
readonly isAcknowledged?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Quantity purchased.
|
|
169
|
+
*/
|
|
170
|
+
readonly quantity?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Product type (inapp or subs).
|
|
173
|
+
*/
|
|
174
|
+
readonly productType?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Whether the transaction is a trial period.
|
|
177
|
+
*/
|
|
178
|
+
readonly isTrialPeriod?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Whether the transaction is in intro price period.
|
|
181
|
+
*/
|
|
182
|
+
readonly isInIntroPricePeriod?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Whether the transaction is in grace period.
|
|
185
|
+
*/
|
|
186
|
+
readonly isInGracePeriod?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the transaction is revoked.
|
|
189
|
+
*/
|
|
190
|
+
readonly isRevoked?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Revocation date if the transaction was revoked.
|
|
193
|
+
*/
|
|
194
|
+
readonly revocationDate?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Revocation reason if the transaction was revoked.
|
|
197
|
+
*/
|
|
198
|
+
readonly revocationReason?: string;
|
|
131
199
|
}
|
|
132
200
|
export interface SubscriptionPeriod {
|
|
133
201
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = \"inapp\",\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = \"subs\",\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = \"UNKNOWN\",\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = \"CUSTOM\",\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = \"LIFETIME\",\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = \"ANNUAL\",\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = \"SIX_MONTH\",\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = \"THREE_MONTH\",\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = \"TWO_MONTH\",\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = \"MONTHLY\",\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = \"WEEKLY\",\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (iOS only - base64 encoded receipt)\n */\n readonly receipt?: string;\n /**\n * Product Id associated with the transaction.\n */\n // readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n // readonly purchaseDate: string;\n}\n\nexport interface SubscriptionPeriod {\n /**\n * The Subscription Period number of unit.\n */\n readonly numberOfUnits: number;\n /**\n * The Subscription Period unit.\n */\n readonly unit: number;\n}\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\n */\n readonly type: number;\n /**\n * The Product discount price.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * The Product discount currency symbol.\n */\n readonly currencySymbol: string;\n /**\n * The Product discount currency code.\n */\n readonly currencyCode: string;\n /**\n * The Product discount paymentMode.\n */\n readonly paymentMode: number;\n /**\n * The Product discount number Of Periods.\n */\n readonly numberOfPeriods: number;\n /**\n * The Product discount subscription period.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n}\nexport interface Product {\n /**\n * Product Id.\n */\n readonly identifier: string;\n /**\n * Description of the product.\n */\n readonly description: string;\n /**\n * Title of the product.\n */\n readonly title: string;\n /**\n * Price of the product in the local currency.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * Currency code for price and original price.\n */\n readonly currencyCode: string;\n /**\n * Currency symbol for price and original price.\n */\n readonly currencySymbol: string;\n /**\n * Boolean indicating if the product is sharable with family\n */\n readonly isFamilyShareable: boolean;\n /**\n * Group identifier for the product.\n */\n readonly subscriptionGroupIdentifier: string;\n /**\n * The Product subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<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 plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Only iOS, UUID for the user's account. Used to link purchases to the user account for App Store Server Notifications.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\n *\n * @param options - The product identifier you wish to retrieve information for\n * @param options.productIdentifier - The product identifier\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProduct(options: {\n productIdentifier: string;\n productType?: PURCHASE_TYPE;\n }): Promise<{ product: Product }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\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 * @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 }): Promise<{ purchases: Transaction[] }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = \"inapp\",\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = \"subs\",\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = \"UNKNOWN\",\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = \"CUSTOM\",\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = \"LIFETIME\",\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = \"ANNUAL\",\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = \"SIX_MONTH\",\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = \"THREE_MONTH\",\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = \"TWO_MONTH\",\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = \"MONTHLY\",\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = \"WEEKLY\",\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * RevenueCat doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (iOS only - base64 encoded receipt)\n */\n readonly receipt?: string;\n /**\n * Product Id associated with the transaction.\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n readonly purchaseDate: string;\n /**\n * Original purchase date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly expirationDate?: string;\n /**\n * Whether the transaction is still active/valid.\n */\n readonly isActive?: boolean;\n /**\n * Purchase state of the transaction.\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction (Android).\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction (Android).\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged (Android).\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n */\n readonly quantity?: number;\n /**\n * Product type (inapp or subs).\n */\n readonly productType?: string;\n /**\n * Whether the transaction is a trial period.\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in intro price period.\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in grace period.\n */\n readonly isInGracePeriod?: boolean;\n /**\n * Whether the transaction is revoked.\n */\n readonly isRevoked?: boolean;\n /**\n * Revocation date if the transaction was revoked.\n */\n readonly revocationDate?: string;\n /**\n * Revocation reason if the transaction was revoked.\n */\n readonly revocationReason?: 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 subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<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 plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Only iOS, UUID for the user's account. Used to link purchases to the user account for App Store Server Notifications.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\n *\n * @param options - The product identifier you wish to retrieve information for\n * @param options.productIdentifier - The product identifier\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProduct(options: {\n productIdentifier: string;\n productType?: PURCHASE_TYPE;\n }): Promise<{ product: Product }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\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 * @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 }): Promise<{ purchases: Transaction[] }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -16,9 +16,7 @@ export declare class NativePurchasesWeb extends WebPlugin implements NativePurch
|
|
|
16
16
|
productIdentifier: string;
|
|
17
17
|
planIdentifier: string;
|
|
18
18
|
quantity: number;
|
|
19
|
-
}): Promise<
|
|
20
|
-
transactionId: string;
|
|
21
|
-
}>;
|
|
19
|
+
}): Promise<Transaction>;
|
|
22
20
|
isBillingSupported(): Promise<{
|
|
23
21
|
isBillingSupported: boolean;
|
|
24
22
|
}>;
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAEhB;QACC,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAEhB;QACC,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAS,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,OAElB;QACC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativePurchasesPlugin,\n Product,\n PURCHASE_TYPE,\n Transaction,\n} from \"./definitions\";\n\nexport class NativePurchasesWeb\n extends WebPlugin\n implements NativePurchasesPlugin\n{\n async restorePurchases(): Promise<void> {\n console.error(\"restorePurchases only mocked in web\");\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n }): Promise<{ products: Product[] }> {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n\n async getProduct(options: {\n productIdentifier: string;\n }): Promise<{ product: Product }> {\n console.error(\"getProduct only mocked in web \" + options);\n return { product: {} as any };\n }\n\n async purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier: string;\n quantity: number;\n }): Promise<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?: {\n productType?: PURCHASE_TYPE;\n }): Promise<{ purchases: Transaction[] }> {\n console.error(\"getPurchases only mocked in web \" + options);\n return { purchases: [] };\n }\n}\n"]}
|
|
@@ -82,6 +82,29 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
82
82
|
response["receipt"] = receiptBase64
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// Add detailed transaction information
|
|
86
|
+
response["productIdentifier"] = transaction.productID
|
|
87
|
+
response["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
|
|
88
|
+
response["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
|
|
89
|
+
|
|
90
|
+
// Add subscription-specific information
|
|
91
|
+
if transaction.productType == .autoRenewable {
|
|
92
|
+
response["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
|
|
93
|
+
if let expirationDate = transaction.expirationDate {
|
|
94
|
+
response["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
|
|
95
|
+
response["isActive"] = expirationDate > Date()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Add revocation information if applicable
|
|
100
|
+
if transaction.revocationDate != nil {
|
|
101
|
+
response["isRevoked"] = true
|
|
102
|
+
response["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
|
|
103
|
+
response["revocationReason"] = transaction.revocationReason?.rawValue
|
|
104
|
+
} else {
|
|
105
|
+
response["isRevoked"] = false
|
|
106
|
+
}
|
|
107
|
+
|
|
85
108
|
await transaction.finish()
|
|
86
109
|
call.resolve(response)
|
|
87
110
|
case let .success(.unverified(_, error)):
|
|
@@ -210,6 +233,29 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
210
233
|
purchaseData["receipt"] = receiptBase64
|
|
211
234
|
}
|
|
212
235
|
|
|
236
|
+
// Add detailed transaction information
|
|
237
|
+
purchaseData["productIdentifier"] = transaction.productID
|
|
238
|
+
purchaseData["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
|
|
239
|
+
purchaseData["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
|
|
240
|
+
|
|
241
|
+
// Add subscription-specific information
|
|
242
|
+
if transaction.productType == .autoRenewable {
|
|
243
|
+
purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
|
|
244
|
+
if let expirationDate = transaction.expirationDate {
|
|
245
|
+
purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
|
|
246
|
+
purchaseData["isActive"] = expirationDate > Date()
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Add revocation information if applicable
|
|
251
|
+
if transaction.revocationDate != nil {
|
|
252
|
+
purchaseData["isRevoked"] = true
|
|
253
|
+
purchaseData["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
|
|
254
|
+
purchaseData["revocationReason"] = transaction.revocationReason?.rawValue
|
|
255
|
+
} else {
|
|
256
|
+
purchaseData["isRevoked"] = false
|
|
257
|
+
}
|
|
258
|
+
|
|
213
259
|
allPurchases.append(purchaseData)
|
|
214
260
|
}
|
|
215
261
|
}
|
|
@@ -238,6 +284,29 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
238
284
|
purchaseData["receipt"] = receiptBase64
|
|
239
285
|
}
|
|
240
286
|
|
|
287
|
+
// Add detailed transaction information
|
|
288
|
+
purchaseData["productIdentifier"] = transaction.productID
|
|
289
|
+
purchaseData["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
|
|
290
|
+
purchaseData["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
|
|
291
|
+
|
|
292
|
+
// Add subscription-specific information
|
|
293
|
+
if transaction.productType == .autoRenewable {
|
|
294
|
+
purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
|
|
295
|
+
if let expirationDate = transaction.expirationDate {
|
|
296
|
+
purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
|
|
297
|
+
purchaseData["isActive"] = expirationDate > Date()
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Add revocation information if applicable
|
|
302
|
+
if transaction.revocationDate != nil {
|
|
303
|
+
purchaseData["isRevoked"] = true
|
|
304
|
+
purchaseData["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
|
|
305
|
+
purchaseData["revocationReason"] = transaction.revocationReason?.rawValue
|
|
306
|
+
} else {
|
|
307
|
+
purchaseData["isRevoked"] = false
|
|
308
|
+
}
|
|
309
|
+
|
|
241
310
|
allPurchases.append(purchaseData)
|
|
242
311
|
}
|
|
243
312
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/native-purchases",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "In-app Subscriptions Made Easy",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -25,7 +25,11 @@
|
|
|
25
25
|
"keywords": [
|
|
26
26
|
"capacitor",
|
|
27
27
|
"plugin",
|
|
28
|
-
"native"
|
|
28
|
+
"native",
|
|
29
|
+
"purchases",
|
|
30
|
+
"IAP",
|
|
31
|
+
"in-app purchases",
|
|
32
|
+
"subscriptions"
|
|
29
33
|
],
|
|
30
34
|
"scripts": {
|
|
31
35
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|