@capgo/native-purchases 8.3.8 → 8.3.10
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/CapgoNativePurchases.podspec +31 -0
- package/Package.swift +40 -1
- package/README.md +138 -25
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +1 -1
- package/dist/docs.json +443 -3
- package/dist/esm/definitions.d.ts +206 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +14 -5
- package/dist/esm/web.js +6 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin+PurchaseHandling.swift +37 -0
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin.swift +40 -34
- package/ios/Sources/NativePurchasesPlugin/Product+CapacitorPurchasesPlugin.swift +23 -1
- package/ios/Sources/NativePurchasesPlugin/StoreKitPayloadExtensions.swift +122 -0
- package/ios/Sources/NativePurchasesPlugin/StoreKitPayloadHelpers.swift +374 -0
- package/ios/Sources/NativePurchasesPlugin/TransactionHelpers.swift +50 -0
- package/package.json +1 -1
|
@@ -2,6 +2,34 @@ require 'json'
|
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
|
+
def has_storekit_265_sdk?
|
|
6
|
+
developer_dirs = [
|
|
7
|
+
ENV['DEVELOPER_DIR'],
|
|
8
|
+
'/Applications/Xcode.app/Contents/Developer'
|
|
9
|
+
].compact
|
|
10
|
+
sdk_roots = [ENV['SDKROOT']].compact
|
|
11
|
+
|
|
12
|
+
developer_dirs.each do |developer_dir|
|
|
13
|
+
sdk_roots.concat([
|
|
14
|
+
File.join(developer_dir, 'Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk'),
|
|
15
|
+
File.join(developer_dir, 'Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk')
|
|
16
|
+
])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
sdk_roots.any? do |sdk_root|
|
|
20
|
+
module_path = File.join(
|
|
21
|
+
sdk_root,
|
|
22
|
+
'System/Library/Frameworks/StoreKit.framework/Modules/StoreKit.swiftmodule'
|
|
23
|
+
)
|
|
24
|
+
Dir[File.join(module_path, '*.swiftinterface')].any? do |path|
|
|
25
|
+
contents = File.read(path)
|
|
26
|
+
contents.include?('BillingPlanType') && contents.include?('pricingTerms')
|
|
27
|
+
rescue StandardError
|
|
28
|
+
false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
5
33
|
Pod::Spec.new do |s|
|
|
6
34
|
s.name = 'CapgoNativePurchases'
|
|
7
35
|
s.version = package['version']
|
|
@@ -15,4 +43,7 @@ Pod::Spec.new do |s|
|
|
|
15
43
|
s.ios.deployment_target = '15.0'
|
|
16
44
|
s.dependency 'Capacitor'
|
|
17
45
|
s.swift_version = '5.1'
|
|
46
|
+
s.pod_target_xcconfig = {
|
|
47
|
+
'OTHER_SWIFT_FLAGS' => has_storekit_265_sdk? ? '$(inherited) -D STOREKIT_26_5' : '$(inherited)'
|
|
48
|
+
}
|
|
18
49
|
end
|
package/Package.swift
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
// swift-tools-version: 5.9
|
|
2
|
+
import Foundation
|
|
2
3
|
import PackageDescription
|
|
3
4
|
|
|
5
|
+
func hasStoreKit265SDK() -> Bool {
|
|
6
|
+
let environment = ProcessInfo.processInfo.environment
|
|
7
|
+
let developerDirs = [
|
|
8
|
+
environment["DEVELOPER_DIR"],
|
|
9
|
+
"/Applications/Xcode.app/Contents/Developer"
|
|
10
|
+
].compactMap { $0 }
|
|
11
|
+
var sdkRoots = [environment["SDKROOT"]].compactMap { $0 }
|
|
12
|
+
|
|
13
|
+
for developerDir in developerDirs {
|
|
14
|
+
sdkRoots.append(contentsOf: [
|
|
15
|
+
"\(developerDir)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk",
|
|
16
|
+
"\(developerDir)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
|
|
17
|
+
])
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for sdkRoot in sdkRoots {
|
|
21
|
+
let modulePath = "\(sdkRoot)/System/Library/Frameworks/StoreKit.framework/Modules/StoreKit.swiftmodule"
|
|
22
|
+
guard let interfaceFiles = try? FileManager.default.contentsOfDirectory(atPath: modulePath) else {
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for fileName in interfaceFiles where fileName.hasSuffix(".swiftinterface") {
|
|
27
|
+
let fileURL = URL(fileURLWithPath: modulePath).appendingPathComponent(fileName)
|
|
28
|
+
guard let contents = try? String(contentsOf: fileURL) else {
|
|
29
|
+
continue
|
|
30
|
+
}
|
|
31
|
+
if contents.contains("BillingPlanType") && contents.contains("pricingTerms") {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let storeKitSwiftSettings: [SwiftSetting] = hasStoreKit265SDK() ? [.define("STOREKIT_26_5")] : []
|
|
41
|
+
|
|
4
42
|
let package = Package(
|
|
5
43
|
name: "CapgoNativePurchases",
|
|
6
44
|
platforms: [.iOS(.v15)],
|
|
@@ -19,7 +57,8 @@ let package = Package(
|
|
|
19
57
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
58
|
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
59
|
],
|
|
22
|
-
path: "ios/Sources/NativePurchasesPlugin"
|
|
60
|
+
path: "ios/Sources/NativePurchasesPlugin",
|
|
61
|
+
swiftSettings: storeKitSwiftSettings),
|
|
23
62
|
.testTarget(
|
|
24
63
|
name: "NativePurchasesPluginTests",
|
|
25
64
|
dependencies: ["NativePurchasesPlugin"],
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ This plugin allows you to implement in-app purchases and subscriptions in your C
|
|
|
15
15
|
The only **free**, **battle-tested** in-app purchase plugin for Capacitor with full feature parity:
|
|
16
16
|
|
|
17
17
|
- **StoreKit 2 (iOS)** - Uses Apple's latest purchase APIs for iOS 15+
|
|
18
|
+
- **iOS subscription commitment plans** - Merchandises and purchases monthly subscriptions with 12-month commitments when StoreKit supports them
|
|
18
19
|
- **Google Play Billing 7.x (Android)** - Implements the newest billing library
|
|
19
20
|
- **Complete feature set** - In-app products AND subscriptions with base plans
|
|
20
21
|
- **Same JavaScript API** - Compatible interface with paid alternatives
|
|
@@ -93,6 +94,35 @@ Add the "In-App Purchase" capability to your Xcode project:
|
|
|
93
94
|
|
|
94
95
|
> 📖 **[Complete iOS Testing Guide](./docs/iOS_TESTING_GUIDE.md)** - Comprehensive guide covering both Sandbox and StoreKit local testing methods with step-by-step instructions, troubleshooting, and best practices.
|
|
95
96
|
|
|
97
|
+
### StoreKit Monthly Commitment Subscriptions
|
|
98
|
+
|
|
99
|
+
On supported iOS versions, the plugin exposes Apple's monthly subscription with 12-month commitment billing plan configuration from StoreKit:
|
|
100
|
+
|
|
101
|
+
- Show `product.pricingTerms` so users can compare the standard up-front plan and the monthly commitment plan before purchasing.
|
|
102
|
+
- Pass `billingPlanType: 'monthly'` to `purchaseProduct()` when the user chooses the monthly commitment plan.
|
|
103
|
+
- Read `transaction.billingPlanType`, `transaction.commitmentInfo`, and `transaction.renewalInfo.commitmentInfo` from purchases, restored purchases, and entitlement checks.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const { products } = await NativePurchases.getProducts({
|
|
107
|
+
productIdentifiers: ['com.yourapp.premium.yearly'],
|
|
108
|
+
productType: PURCHASE_TYPE.SUBS,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const premiumYearly = products[0];
|
|
112
|
+
const monthlyCommitment = premiumYearly.pricingTerms?.find(
|
|
113
|
+
(term) => term.billingPlanType === 'monthly'
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (monthlyCommitment) {
|
|
117
|
+
// Display both billingDisplayPrice and commitmentInfo.priceString before purchase.
|
|
118
|
+
await NativePurchases.purchaseProduct({
|
|
119
|
+
productIdentifier: premiumYearly.identifier,
|
|
120
|
+
productType: PURCHASE_TYPE.SUBS,
|
|
121
|
+
billingPlanType: 'monthly',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
96
126
|
### Testing with Sandbox
|
|
97
127
|
|
|
98
128
|
For testing in-app purchases on iOS:
|
|
@@ -1678,6 +1708,7 @@ This approach balances immediate user gratification with proper server-side vali
|
|
|
1678
1708
|
* [`addListener('transactionVerificationFailed', ...)`](#addlistenertransactionverificationfailed-)
|
|
1679
1709
|
* [`removeAllListeners()`](#removealllisteners)
|
|
1680
1710
|
* [Interfaces](#interfaces)
|
|
1711
|
+
* [Type Aliases](#type-aliases)
|
|
1681
1712
|
* [Enums](#enums)
|
|
1682
1713
|
|
|
1683
1714
|
</docgen-index>
|
|
@@ -1758,14 +1789,14 @@ to determine if they should be grandfathered into free features.
|
|
|
1758
1789
|
### purchaseProduct(...)
|
|
1759
1790
|
|
|
1760
1791
|
```typescript
|
|
1761
|
-
purchaseProduct(options: { productIdentifier: string; planIdentifier?: string; productType?: PURCHASE_TYPE; quantity?: number; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }) => Promise<Transaction>
|
|
1792
|
+
purchaseProduct(options: { productIdentifier: string; planIdentifier?: string; productType?: PURCHASE_TYPE; quantity?: number; billingPlanType?: 'monthly' | 'upFront'; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }) => Promise<Transaction>
|
|
1762
1793
|
```
|
|
1763
1794
|
|
|
1764
1795
|
Started purchase process for the given product.
|
|
1765
1796
|
|
|
1766
|
-
| Param | Type
|
|
1767
|
-
| ------------- |
|
|
1768
|
-
| **`options`** | <code>{ productIdentifier: string; planIdentifier?: string; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; quantity?: number; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }</code> | - The product to purchase |
|
|
1797
|
+
| Param | Type | Description |
|
|
1798
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
|
|
1799
|
+
| **`options`** | <code>{ productIdentifier: string; planIdentifier?: string; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; quantity?: number; billingPlanType?: 'upFront' \| 'monthly'; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }</code> | - The product to purchase |
|
|
1769
1800
|
|
|
1770
1801
|
**Returns:** <code>Promise<<a href="#transaction">Transaction</a>></code>
|
|
1771
1802
|
|
|
@@ -2037,6 +2068,10 @@ which is useful for determining if users are entitled to features from earlier b
|
|
|
2037
2068
|
| **`revocationReason`** | <code>'developerIssue' \| 'other' \| 'unknown'</code> | Reason why Apple revoked the transaction. Possible values: - `"developerIssue"`: Developer-initiated refund or issue - `"other"`: Apple-initiated (customer refund, billing problem, etc.) - `"unknown"`: StoreKit didn't report a specific reason | | 7.13.2 |
|
|
2038
2069
|
| **`willCancel`** | <code>boolean \| null</code> | Whether the subscription will be cancelled at the end of the billing cycle. - `true`: User has cancelled but subscription remains active until expiration - `false`: Subscription will auto-renew - `null`: Status unknown or not available | <code>null</code> | 1.0.0 |
|
|
2039
2070
|
| **`subscriptionState`** | <code>'unknown' \| 'subscribed' \| 'expired' \| 'revoked' \| 'inGracePeriod' \| 'inBillingRetryPeriod'</code> | Current subscription state reported by StoreKit. Possible values: - `"subscribed"`: Auto-renewing and in good standing - `"expired"`: Lapsed with no access - `"revoked"`: Access removed due to refund or issue - `"inGracePeriod"`: Payment issue but still in grace access window - `"inBillingRetryPeriod"`: StoreKit retrying failed billing - `"unknown"`: StoreKit did not report a state | | 7.13.2 |
|
|
2071
|
+
| **`billingPlanType`** | <code><a href="#subscriptionbillingplantype">SubscriptionBillingPlanType</a></code> | StoreKit billing plan type for auto-renewable subscriptions. - `"upFront"`: Standard subscription billing for the full billing period. - `"monthly"`: Monthly billing with a 12-month commitment. - `"unknown"`: StoreKit returned a future or unsupported value. | | 8.3.8 |
|
|
2072
|
+
| **`commitmentInfo`** | <code><a href="#transactioncommitmentinfo">TransactionCommitmentInfo</a></code> | Commitment metadata for monthly subscriptions with a 12-month commitment. Use `expirationDate` here only to display commitment progress. Continue using the top-level `expirationDate` to decide whether the current billing period grants entitlement access. | | 8.3.8 |
|
|
2073
|
+
| **`renewalInfo`** | <code><a href="#subscriptionrenewalinfo">SubscriptionRenewalInfo</a></code> | StoreKit renewal metadata for auto-renewable subscriptions. `willAutoRenew` here describes the next billing period. For monthly commitment subscriptions, `commitmentInfo.willAutoRenew` describes whether the next 12-month commitment renews after the current commitment ends. | | 8.3.8 |
|
|
2074
|
+
| **`currencyCode`** | <code>string</code> | Currency code associated with StoreKit transaction pricing metadata. | | 8.3.8 |
|
|
2040
2075
|
| **`purchaseState`** | <code>string</code> | Purchase state of the transaction (numeric string value). **Android Values:** - `"1"`: Purchase completed and valid (PURCHASED state) - `"0"`: Payment pending (PENDING state, e.g., cash payment processing) - Other numeric values: Various other states Always check `purchaseState === "1"` on Android to verify a valid purchase. Refunded purchases typically disappear from getPurchases() rather than showing a different state. | | 1.0.0 |
|
|
2041
2076
|
| **`orderId`** | <code>string</code> | Order ID associated with the transaction. Use this for server-side verification on Android. This is the Google Play order ID. | | 1.0.0 |
|
|
2042
2077
|
| **`purchaseToken`** | <code>string</code> | Purchase token associated with the transaction. **This is the full verified purchase token from Google Play.** Send this to your backend for server-side validation with Google Play Developer API. This is the Android equivalent of iOS's receipt field. **For backend validation:** - Use Google Play Developer API v3 to verify the purchase - API endpoint: androidpublisher.purchases.products.get() or purchases.subscriptions.get() - This token contains all data needed for validation with Google servers - Can also be used for subscription status checks and cancellation detection | | 1.0.0 |
|
|
@@ -2051,33 +2086,103 @@ which is useful for determining if users are entitled to features from earlier b
|
|
|
2051
2086
|
| **`isInGracePeriod`** | <code>boolean</code> | Whether the transaction is in a grace period. Grace period allows users to fix payment issues while maintaining access. You typically want to continue providing access during this time. - `true`: Subscription payment failed but user still has access - `false`: Not in grace period | | 1.0.0 |
|
|
2052
2087
|
|
|
2053
2088
|
|
|
2089
|
+
#### TransactionCommitmentInfo
|
|
2090
|
+
|
|
2091
|
+
| Prop | Type | Description |
|
|
2092
|
+
| ------------------------- | ------------------- | ---------------------------------------------------- |
|
|
2093
|
+
| **`billingPeriodNumber`** | <code>number</code> | Current billing period number within the commitment. |
|
|
2094
|
+
| **`totalBillingPeriods`** | <code>number</code> | Total number of billing periods in the commitment. |
|
|
2095
|
+
| **`expirationDate`** | <code>string</code> | End of the full commitment, in ISO 8601 format. |
|
|
2096
|
+
| **`price`** | <code>number</code> | Total commitment price in the local currency. |
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
#### SubscriptionRenewalInfo
|
|
2100
|
+
|
|
2101
|
+
| Prop | Type | Description |
|
|
2102
|
+
| ---------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
2103
|
+
| **`willAutoRenew`** | <code>boolean</code> | Whether the next billing period will renew. |
|
|
2104
|
+
| **`autoRenewProductId`** | <code>string</code> | <a href="#product">Product</a> StoreKit will renew into for the next billing period. |
|
|
2105
|
+
| **`renewalBillingPlanType`** | <code><a href="#subscriptionbillingplantype">SubscriptionBillingPlanType</a></code> | Billing plan StoreKit will use for the next billing period. |
|
|
2106
|
+
| **`renewalDate`** | <code>string</code> | Next billing period renewal date, in ISO 8601 format. |
|
|
2107
|
+
| **`renewalPrice`** | <code>number</code> | Next billing period renewal price in the local currency. |
|
|
2108
|
+
| **`currencyCode`** | <code>string</code> | Currency code for renewal pricing metadata. |
|
|
2109
|
+
| **`commitmentInfo`** | <code><a href="#renewalcommitmentinfo">RenewalCommitmentInfo</a></code> | Commitment renewal metadata for monthly subscriptions with a 12-month commitment. |
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
#### RenewalCommitmentInfo
|
|
2113
|
+
|
|
2114
|
+
| Prop | Type | Description |
|
|
2115
|
+
| ---------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
2116
|
+
| **`autoRenewProductId`** | <code>string</code> | <a href="#product">Product</a> StoreKit will renew into after the commitment ends. |
|
|
2117
|
+
| **`willAutoRenew`** | <code>boolean</code> | Whether the subscription renews into another commitment after the current commitment ends. |
|
|
2118
|
+
| **`renewalBillingPlanType`** | <code><a href="#subscriptionbillingplantype">SubscriptionBillingPlanType</a></code> | Billing plan StoreKit will use for the next commitment or renewal. |
|
|
2119
|
+
| **`renewalDate`** | <code>string</code> | Renewal date for the next commitment or renewal, in ISO 8601 format. |
|
|
2120
|
+
| **`renewalPrice`** | <code>number</code> | Renewal price in the local currency. |
|
|
2121
|
+
|
|
2122
|
+
|
|
2054
2123
|
#### Product
|
|
2055
2124
|
|
|
2056
|
-
| Prop | Type | Description
|
|
2057
|
-
| --------------------------------- | ----------------------------------------------------------------------- |
|
|
2058
|
-
| **`identifier`** | <code>string</code> | <a href="#product">Product</a> Id. Android subscriptions note: - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`). - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`). If you group/filter Android subscription results by `identifier`, you are grouping by base plan.
|
|
2059
|
-
| **`description`** | <code>string</code> | Description of the product.
|
|
2060
|
-
| **`title`** | <code>string</code> | Title of the product.
|
|
2061
|
-
| **`price`** | <code>number</code> | Price of the product in the local currency.
|
|
2062
|
-
| **`priceString`** | <code>string</code> | Formatted price of the item, including its currency sign, such as €3.99.
|
|
2063
|
-
| **`currencyCode`** | <code>string</code> | Currency code for price and original price.
|
|
2064
|
-
| **`currencySymbol`** | <code>string</code> | Currency symbol for price and original price.
|
|
2065
|
-
| **`isFamilyShareable`** | <code>boolean</code> | Boolean indicating if the product is sharable with family
|
|
2066
|
-
| **`subscriptionGroupIdentifier`** | <code>string</code> | Group identifier for the product.
|
|
2067
|
-
| **`planIdentifier`** | <code>string</code> | Android subscriptions only: Google Play product identifier tied to the offer/base plan set.
|
|
2068
|
-
| **`offerToken`** | <code>string</code> | Android subscriptions only: offer token required when purchasing specific offers.
|
|
2069
|
-
| **`offerId`** | <code>string \| null</code> | Android subscriptions only: offer identifier (null/undefined for base offers).
|
|
2070
|
-
| **`
|
|
2071
|
-
| **`
|
|
2072
|
-
| **`
|
|
2125
|
+
| Prop | Type | Description | Since |
|
|
2126
|
+
| --------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
2127
|
+
| **`identifier`** | <code>string</code> | <a href="#product">Product</a> Id. Android subscriptions note: - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`). - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`). If you group/filter Android subscription results by `identifier`, you are grouping by base plan. | |
|
|
2128
|
+
| **`description`** | <code>string</code> | Description of the product. | |
|
|
2129
|
+
| **`title`** | <code>string</code> | Title of the product. | |
|
|
2130
|
+
| **`price`** | <code>number</code> | Price of the product in the local currency. | |
|
|
2131
|
+
| **`priceString`** | <code>string</code> | Formatted price of the item, including its currency sign, such as €3.99. | |
|
|
2132
|
+
| **`currencyCode`** | <code>string</code> | Currency code for price and original price. | |
|
|
2133
|
+
| **`currencySymbol`** | <code>string</code> | Currency symbol for price and original price. | |
|
|
2134
|
+
| **`isFamilyShareable`** | <code>boolean</code> | Boolean indicating if the product is sharable with family | |
|
|
2135
|
+
| **`subscriptionGroupIdentifier`** | <code>string</code> | Group identifier for the product. | |
|
|
2136
|
+
| **`planIdentifier`** | <code>string</code> | Android subscriptions only: Google Play product identifier tied to the offer/base plan set. | |
|
|
2137
|
+
| **`offerToken`** | <code>string</code> | Android subscriptions only: offer token required when purchasing specific offers. | |
|
|
2138
|
+
| **`offerId`** | <code>string \| null</code> | Android subscriptions only: offer identifier (null/undefined for base offers). | |
|
|
2139
|
+
| **`pricingTerms`** | <code>SubscriptionPricingTerms[]</code> | iOS subscriptions only: StoreKit pricing terms by billing plan. For subscriptions with a monthly billing plan and 12-month commitment, this includes both the standard up-front plan and the monthly commitment plan. Display both `billingDisplayPrice` and `commitmentInfo.priceString` before starting a monthly commitment purchase. | 8.3.8 |
|
|
2140
|
+
| **`subscriptionPeriod`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | The <a href="#product">Product</a> subscription group identifier. | |
|
|
2141
|
+
| **`introductoryPrice`** | <code><a href="#skproductdiscount">SKProductDiscount</a> \| null</code> | The <a href="#product">Product</a> introductory Price. | |
|
|
2142
|
+
| **`discounts`** | <code>SKProductDiscount[]</code> | The <a href="#product">Product</a> discounts list. | |
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
#### SubscriptionPricingTerms
|
|
2146
|
+
|
|
2147
|
+
| Prop | Type | Description |
|
|
2148
|
+
| ------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
2149
|
+
| **`billingPlanType`** | <code><a href="#subscriptionbillingplantype">SubscriptionBillingPlanType</a></code> | Billing plan represented by this pricing entry. |
|
|
2150
|
+
| **`commitmentInfo`** | <code><a href="#productcommitmentinfo">ProductCommitmentInfo</a></code> | Total commitment details for this billing plan. |
|
|
2151
|
+
| **`billingDisplayPrice`** | <code>string</code> | Formatted price for each billing period. |
|
|
2152
|
+
| **`billingPrice`** | <code>number</code> | Numeric price for each billing period. |
|
|
2153
|
+
| **`billingPeriod`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | Duration of each billing period. |
|
|
2154
|
+
| **`subscriptionOffers`** | <code>StoreKitSubscriptionOffer[]</code> | StoreKit subscription offers that apply to this billing plan. |
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
#### ProductCommitmentInfo
|
|
2158
|
+
|
|
2159
|
+
| Prop | Type | Description |
|
|
2160
|
+
| ----------------- | ----------------------------------------------------------------- | --------------------------------------------- |
|
|
2161
|
+
| **`price`** | <code>number</code> | Total commitment price in the local currency. |
|
|
2162
|
+
| **`priceString`** | <code>string</code> | Formatted total commitment price. |
|
|
2163
|
+
| **`period`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | Full commitment period. |
|
|
2073
2164
|
|
|
2074
2165
|
|
|
2075
2166
|
#### SubscriptionPeriod
|
|
2076
2167
|
|
|
2077
|
-
| Prop | Type
|
|
2078
|
-
| ------------------- |
|
|
2079
|
-
| **`numberOfUnits`** | <code>number</code>
|
|
2080
|
-
| **`unit`** | <code>number</code>
|
|
2168
|
+
| Prop | Type | Description | Since |
|
|
2169
|
+
| ------------------- | -------------------------------------------------------------- | ---------------------------------------- | ----- |
|
|
2170
|
+
| **`numberOfUnits`** | <code>number</code> | The Subscription Period number of unit. | |
|
|
2171
|
+
| **`unit`** | <code>number</code> | The Subscription Period unit. | |
|
|
2172
|
+
| **`unitString`** | <code>'unknown' \| 'day' \| 'week' \| 'month' \| 'year'</code> | Human-readable subscription period unit. | 8.3.8 |
|
|
2173
|
+
|
|
2174
|
+
|
|
2175
|
+
#### StoreKitSubscriptionOffer
|
|
2176
|
+
|
|
2177
|
+
| Prop | Type | Description |
|
|
2178
|
+
| ----------------- | ----------------------------------------------------------------- | --------------------------------------- |
|
|
2179
|
+
| **`identifier`** | <code>string</code> | StoreKit offer identifier. |
|
|
2180
|
+
| **`type`** | <code>string</code> | StoreKit offer type. |
|
|
2181
|
+
| **`price`** | <code>number</code> | Offer price in the local currency. |
|
|
2182
|
+
| **`priceString`** | <code>string</code> | Formatted offer price. |
|
|
2183
|
+
| **`period`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | Offer billing period. |
|
|
2184
|
+
| **`periodCount`** | <code>number</code> | Number of periods the offer applies to. |
|
|
2185
|
+
| **`paymentMode`** | <code>string</code> | StoreKit offer payment mode. |
|
|
2081
2186
|
|
|
2082
2187
|
|
|
2083
2188
|
#### SKProductDiscount
|
|
@@ -2110,6 +2215,14 @@ which is useful for determining if users are entitled to features from earlier b
|
|
|
2110
2215
|
| **`error`** | <code>string</code> | Localized error message describing why verification failed. | 7.13.2 |
|
|
2111
2216
|
|
|
2112
2217
|
|
|
2218
|
+
### Type Aliases
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
#### SubscriptionBillingPlanType
|
|
2222
|
+
|
|
2223
|
+
<code>'upFront' | 'monthly' | 'unknown'</code>
|
|
2224
|
+
|
|
2225
|
+
|
|
2113
2226
|
### Enums
|
|
2114
2227
|
|
|
2115
2228
|
|
|
@@ -41,7 +41,7 @@ import org.json.JSONArray;
|
|
|
41
41
|
@CapacitorPlugin(name = "NativePurchases")
|
|
42
42
|
public class NativePurchasesPlugin extends Plugin {
|
|
43
43
|
|
|
44
|
-
private final String pluginVersion = "8.3.
|
|
44
|
+
private final String pluginVersion = "8.3.10";
|
|
45
45
|
public static final String TAG = "NativePurchases";
|
|
46
46
|
private static final Phaser semaphoreReady = new Phaser(1);
|
|
47
47
|
private BillingClient billingClient;
|