@capgo/native-purchases 0.0.25 → 0.0.26
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.
|
@@ -265,6 +265,7 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
265
265
|
@PluginMethod
|
|
266
266
|
public void getProducts(PluginCall call) {
|
|
267
267
|
JSONArray productIdentifiersArray = call.getArray("productIdentifiers");
|
|
268
|
+
String planIdentifier = call.getString("planIdentifier");
|
|
268
269
|
if (productIdentifiersArray == null) {
|
|
269
270
|
call.reject("productIdentifiers is missing");
|
|
270
271
|
return;
|
|
@@ -286,7 +287,9 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
286
287
|
productList.add(
|
|
287
288
|
QueryProductDetailsParams.Product
|
|
288
289
|
.newBuilder()
|
|
289
|
-
.setProductId(
|
|
290
|
+
.setProductId(
|
|
291
|
+
productType.equals("inapp") ? productIdentifier : planIdentifier
|
|
292
|
+
)
|
|
290
293
|
.setProductType(
|
|
291
294
|
productType.equals("inapp")
|
|
292
295
|
? BillingClient.ProductType.INAPP
|
|
@@ -320,30 +323,80 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
320
323
|
// Process the result
|
|
321
324
|
JSObject ret = new JSObject();
|
|
322
325
|
JSONArray products = new JSONArray();
|
|
326
|
+
Number productIdIndex = 0;
|
|
323
327
|
for (ProductDetails productDetails : productDetailsList) {
|
|
324
328
|
JSObject product = new JSObject();
|
|
325
329
|
product.put("identifier", productDetails.getProductId());
|
|
326
330
|
product.put("title", productDetails.getTitle());
|
|
327
331
|
product.put("description", productDetails.getDescription());
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
332
|
+
if (productType.equals("inapp")) {
|
|
333
|
+
product.put(
|
|
334
|
+
"price",
|
|
335
|
+
productDetails
|
|
336
|
+
.getOneTimePurchaseOfferDetails()
|
|
337
|
+
.getPriceAmountMicros() /
|
|
338
|
+
1000000.0
|
|
339
|
+
);
|
|
340
|
+
product.put(
|
|
341
|
+
"priceString",
|
|
342
|
+
productDetails
|
|
343
|
+
.getOneTimePurchaseOfferDetails()
|
|
344
|
+
.getFormattedPrice()
|
|
345
|
+
);
|
|
346
|
+
product.put(
|
|
347
|
+
"currencyCode",
|
|
348
|
+
productDetails
|
|
349
|
+
.getOneTimePurchaseOfferDetails()
|
|
350
|
+
.getPriceCurrencyCode()
|
|
351
|
+
);
|
|
352
|
+
} else {
|
|
353
|
+
// productIdIndex is used to get the correct SubscriptionOfferDetails by productIdentifiersArray index and increment it
|
|
354
|
+
String subscriptionOfferIdentifier = productIdentifiers.get(
|
|
355
|
+
productIdIndex.intValue()
|
|
356
|
+
);
|
|
357
|
+
productIdIndex = productIdIndex.intValue() + 1;
|
|
358
|
+
// get the SubscriptionOfferDetails who match the subscriptionOfferIdentifier
|
|
359
|
+
ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
|
|
360
|
+
null;
|
|
361
|
+
for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetails.getSubscriptionOfferDetails()) {
|
|
362
|
+
if (
|
|
363
|
+
offerDetails.getOfferId().equals(subscriptionOfferIdentifier)
|
|
364
|
+
) {
|
|
365
|
+
selectedOfferDetails = offerDetails;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (selectedOfferDetails == null) {
|
|
370
|
+
selectedOfferDetails =
|
|
371
|
+
productDetails.getSubscriptionOfferDetails().get(0);
|
|
372
|
+
}
|
|
373
|
+
product.put(
|
|
374
|
+
"price",
|
|
375
|
+
selectedOfferDetails
|
|
376
|
+
.getPricingPhases()
|
|
377
|
+
.getPricingPhaseList()
|
|
378
|
+
.get(0)
|
|
379
|
+
.getPriceAmountMicros() /
|
|
380
|
+
1000000.0
|
|
381
|
+
);
|
|
382
|
+
product.put(
|
|
383
|
+
"priceString",
|
|
384
|
+
selectedOfferDetails
|
|
385
|
+
.getPricingPhases()
|
|
386
|
+
.getPricingPhaseList()
|
|
387
|
+
.get(0)
|
|
388
|
+
.getFormattedPrice()
|
|
389
|
+
);
|
|
390
|
+
product.put(
|
|
391
|
+
"currencyCode",
|
|
392
|
+
selectedOfferDetails
|
|
393
|
+
.getPricingPhases()
|
|
394
|
+
.getPricingPhaseList()
|
|
395
|
+
.get(0)
|
|
396
|
+
.getPriceCurrencyCode()
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
347
400
|
product.put("isFamilyShareable", false);
|
|
348
401
|
products.put(product);
|
|
349
402
|
}
|