@capgo/native-purchases 8.9.7 → 8.9.9
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 +151 -40
- package/android/build.gradle +1 -0
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +114 -34
- package/android/src/main/java/ee/forgr/nativepurchases/ProductPayloadMapper.java +14 -0
- package/android/src/main/java/ee/forgr/nativepurchases/SubscriptionOfferSelector.java +136 -0
- package/dist/docs.json +32 -16
- package/dist/esm/definitions.d.ts +68 -12
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin+TransactionFinishing.swift +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin.swift +1 -1
- package/package.json +1 -1
|
@@ -87,6 +87,14 @@ final class ProductPayloadMapper {
|
|
|
87
87
|
List<ProductDetails.PricingPhase> phases =
|
|
88
88
|
offerDetails.getPricingPhases() == null ? List.of() : offerDetails.getPricingPhases().getPricingPhaseList();
|
|
89
89
|
|
|
90
|
+
ProductDetails.InstallmentPlanDetails installmentPlanDetails = offerDetails.getInstallmentPlanDetails();
|
|
91
|
+
if (installmentPlanDetails != null) {
|
|
92
|
+
int commitmentPayments = installmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount();
|
|
93
|
+
if (commitmentPayments > 0) {
|
|
94
|
+
product.put("subscriptionBillingCycles", commitmentPayments);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
ProductDetails.PricingPhase standardPhase = findStandardPricingPhase(phases);
|
|
91
99
|
if (standardPhase != null) {
|
|
92
100
|
double price = standardPhase.getPriceAmountMicros() / 1_000_000.0;
|
|
@@ -94,6 +102,12 @@ final class ProductPayloadMapper {
|
|
|
94
102
|
product.put("priceString", standardPhase.getFormattedPrice());
|
|
95
103
|
product.put("currencyCode", standardPhase.getPriceCurrencyCode());
|
|
96
104
|
product.put("currencySymbol", currencySymbol(standardPhase.getPriceCurrencyCode()));
|
|
105
|
+
int recurrenceMode = standardPhase.getRecurrenceMode();
|
|
106
|
+
if (recurrenceMode == RECURRENCE_MODE_INFINITE_RECURRING) {
|
|
107
|
+
product.put("subscriptionPeriod", subscriptionPeriodFromBillingPeriod(standardPhase.getBillingPeriod()));
|
|
108
|
+
} else if (recurrenceMode == RECURRENCE_MODE_FINITE_RECURRING && installmentPlanDetails != null) {
|
|
109
|
+
product.put("subscriptionPeriod", subscriptionPeriodFromBillingPeriod(standardPhase.getBillingPeriod()));
|
|
110
|
+
}
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
String currencyCode = standardPhase != null ? standardPhase.getPriceCurrencyCode() : product.getString("currencyCode", "");
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
package ee.forgr.nativepurchases;
|
|
2
|
+
|
|
3
|
+
import com.android.billingclient.api.ProductDetails;
|
|
4
|
+
import java.util.ArrayList;
|
|
5
|
+
import java.util.List;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Chooses which of a subscription's offers a purchase should use.
|
|
9
|
+
*
|
|
10
|
+
* Play returns one {@link ProductDetails.SubscriptionOfferDetails} per
|
|
11
|
+
* (base plan, offer) pair, and the offer token the billing flow is given is
|
|
12
|
+
* what decides the price actually charged. Selecting by base plan alone is
|
|
13
|
+
* therefore ambiguous as soon as a base plan carries an offer: the base plan
|
|
14
|
+
* and the offer are two entries with the same {@code basePlanId}, and taking
|
|
15
|
+
* the first means the caller cannot say whether the offer applies.
|
|
16
|
+
*
|
|
17
|
+
* Order of preference:
|
|
18
|
+
* <ol>
|
|
19
|
+
* <li>an explicit {@code offerToken}, matched exactly: the caller named a
|
|
20
|
+
* specific offer, which is the most specific thing they can say;</li>
|
|
21
|
+
* <li>the first offer whose base plan matches {@code planIdentifier};</li>
|
|
22
|
+
* <li>the first offer the store returned.</li>
|
|
23
|
+
* </ol>
|
|
24
|
+
*
|
|
25
|
+
* An {@code offerToken} that matches nothing is reported rather than
|
|
26
|
+
* silently falling through to (2) or (3): it means the caller asked for an
|
|
27
|
+
* offer that is not on offer, usually a token cached past its query, and
|
|
28
|
+
* charging a different price than the one they named is the worse outcome.
|
|
29
|
+
* This mirrors how the one-time purchase path already treats an unknown
|
|
30
|
+
* token.
|
|
31
|
+
*
|
|
32
|
+
* An index is returned rather than an offer, so the caller indexes back into
|
|
33
|
+
* Play's own list. The {@link Offer} seam exists only so the choice can be
|
|
34
|
+
* unit-tested without constructing Billing objects, the same way
|
|
35
|
+
* {@link PurchaseActionDecider} can be; handing the wrapper back would make
|
|
36
|
+
* the caller unwrap to reach something it already holds.
|
|
37
|
+
*/
|
|
38
|
+
public final class SubscriptionOfferSelector {
|
|
39
|
+
|
|
40
|
+
/** No offer to use; see {@link #selectIndex}. */
|
|
41
|
+
static final int NOT_FOUND = -1;
|
|
42
|
+
|
|
43
|
+
private SubscriptionOfferSelector() {}
|
|
44
|
+
|
|
45
|
+
/** The fields of an offer this choice depends on. */
|
|
46
|
+
interface Offer {
|
|
47
|
+
String getBasePlanId();
|
|
48
|
+
|
|
49
|
+
String getOfferToken();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The index of the offer to purchase, or {@link #NOT_FOUND}.
|
|
54
|
+
*
|
|
55
|
+
* {@code NOT_FOUND} means either that there was nothing to choose from,
|
|
56
|
+
* or that an explicit {@code offerToken} matched none of the offers. The
|
|
57
|
+
* caller tells those apart by checking the list before calling, because
|
|
58
|
+
* it is the one that can name the product that had no offers.
|
|
59
|
+
*/
|
|
60
|
+
static int selectIndex(List<Offer> offers, String planIdentifier, String offerToken) {
|
|
61
|
+
if (offers == null || offers.isEmpty()) {
|
|
62
|
+
return NOT_FOUND;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (isPresent(offerToken)) {
|
|
66
|
+
for (int i = 0; i < offers.size(); i++) {
|
|
67
|
+
if (offerToken.equals(offers.get(i).getOfferToken())) {
|
|
68
|
+
return i;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return NOT_FOUND;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isPresent(planIdentifier)) {
|
|
75
|
+
for (int i = 0; i < offers.size(); i++) {
|
|
76
|
+
if (planIdentifier.equals(offers.get(i).getBasePlanId())) {
|
|
77
|
+
return i;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Whether a subscription purchase named an offer at all.
|
|
87
|
+
*
|
|
88
|
+
* Either value is enough on its own: an {@code offerToken} names one
|
|
89
|
+
* specific offer, and a {@code planIdentifier} names the base plan whose
|
|
90
|
+
* first offer {@link #selectIndex} then takes. Only when both are absent
|
|
91
|
+
* has the caller said nothing to go on, and such a purchase is rejected
|
|
92
|
+
* rather than charged whichever offer the store happened to return first.
|
|
93
|
+
*
|
|
94
|
+
* Saying something is not the same as saying something that matches: a
|
|
95
|
+
* {@code planIdentifier} matching no base plan still falls back to the
|
|
96
|
+
* first offer, as it did before this was checked.
|
|
97
|
+
*/
|
|
98
|
+
static boolean canSelect(String planIdentifier, String offerToken) {
|
|
99
|
+
return isPresent(offerToken) || isPresent(planIdentifier);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private static boolean isPresent(String value) {
|
|
103
|
+
return value != null && !value.isEmpty();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Adapt Play's own offer details to {@link Offer}. */
|
|
107
|
+
static List<Offer> adapt(List<ProductDetails.SubscriptionOfferDetails> offerDetailsList) {
|
|
108
|
+
if (offerDetailsList == null) {
|
|
109
|
+
return new ArrayList<>();
|
|
110
|
+
}
|
|
111
|
+
List<Offer> offers = new ArrayList<>(offerDetailsList.size());
|
|
112
|
+
for (ProductDetails.SubscriptionOfferDetails offerDetails : offerDetailsList) {
|
|
113
|
+
offers.add(new SubscriptionOfferDetailsAdapter(offerDetails));
|
|
114
|
+
}
|
|
115
|
+
return offers;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private static final class SubscriptionOfferDetailsAdapter implements Offer {
|
|
119
|
+
|
|
120
|
+
private final ProductDetails.SubscriptionOfferDetails details;
|
|
121
|
+
|
|
122
|
+
SubscriptionOfferDetailsAdapter(ProductDetails.SubscriptionOfferDetails details) {
|
|
123
|
+
this.details = details;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Override
|
|
127
|
+
public String getBasePlanId() {
|
|
128
|
+
return details.getBasePlanId();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@Override
|
|
132
|
+
public String getOfferToken() {
|
|
133
|
+
return details.getOfferToken();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -148,11 +148,11 @@
|
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
"name": "param",
|
|
151
|
-
"text": "options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console.
|
|
151
|
+
"text": "options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console, the value `getProducts()` reports as `Product.identifier` for a subscription, not `Product.planIdentifier`. Required for Android subscriptions unless `offerToken` is given; ignored for one-time products and on iOS."
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
"name": "param",
|
|
155
|
-
"text": "options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`."
|
|
155
|
+
"text": "options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`. For a subscription it takes precedence over `planIdentifier`, since it names one specific offer, and makes `planIdentifier` optional. When the token is absent from the plugin query result the purchase is rejected instead of falling back to another offer. Google Play may still change what the user can buy after the query. Offer tokens come from a specific product query and go stale, so read one from the same query you purchase from. Omit it to keep the previous behaviour."
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"name": "param",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"text": "options.autoAcknowledgePurchases - When false, this purchase is not auto-finished/acknowledged when\n `autoFinishTransactions` is also true. Does not disable auto-finishing on\n the iOS `transactionUpdated` listener; use `configure({ autoFinishTransactions: false })`\n for manual finishing across purchase and recovery flows. 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"
|
|
176
176
|
}
|
|
177
177
|
],
|
|
178
|
-
"docs": "Started purchase process for the given product.",
|
|
178
|
+
"docs": "Started purchase process for the given product.\n\nOn Android, `offerToken` selects which offer is charged. If the token is\nmissing from the product details returned by the plugin's query, the plugin\nrejects the purchase instead of selecting another offer. Other failures can\nalso reject the purchase. Google Play may still show a different checkout,\nfor example if the offer stops being eligible after the query, so the final\nprice is not guaranteed.\nOffer tokens come from a specific product query and go stale, so read\none from the same `getProducts()` / `getProduct()` call you purchase\nfrom.\n\nFor a **subscription** (`productType: 'subs'`) the order is: an explicit\n`offerToken`, then the first offer whose base plan matches\n`planIdentifier`, then the first offer the store returned.\n`planIdentifier` is the **base plan id**, which `getProducts()` reports\nas `Product.identifier`, not `Product.planIdentifier`, which holds the\nPlay product id. It is required unless an `offerToken` is given, since\na token already identifies one offer on its own.\n\nFor a **one-time product** (`productType: 'inapp'`) there is no base\nplan, so `planIdentifier` plays no part, and an `offerToken` selects one\nof the product's purchase offers. Without a token no offer token is set\nat all whenever the product still has a backward-compatible purchase\noption, which leaves the choice to Play: it charges whichever buy\npurchase option is marked backward-compatible, which is the first\n*created* one by default and another only if one was marked\n`legacyCompatible`. Either way it need not be the first offer\n`getProducts()` returned. Only for a product with no backward-compatible\noption does the first offer in the list get used. So pass the token\nwhenever a specific one-time offer matters.",
|
|
179
179
|
"complexTypes": [
|
|
180
180
|
"Transaction",
|
|
181
181
|
"PURCHASE_TYPE"
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
},
|
|
457
457
|
{
|
|
458
458
|
"name": "param",
|
|
459
|
-
"text": "options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`."
|
|
459
|
+
"text": "options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`. Since 8.9.7."
|
|
460
460
|
},
|
|
461
461
|
{
|
|
462
462
|
"name": "since",
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
"tags": [
|
|
490
490
|
{
|
|
491
491
|
"name": "param",
|
|
492
|
-
"text": "options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`."
|
|
492
|
+
"text": "options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`. Since 8.9.7."
|
|
493
493
|
},
|
|
494
494
|
{
|
|
495
495
|
"name": "since",
|
|
@@ -805,7 +805,7 @@
|
|
|
805
805
|
"name": "platform"
|
|
806
806
|
},
|
|
807
807
|
{
|
|
808
|
-
"text": "android
|
|
808
|
+
"text": "android The Google Play purchase token (same value as `purchaseToken`), not the `GPA.` order ID in `orderId`",
|
|
809
809
|
"name": "platform"
|
|
810
810
|
}
|
|
811
811
|
],
|
|
@@ -1438,7 +1438,7 @@
|
|
|
1438
1438
|
"name": "verificationError",
|
|
1439
1439
|
"tags": [
|
|
1440
1440
|
{
|
|
1441
|
-
"text": "8.
|
|
1441
|
+
"text": "8.9.7",
|
|
1442
1442
|
"name": "since"
|
|
1443
1443
|
},
|
|
1444
1444
|
{
|
|
@@ -1639,7 +1639,7 @@
|
|
|
1639
1639
|
{
|
|
1640
1640
|
"name": "priceString",
|
|
1641
1641
|
"tags": [],
|
|
1642
|
-
"docs": "Formatted price of the item, including its currency sign, such as €3.99.",
|
|
1642
|
+
"docs": "Formatted price of the item, including its currency sign, such as €3.99.\n\nAndroid subscriptions: set from the standard recurring pricing phase (see\n`ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice`\ndescribes that phase, so a pre purchase message should include both or defer confirmation\nto the store sheet.",
|
|
1643
1643
|
"complexTypes": [],
|
|
1644
1644
|
"type": "string"
|
|
1645
1645
|
},
|
|
@@ -1681,7 +1681,7 @@
|
|
|
1681
1681
|
{
|
|
1682
1682
|
"name": "offerToken",
|
|
1683
1683
|
"tags": [],
|
|
1684
|
-
"docs": "Android: offer token required when purchasing a specific subscription or one-time offer.",
|
|
1684
|
+
"docs": "Android: offer token required when purchasing a specific subscription or one-time offer.\n\nPass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the\nquery that returned it and goes stale, so read it from the same `getProducts()` /\n`getProduct()` call you purchase from.",
|
|
1685
1685
|
"complexTypes": [],
|
|
1686
1686
|
"type": "string | undefined"
|
|
1687
1687
|
},
|
|
@@ -1766,26 +1766,42 @@
|
|
|
1766
1766
|
},
|
|
1767
1767
|
{
|
|
1768
1768
|
"name": "subscriptionPeriod",
|
|
1769
|
-
"tags": [
|
|
1770
|
-
|
|
1769
|
+
"tags": [
|
|
1770
|
+
{
|
|
1771
|
+
"text": "ios From StoreKit `subscription.subscriptionPeriod`.",
|
|
1772
|
+
"name": "platform"
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
"text": "android From the standard pricing phase billing period when recurrence is\ninfinite recurring, or finite recurring on installment offers (`ProductPayloadMapper.applySubscriptionPricing`).\nOmitted for prepaid (non-recurring) phases.",
|
|
1776
|
+
"name": "platform"
|
|
1777
|
+
}
|
|
1778
|
+
],
|
|
1779
|
+
"docs": "Recurring billing period for subscription products.",
|
|
1771
1780
|
"complexTypes": [
|
|
1772
1781
|
"SubscriptionPeriod"
|
|
1773
1782
|
],
|
|
1774
1783
|
"type": "SubscriptionPeriod"
|
|
1775
1784
|
},
|
|
1776
1785
|
{
|
|
1777
|
-
"name": "
|
|
1786
|
+
"name": "subscriptionBillingCycles",
|
|
1778
1787
|
"tags": [
|
|
1779
1788
|
{
|
|
1780
|
-
"text": "
|
|
1789
|
+
"text": "android From `InstallmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount()`.",
|
|
1781
1790
|
"name": "platform"
|
|
1782
1791
|
},
|
|
1783
1792
|
{
|
|
1784
|
-
"text": "
|
|
1793
|
+
"text": "ios Not available",
|
|
1785
1794
|
"name": "platform"
|
|
1786
1795
|
}
|
|
1787
1796
|
],
|
|
1788
|
-
"docs": "
|
|
1797
|
+
"docs": "Android subscriptions only: committed payment count for installment base plans when Play\nexposes it on the offer.",
|
|
1798
|
+
"complexTypes": [],
|
|
1799
|
+
"type": "number | undefined"
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
"name": "introductoryPrice",
|
|
1803
|
+
"tags": [],
|
|
1804
|
+
"docs": "Introductory price for this product line when the store exposes it. Pair with `priceString`\nfor full subscription offer wording before purchase. iOS: from StoreKit introductory offers\nwhen available. Android base subscription offers (`offerId` null): from the first pricing\nphase when multiple phases exist (intro then recurring). Android promotional offer lines\n(`offerId` set): null; phase pricing is not exposed on `Product`, so defer price confirmation\nto Play checkout instead of using `priceString` alone. Mapping matches `ProductPayloadMapper`.",
|
|
1789
1805
|
"complexTypes": [
|
|
1790
1806
|
"SKProductDiscount"
|
|
1791
1807
|
],
|
|
@@ -1821,7 +1837,7 @@
|
|
|
1821
1837
|
"name": "platform"
|
|
1822
1838
|
},
|
|
1823
1839
|
{
|
|
1824
|
-
"text": "android
|
|
1840
|
+
"text": "android On base subscription offers (`offerId` null), lists promotional offers on\nthe same base plan. A promotional offer line itself returns an empty array; its pricing\nphases are not mapped here or on `introductoryPrice`.",
|
|
1825
1841
|
"name": "platform"
|
|
1826
1842
|
}
|
|
1827
1843
|
],
|
|
@@ -126,7 +126,7 @@ export interface Transaction {
|
|
|
126
126
|
*
|
|
127
127
|
* @since 1.0.0
|
|
128
128
|
* @platform ios Numeric string (e.g., "2000001043762129")
|
|
129
|
-
* @platform android
|
|
129
|
+
* @platform android The Google Play purchase token (same value as `purchaseToken`), not the `GPA.` order ID in `orderId`
|
|
130
130
|
*/
|
|
131
131
|
readonly transactionId: string;
|
|
132
132
|
/**
|
|
@@ -568,7 +568,7 @@ export interface Transaction {
|
|
|
568
568
|
*
|
|
569
569
|
* Present only on unverified entries returned by `getUnfinishedTransactions({ includeUnverified: true })`.
|
|
570
570
|
*
|
|
571
|
-
* @since 8.
|
|
571
|
+
* @since 8.9.7
|
|
572
572
|
* @platform ios Present when StoreKit reports the transaction as unverified
|
|
573
573
|
* @platform android Not available (Play Billing has no client-side unverified state)
|
|
574
574
|
*/
|
|
@@ -904,6 +904,11 @@ export interface Product {
|
|
|
904
904
|
readonly price: number;
|
|
905
905
|
/**
|
|
906
906
|
* Formatted price of the item, including its currency sign, such as €3.99.
|
|
907
|
+
*
|
|
908
|
+
* Android subscriptions: set from the standard recurring pricing phase (see
|
|
909
|
+
* `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice`
|
|
910
|
+
* describes that phase, so a pre purchase message should include both or defer confirmation
|
|
911
|
+
* to the store sheet.
|
|
907
912
|
*/
|
|
908
913
|
readonly priceString: string;
|
|
909
914
|
/**
|
|
@@ -928,6 +933,10 @@ export interface Product {
|
|
|
928
933
|
readonly planIdentifier?: string;
|
|
929
934
|
/**
|
|
930
935
|
* Android: offer token required when purchasing a specific subscription or one-time offer.
|
|
936
|
+
*
|
|
937
|
+
* Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the
|
|
938
|
+
* query that returned it and goes stale, so read it from the same `getProducts()` /
|
|
939
|
+
* `getProduct()` call you purchase from.
|
|
931
940
|
*/
|
|
932
941
|
readonly offerToken?: string;
|
|
933
942
|
/**
|
|
@@ -969,14 +978,29 @@ export interface Product {
|
|
|
969
978
|
*/
|
|
970
979
|
readonly pricingTerms?: SubscriptionPricingTerms[];
|
|
971
980
|
/**
|
|
972
|
-
*
|
|
981
|
+
* Recurring billing period for subscription products.
|
|
982
|
+
*
|
|
983
|
+
* @platform ios From StoreKit `subscription.subscriptionPeriod`.
|
|
984
|
+
* @platform android From the standard pricing phase billing period when recurrence is
|
|
985
|
+
* infinite recurring, or finite recurring on installment offers (`ProductPayloadMapper.applySubscriptionPricing`).
|
|
986
|
+
* Omitted for prepaid (non-recurring) phases.
|
|
973
987
|
*/
|
|
974
|
-
readonly subscriptionPeriod
|
|
988
|
+
readonly subscriptionPeriod?: SubscriptionPeriod;
|
|
975
989
|
/**
|
|
976
|
-
*
|
|
990
|
+
* Android subscriptions only: committed payment count for installment base plans when Play
|
|
991
|
+
* exposes it on the offer.
|
|
977
992
|
*
|
|
978
|
-
* @platform
|
|
979
|
-
* @platform
|
|
993
|
+
* @platform android From `InstallmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount()`.
|
|
994
|
+
* @platform ios Not available
|
|
995
|
+
*/
|
|
996
|
+
readonly subscriptionBillingCycles?: number;
|
|
997
|
+
/**
|
|
998
|
+
* Introductory price for this product line when the store exposes it. Pair with `priceString`
|
|
999
|
+
* for full subscription offer wording before purchase. iOS: from StoreKit introductory offers
|
|
1000
|
+
* when available. Android base subscription offers (`offerId` null): from the first pricing
|
|
1001
|
+
* phase when multiple phases exist (intro then recurring). Android promotional offer lines
|
|
1002
|
+
* (`offerId` set): null; phase pricing is not exposed on `Product`, so defer price confirmation
|
|
1003
|
+
* to Play checkout instead of using `priceString` alone. Mapping matches `ProductPayloadMapper`.
|
|
980
1004
|
*/
|
|
981
1005
|
readonly introductoryPrice: SKProductDiscount | null;
|
|
982
1006
|
/**
|
|
@@ -991,7 +1015,9 @@ export interface Product {
|
|
|
991
1015
|
* The Product discounts list.
|
|
992
1016
|
*
|
|
993
1017
|
* @platform ios Populated from StoreKit promotional offers when available.
|
|
994
|
-
* @platform android
|
|
1018
|
+
* @platform android On base subscription offers (`offerId` null), lists promotional offers on
|
|
1019
|
+
* the same base plan. A promotional offer line itself returns an empty array; its pricing
|
|
1020
|
+
* phases are not mapped here or on `introductoryPrice`.
|
|
995
1021
|
*/
|
|
996
1022
|
readonly discounts: SKProductDiscount[];
|
|
997
1023
|
}
|
|
@@ -1126,11 +1152,41 @@ export interface NativePurchasesPlugin {
|
|
|
1126
1152
|
/**
|
|
1127
1153
|
* Started purchase process for the given product.
|
|
1128
1154
|
*
|
|
1155
|
+
* On Android, `offerToken` selects which offer is charged. If the token is
|
|
1156
|
+
* missing from the product details returned by the plugin's query, the plugin
|
|
1157
|
+
* rejects the purchase instead of selecting another offer. Other failures can
|
|
1158
|
+
* also reject the purchase. Google Play may still show a different checkout,
|
|
1159
|
+
* for example if the offer stops being eligible after the query, so the final
|
|
1160
|
+
* price is not guaranteed.
|
|
1161
|
+
* Offer tokens come from a specific product query and go stale, so read
|
|
1162
|
+
* one from the same `getProducts()` / `getProduct()` call you purchase
|
|
1163
|
+
* from.
|
|
1164
|
+
*
|
|
1165
|
+
* For a **subscription** (`productType: 'subs'`) the order is: an explicit
|
|
1166
|
+
* `offerToken`, then the first offer whose base plan matches
|
|
1167
|
+
* `planIdentifier`, then the first offer the store returned.
|
|
1168
|
+
* `planIdentifier` is the **base plan id**, which `getProducts()` reports
|
|
1169
|
+
* as `Product.identifier`, not `Product.planIdentifier`, which holds the
|
|
1170
|
+
* Play product id. It is required unless an `offerToken` is given, since
|
|
1171
|
+
* a token already identifies one offer on its own.
|
|
1172
|
+
*
|
|
1173
|
+
* For a **one-time product** (`productType: 'inapp'`) there is no base
|
|
1174
|
+
* plan, so `planIdentifier` plays no part, and an `offerToken` selects one
|
|
1175
|
+
* of the product's purchase offers. Without a token no offer token is set
|
|
1176
|
+
* at all whenever the product still has a backward-compatible purchase
|
|
1177
|
+
* option, which leaves the choice to Play: it charges whichever buy
|
|
1178
|
+
* purchase option is marked backward-compatible, which is the first
|
|
1179
|
+
* *created* one by default and another only if one was marked
|
|
1180
|
+
* `legacyCompatible`. Either way it need not be the first offer
|
|
1181
|
+
* `getProducts()` returned. Only for a product with no backward-compatible
|
|
1182
|
+
* option does the first offer in the list get used. So pass the token
|
|
1183
|
+
* whenever a specific one-time offer matters.
|
|
1184
|
+
*
|
|
1129
1185
|
* @param options - The product to purchase
|
|
1130
1186
|
* @param options.productIdentifier - The product identifier of the product you want to purchase.
|
|
1131
1187
|
* @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
|
|
1132
|
-
* @param options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console.
|
|
1133
|
-
* @param options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`.
|
|
1188
|
+
* @param options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console, the value `getProducts()` reports as `Product.identifier` for a subscription, not `Product.planIdentifier`. Required for Android subscriptions unless `offerToken` is given; ignored for one-time products and on iOS.
|
|
1189
|
+
* @param options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`. For a subscription it takes precedence over `planIdentifier`, since it names one specific offer, and makes `planIdentifier` optional. When the token is absent from the plugin query result the purchase is rejected instead of falling back to another offer. Google Play may still change what the user can buy after the query. Offer tokens come from a specific product query and go stale, so read one from the same query you purchase from. Omit it to keep the previous behaviour.
|
|
1134
1190
|
* @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.
|
|
1135
1191
|
* @param options.billingPlanType - Only iOS, the StoreKit subscription billing plan to purchase. Use `"monthly"` for a monthly subscription with a 12-month commitment. Requires iOS 26.4+ and Xcode 26.5 SDK support.
|
|
1136
1192
|
* @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.
|
|
@@ -1352,7 +1408,7 @@ export interface NativePurchasesPlugin {
|
|
|
1352
1408
|
* `allowUnverified` has no effect because Play Billing has no client-side unverified state.
|
|
1353
1409
|
*
|
|
1354
1410
|
* @param options.transactionId Transaction ID from the `Transaction` object (numeric string on iOS, purchase token on Android).
|
|
1355
|
-
* @param options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`.
|
|
1411
|
+
* @param options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`. Since 8.9.7.
|
|
1356
1412
|
* @since 8.9.0
|
|
1357
1413
|
* @platform ios Finishes the transaction with StoreKit 2
|
|
1358
1414
|
* @platform android Acknowledges the purchase with Google Play
|
|
@@ -1376,7 +1432,7 @@ export interface NativePurchasesPlugin {
|
|
|
1376
1432
|
* to `finishTransaction({ transactionId, allowUnverified: true })` to clear them. Android has no
|
|
1377
1433
|
* client-side unverified state, so the option does not change its results.
|
|
1378
1434
|
*
|
|
1379
|
-
* @param options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`.
|
|
1435
|
+
* @param options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`. Since 8.9.7.
|
|
1380
1436
|
* @since 8.9.0
|
|
1381
1437
|
*/
|
|
1382
1438
|
getUnfinishedTransactions(options?: {
|