@octane-xplat/billing 0.0.0-nightly.g1b95ef7

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 ADDED
@@ -0,0 +1,5 @@
1
+ # @octane-xplat/billing
2
+
3
+ [Documentation](https://octane-xplat.goddardai.org/package-billing).
4
+
5
+ [API reference](https://octane-xplat.goddardai.org/api-billing).
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@octane-xplat/billing",
3
+ "version": "0.0.0-nightly.g1b95ef7",
4
+ "description": "In-app purchases and subscriptions for Octane xplat — StoreKit 2 and Play Billing via @nativescript/payments",
5
+ "keywords": [
6
+ "android",
7
+ "cross-platform",
8
+ "nativescript",
9
+ "octane",
10
+ "xplat",
11
+ "iap",
12
+ "billing",
13
+ "storekit",
14
+ "purchases",
15
+ "subscriptions"
16
+ ],
17
+ "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/billing",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/octane-xplat/octane-xplat",
22
+ "directory": "packages/billing"
23
+ },
24
+ "files": [
25
+ "src",
26
+ "platforms",
27
+ "types",
28
+ "!src/**/*.test.*",
29
+ "!src/**/*.spec.*"
30
+ ],
31
+ "type": "module",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./types/generated/index.d.ts",
35
+ "macos": "./src/index.macos.ts",
36
+ "web": "./src/index.web.ts",
37
+ "native": "./src/index.ts",
38
+ "default": "./src/index.ts"
39
+ },
40
+ "./*": {
41
+ "types": "./types/generated/*.d.ts",
42
+ "default": "./src/*"
43
+ },
44
+ "./*.ts": {
45
+ "types": "./types/generated/*.d.ts",
46
+ "default": "./src/*.ts"
47
+ }
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "test": "node --test tests/*.test.mts",
54
+ "typegen": "tsrx-typegen --target octane",
55
+ "prepack": "bun run typegen && tsrx-typegen --pack-check",
56
+ "pack:check": "tsrx-typegen --pack-check",
57
+ "typecheck": "node ../../scripts/typecheck.ts"
58
+ },
59
+ "devDependencies": {
60
+ "@octane-xplat/nativescript-octane": "0.0.0-nightly.g1b95ef7",
61
+ "@nativescript/core": "9.1.3",
62
+ "@nativescript/types": "9.1.4",
63
+ "octane": "0.23.2",
64
+ "tsrx-typegen": "0.6.2",
65
+ "typescript": "7.1.0-dev.20261121.1",
66
+ "@tsrx/content-mapper": "0.1.2",
67
+ "typescript-classic": "npm:typescript@5.9.3"
68
+ },
69
+ "peerDependencies": {
70
+ "@octane-xplat/nativescript-octane": "0.0.0-nightly.g1b95ef7",
71
+ "@nativescript/core": ">=9.1.0 <10",
72
+ "octane": ">=0.6.3 <1"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@octane-xplat/nativescript-octane": {
76
+ "optional": true
77
+ },
78
+ "@nativescript/core": {
79
+ "optional": true
80
+ }
81
+ },
82
+ "nativescript": {
83
+ "platforms": {
84
+ "android": "9.1.0",
85
+ "ios": "9.1.0"
86
+ }
87
+ },
88
+ "dependencies": {
89
+ "@nativescript/payments": "4.0.1"
90
+ }
91
+ }
@@ -0,0 +1,2 @@
1
+ // Linux's system webview runs the shared web implementation.
2
+ export { billing } from './billing.web'
@@ -0,0 +1,20 @@
1
+ // Billing — macOS leaf. StoreKit is bridgeable through the AppKit host but
2
+ // not wired; report unsupported.
3
+ import type { Billing } from './types'
4
+
5
+ const unsupported = () => Promise.reject(new Error('unsupported: billing is not wired on macOS'))
6
+
7
+ /** Store billing service — Play Billing / StoreKit. */
8
+ export const billing: Billing = {
9
+ supported: false,
10
+ connect: () => Promise.resolve(),
11
+ disconnect: () => {},
12
+ canMakePayments: () => false,
13
+ fetchProducts: unsupported,
14
+ requestPurchase: unsupported,
15
+ onPurchase: () => () => {},
16
+ onPurchaseError: () => () => {},
17
+ getAvailablePurchases: unsupported,
18
+ finishTransaction: unsupported,
19
+ showManageSubscriptions: unsupported,
20
+ }
package/src/billing.ts ADDED
@@ -0,0 +1,174 @@
1
+ // Billing — native leaf over @nativescript/payments (StoreKit 2 + Play
2
+ // Billing). One Payment client behind the flat service; purchase outcomes
3
+ // fan out to registered listeners.
4
+ import { Payment, type Product as NativeProduct, type Transaction } from '@nativescript/payments'
5
+ import type { Billing, Product, Purchase, RequestPurchaseOptions } from './types'
6
+
7
+ let client: Payment | null = null
8
+ let ready = false
9
+ const readyWaiters = new Set<() => void>()
10
+ const purchaseListeners = new Set<(purchases: Purchase[]) => void>()
11
+ const errorListeners = new Set<(error: { code: string; message: string }) => void>()
12
+
13
+ function asProduct(p: NativeProduct): Product {
14
+ return {
15
+ id: p.id,
16
+ title: p.localizedTitle ?? p.title ?? p.name,
17
+ description: p.description,
18
+ type: p.type,
19
+ displayPrice: p.priceFormatted,
20
+ priceMicros: p.priceAmountMicros,
21
+ native: p,
22
+ }
23
+ }
24
+
25
+ function asPurchase(t: Transaction): Purchase {
26
+ return {
27
+ productId: t.productId,
28
+ transactionId: t.orderId,
29
+ transactionDate: t.orderDate ?? null,
30
+ state: t.state,
31
+ type: t.type,
32
+ isAcknowledged: t.isAcknowledged,
33
+ receiptToken: t.receiptToken,
34
+ native: t,
35
+ }
36
+ }
37
+
38
+ function getClient(): Payment {
39
+ if (!client) {
40
+ client = new Payment()
41
+ client.onReady = () => {
42
+ ready = true
43
+ for (const resolve of readyWaiters) {
44
+ resolve()
45
+ }
46
+
47
+ readyWaiters.clear()
48
+ }
49
+
50
+ client.onPurchaseUpdate = (purchases, error) => {
51
+ if (error) {
52
+ const out = {
53
+ code: (error as any)?.code ?? 'ERROR',
54
+ message: error.message ?? String(error),
55
+ }
56
+
57
+ for (const listener of errorListeners) {
58
+ listener(out)
59
+ }
60
+
61
+ return
62
+ }
63
+
64
+ const mapped = (purchases ?? []).map(asPurchase)
65
+
66
+ for (const listener of purchaseListeners) {
67
+ listener(mapped)
68
+ }
69
+ }
70
+ }
71
+
72
+ return client
73
+ }
74
+
75
+ /** Store billing service — Play Billing / StoreKit. */
76
+ export const billing: Billing = {
77
+ supported: Payment.isSupported(),
78
+
79
+ connect(): Promise<void> {
80
+ const c = getClient()
81
+
82
+ if (ready) {
83
+ return Promise.resolve()
84
+ }
85
+
86
+ const pending = new Promise<void>((resolve) => readyWaiters.add(resolve))
87
+
88
+ c.connect()
89
+ return pending
90
+ },
91
+
92
+ disconnect(): void {
93
+ ready = false
94
+ client?.disconnect()
95
+ // @nativescript/payments 4.0.1 never re-fires onReady on a manually
96
+ // disconnected Payment (its internal flag stays set), so reconnecting
97
+ // needs a fresh client — a new Payment's init reconnects and re-arms
98
+ // the callback.
99
+ client = null
100
+ },
101
+
102
+ canMakePayments(): boolean {
103
+ return getClient().canMakePayments()
104
+ },
105
+
106
+ async fetchProducts(productIds: string[], type: 'inapp' | 'subs' = 'inapp'): Promise<Product[]> {
107
+ const products = await getClient().fetchProducts(productIds, type)
108
+
109
+ return (products ?? []).map(asProduct)
110
+ },
111
+
112
+ async requestPurchase(
113
+ product: Product | string,
114
+ options?: RequestPurchaseOptions,
115
+ ): Promise<void> {
116
+ const c = getClient()
117
+ const { type, ...purchaseOptions } = options ?? {}
118
+ let native: NativeProduct | undefined
119
+
120
+ if (typeof product === 'string') {
121
+ const [fetched] = await c.fetchProducts([product], type ?? 'inapp')
122
+
123
+ if (!fetched) {
124
+ throw Object.assign(new Error(`billing.requestPurchase: product '${product}' not found`), {
125
+ code: 'PRODUCT_UNAVAILABLE',
126
+ })
127
+ }
128
+
129
+ native = fetched
130
+ } else {
131
+ native = product.native as NativeProduct | undefined
132
+ if (!native) {
133
+ throw new Error('billing.requestPurchase: product lacks its native store reference')
134
+ }
135
+ }
136
+
137
+ await c.purchaseProduct(native, purchaseOptions)
138
+ },
139
+
140
+ onPurchase(listener: (purchases: Purchase[]) => void): () => void {
141
+ purchaseListeners.add(listener)
142
+ return () => purchaseListeners.delete(listener)
143
+ },
144
+
145
+ onPurchaseError(listener): () => void {
146
+ errorListeners.add(listener)
147
+ return () => errorListeners.delete(listener)
148
+ },
149
+
150
+ async getAvailablePurchases(): Promise<Purchase[]> {
151
+ const transactions = await getClient().fetchPurchases()
152
+
153
+ return (transactions ?? []).map(asPurchase)
154
+ },
155
+
156
+ async finishTransaction(purchase: Purchase, options?: { consume?: boolean }): Promise<void> {
157
+ const native = purchase.native as Transaction | undefined
158
+
159
+ if (!native) {
160
+ throw new Error('billing.finishTransaction: purchase lacks its native transaction')
161
+ }
162
+
163
+ // consume is a Play Billing concept; the iOS Transaction declares a
164
+ // zero-argument finish(), so call through the wider signature.
165
+ const transaction: { finish(options?: { consume?: boolean }): Promise<void> } = native
166
+ await transaction.finish(options)
167
+ },
168
+
169
+ async showManageSubscriptions(options?: { subscriptionGroupId?: string }): Promise<void> {
170
+ await getClient().showSubscriptionsManagement({
171
+ ios: { subscriptionGroupID: options?.subscriptionGroupId },
172
+ })
173
+ },
174
+ }
@@ -0,0 +1,21 @@
1
+ // Billing — web leaf. No web store backend exists yet (a delegated-checkout
2
+ // seam like RevenueCat Web Billing is a possible future). supported: false;
3
+ // calls throw rather than silently doing nothing.
4
+ import type { Billing } from './types'
5
+
6
+ const unsupported = () => Promise.reject(new Error('unsupported: no store backend on web'))
7
+
8
+ /** Store billing service — Play Billing / StoreKit. */
9
+ export const billing: Billing = {
10
+ supported: false,
11
+ connect: () => Promise.resolve(),
12
+ disconnect: () => {},
13
+ canMakePayments: () => false,
14
+ fetchProducts: unsupported,
15
+ requestPurchase: unsupported,
16
+ onPurchase: () => () => {},
17
+ onPurchaseError: () => () => {},
18
+ getAvailablePurchases: unsupported,
19
+ finishTransaction: unsupported,
20
+ showManageSubscriptions: unsupported,
21
+ }
@@ -0,0 +1,20 @@
1
+ // Windows leaf — no store backend; report unsupported.
2
+ import type { Billing } from './types'
3
+
4
+ const unsupported = () =>
5
+ Promise.reject(new Error('unsupported: billing is not available on windows'))
6
+
7
+ /** Store billing service — Play Billing / StoreKit. */
8
+ export const billing: Billing = {
9
+ supported: false,
10
+ connect: () => Promise.resolve(),
11
+ disconnect: () => {},
12
+ canMakePayments: () => false,
13
+ fetchProducts: unsupported,
14
+ requestPurchase: unsupported,
15
+ onPurchase: () => () => {},
16
+ onPurchaseError: () => () => {},
17
+ getAvailablePurchases: unsupported,
18
+ finishTransaction: unsupported,
19
+ showManageSubscriptions: unsupported,
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './types'
2
+ export { billing } from './billing.macos'
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './types'
2
+ export { billing } from './billing'
@@ -0,0 +1,2 @@
1
+ export * from './types'
2
+ export { billing } from './billing.web'
package/src/types.ts ADDED
@@ -0,0 +1,114 @@
1
+ /** Store product kind: one-time 'inapp' or 'subs' subscription; 'unknown'
2
+ * when the store reports something else. */
3
+ export type ProductType = 'inapp' | 'subs' | 'unknown'
4
+
5
+ /** A store product as fetched from the app store. Prices are null until
6
+ * the store reports them (and priceMicros stays null on iOS). */
7
+ export interface Product {
8
+ /** Store product identifier as registered in the console. */
9
+ id: string
10
+ /** Store-localized title. */
11
+ title: string
12
+ /** Store-localized description. */
13
+ description: string
14
+ /** 'inapp' or 'subs' as queried. */
15
+ type: ProductType
16
+ /** Localized price string ('$4.99') — null until the store reports it. */
17
+ displayPrice: string | null
18
+ /** Price in micros (1_000_000 = 1 unit) — null on iOS, which reports
19
+ * formatted price only at this API level. */
20
+ priceMicros: number | null
21
+ /** Underlying plugin product — pass the fetched Product back to
22
+ * requestPurchase so subscription offer details reach checkout. */
23
+ native?: unknown
24
+ }
25
+
26
+ /** Transaction lifecycle: 'pending' awaits external payment action
27
+ * (ask-to-buy, deferred); 'unknown' covers unmapped store states. */
28
+ export type PurchaseState = 'pending' | 'purchased' | 'unknown'
29
+
30
+ /** One store transaction returned by purchase updates or restore queries. */
31
+ export interface Purchase {
32
+ /** The Product.id this transaction is for. */
33
+ productId: string
34
+ /** Play order id / StoreKit transaction id. */
35
+ transactionId: string
36
+ /** When the store recorded the transaction; null when unreported. */
37
+ transactionDate: Date | null
38
+ /** Normalized transaction state. */
39
+ state: PurchaseState
40
+ /** 'inapp' or 'subs'. */
41
+ type: ProductType
42
+ /** Play: acknowledged; StoreKit: finished. Unacknowledged consumables
43
+ * are re-delivered by the store until finishTransaction completes them. */
44
+ isAcknowledged: boolean
45
+ /** Receipt token for server-side verification (Play purchase token /
46
+ * StoreKit receipt data). */
47
+ receiptToken: string
48
+ /** Underlying plugin transaction — pass to finishTransaction internals
49
+ * when holding the raw reference is required. */
50
+ native?: unknown
51
+ }
52
+
53
+ /** Options for requestPurchase(); platform bags pass through to the store. */
54
+ export interface PurchaseOptions {
55
+ /** Android obfuscated account/profile ids. */
56
+ accountId?: string
57
+ /** Play Billing overrides — obfuscated ids plus the EU personalized-price flag. */
58
+ android?: { accountId?: string; profileId?: string; isOfferPersonalized?: boolean }
59
+ /** StoreKit overrides — quantity and sandbox ask-to-buy simulation. */
60
+ ios?: { quantity?: number; simulatesAskToBuyInSandbox?: boolean }
61
+ }
62
+
63
+ /** requestPurchase() options: store options plus the product kind used to
64
+ * fetch an id before checkout. */
65
+ export interface RequestPurchaseOptions extends PurchaseOptions {
66
+ /** Product kind fetched when `requestPurchase` receives an id rather than
67
+ * a fetched Product; defaults to 'inapp'. Use 'subs' for subscriptions. */
68
+ type?: 'inapp' | 'subs'
69
+ }
70
+
71
+ /** A store-reported failure. */
72
+ export interface PurchaseError {
73
+ /** Normalized store error code (Play Billing response / StoreKit error
74
+ * mapped to shared spellings where possible). */
75
+ code: string
76
+ /** Human-readable store message. */
77
+ message: string
78
+ }
79
+
80
+ /** Store billing façade — Play Billing on Android, StoreKit on iOS.
81
+ * False `supported` on web/desktop leaves. */
82
+ export interface Billing {
83
+ /** StoreKit/Play Billing client exists (false on web/desktop leaves). */
84
+ readonly supported: boolean
85
+ /** Connect the store client — call once at app start, before other calls.
86
+ * Resolves once the store reports ready; check canMakePayments() after it
87
+ * resolves. A call after disconnect() awaits the next readiness signal. */
88
+ connect(): Promise<void>
89
+ /** Release the store client connection. */
90
+ disconnect(): void
91
+ /** The device can make payments (parental controls off, store reachable). */
92
+ canMakePayments(): boolean
93
+ /** Fetch store metadata for console-registered product ids. */
94
+ fetchProducts(productIds: string[], type?: 'inapp' | 'subs'): Promise<Product[]>
95
+ /** Kick the OS purchase sheet. Pass the Product returned by fetchProducts —
96
+ * required for subscriptions, whose 'subs' fetch carries the store's offer
97
+ * details — or a product id, fetched internally as options.type
98
+ * (default 'inapp'). Outcomes arrive on onPurchase/onPurchaseError and
99
+ * must be completed with finishTransaction. */
100
+ requestPurchase(product: Product | string, options?: RequestPurchaseOptions): Promise<void>
101
+ /** Purchase-update listener; returns the unsubscribe function. */
102
+ onPurchase(listener: (purchases: Purchase[]) => void): () => void
103
+ /** Purchase-failure listener; returns the unsubscribe function. */
104
+ onPurchaseError(listener: (error: PurchaseError) => void): () => void
105
+ /** Owned/unconsumed purchases — the "restore" query on both stores. */
106
+ getAvailablePurchases(): Promise<Purchase[]>
107
+ /** Consume/acknowledge a completed purchase (Play: consume or
108
+ * acknowledge; StoreKit: finish). Options.consume = consumable flow. */
109
+ finishTransaction(purchase: Purchase, options?: { consume?: boolean }): Promise<void>
110
+ /** Native subscription management UI. */
111
+ showManageSubscriptions(options?: { subscriptionGroupId?: string }): Promise<void>
112
+ }
113
+
114
+ export declare const billing: Billing
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 1,
3
+ "files": [
4
+ "billing.d.ts",
5
+ "index.d.ts",
6
+ "types.d.ts"
7
+ ]
8
+ }
@@ -0,0 +1,3 @@
1
+ import type { Billing } from './types.js';
2
+ /** Store billing service — Play Billing / StoreKit. */
3
+ export declare const billing: Billing;
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export { billing } from './billing.js';
@@ -0,0 +1,117 @@
1
+ /** Store product kind: one-time 'inapp' or 'subs' subscription; 'unknown'
2
+ * when the store reports something else. */
3
+ export type ProductType = 'inapp' | 'subs' | 'unknown';
4
+ /** A store product as fetched from the app store. Prices are null until
5
+ * the store reports them (and priceMicros stays null on iOS). */
6
+ export interface Product {
7
+ /** Store product identifier as registered in the console. */
8
+ id: string;
9
+ /** Store-localized title. */
10
+ title: string;
11
+ /** Store-localized description. */
12
+ description: string;
13
+ /** 'inapp' or 'subs' as queried. */
14
+ type: ProductType;
15
+ /** Localized price string ('$4.99') — null until the store reports it. */
16
+ displayPrice: string | null;
17
+ /** Price in micros (1_000_000 = 1 unit) — null on iOS, which reports
18
+ * formatted price only at this API level. */
19
+ priceMicros: number | null;
20
+ /** Underlying plugin product — pass the fetched Product back to
21
+ * requestPurchase so subscription offer details reach checkout. */
22
+ native?: unknown;
23
+ }
24
+ /** Transaction lifecycle: 'pending' awaits external payment action
25
+ * (ask-to-buy, deferred); 'unknown' covers unmapped store states. */
26
+ export type PurchaseState = 'pending' | 'purchased' | 'unknown';
27
+ /** One store transaction returned by purchase updates or restore queries. */
28
+ export interface Purchase {
29
+ /** The Product.id this transaction is for. */
30
+ productId: string;
31
+ /** Play order id / StoreKit transaction id. */
32
+ transactionId: string;
33
+ /** When the store recorded the transaction; null when unreported. */
34
+ transactionDate: Date | null;
35
+ /** Normalized transaction state. */
36
+ state: PurchaseState;
37
+ /** 'inapp' or 'subs'. */
38
+ type: ProductType;
39
+ /** Play: acknowledged; StoreKit: finished. Unacknowledged consumables
40
+ * are re-delivered by the store until finishTransaction completes them. */
41
+ isAcknowledged: boolean;
42
+ /** Receipt token for server-side verification (Play purchase token /
43
+ * StoreKit receipt data). */
44
+ receiptToken: string;
45
+ /** Underlying plugin transaction — pass to finishTransaction internals
46
+ * when holding the raw reference is required. */
47
+ native?: unknown;
48
+ }
49
+ /** Options for requestPurchase(); platform bags pass through to the store. */
50
+ export interface PurchaseOptions {
51
+ /** Android obfuscated account/profile ids. */
52
+ accountId?: string;
53
+ /** Play Billing overrides — obfuscated ids plus the EU personalized-price flag. */
54
+ android?: {
55
+ accountId?: string;
56
+ profileId?: string;
57
+ isOfferPersonalized?: boolean;
58
+ };
59
+ /** StoreKit overrides — quantity and sandbox ask-to-buy simulation. */
60
+ ios?: {
61
+ quantity?: number;
62
+ simulatesAskToBuyInSandbox?: boolean;
63
+ };
64
+ }
65
+ /** requestPurchase() options: store options plus the product kind used to
66
+ * fetch an id before checkout. */
67
+ export interface RequestPurchaseOptions extends PurchaseOptions {
68
+ /** Product kind fetched when `requestPurchase` receives an id rather than
69
+ * a fetched Product; defaults to 'inapp'. Use 'subs' for subscriptions. */
70
+ type?: 'inapp' | 'subs';
71
+ }
72
+ /** A store-reported failure. */
73
+ export interface PurchaseError {
74
+ /** Normalized store error code (Play Billing response / StoreKit error
75
+ * mapped to shared spellings where possible). */
76
+ code: string;
77
+ /** Human-readable store message. */
78
+ message: string;
79
+ }
80
+ /** Store billing façade — Play Billing on Android, StoreKit on iOS.
81
+ * False `supported` on web/desktop leaves. */
82
+ export interface Billing {
83
+ /** StoreKit/Play Billing client exists (false on web/desktop leaves). */
84
+ readonly supported: boolean;
85
+ /** Connect the store client — call once at app start, before other calls.
86
+ * Resolves once the store reports ready; check canMakePayments() after it
87
+ * resolves. A call after disconnect() awaits the next readiness signal. */
88
+ connect(): Promise<void>;
89
+ /** Release the store client connection. */
90
+ disconnect(): void;
91
+ /** The device can make payments (parental controls off, store reachable). */
92
+ canMakePayments(): boolean;
93
+ /** Fetch store metadata for console-registered product ids. */
94
+ fetchProducts(productIds: string[], type?: 'inapp' | 'subs'): Promise<Product[]>;
95
+ /** Kick the OS purchase sheet. Pass the Product returned by fetchProducts —
96
+ * required for subscriptions, whose 'subs' fetch carries the store's offer
97
+ * details — or a product id, fetched internally as options.type
98
+ * (default 'inapp'). Outcomes arrive on onPurchase/onPurchaseError and
99
+ * must be completed with finishTransaction. */
100
+ requestPurchase(product: Product | string, options?: RequestPurchaseOptions): Promise<void>;
101
+ /** Purchase-update listener; returns the unsubscribe function. */
102
+ onPurchase(listener: (purchases: Purchase[]) => void): () => void;
103
+ /** Purchase-failure listener; returns the unsubscribe function. */
104
+ onPurchaseError(listener: (error: PurchaseError) => void): () => void;
105
+ /** Owned/unconsumed purchases — the "restore" query on both stores. */
106
+ getAvailablePurchases(): Promise<Purchase[]>;
107
+ /** Consume/acknowledge a completed purchase (Play: consume or
108
+ * acknowledge; StoreKit: finish). Options.consume = consumable flow. */
109
+ finishTransaction(purchase: Purchase, options?: {
110
+ consume?: boolean;
111
+ }): Promise<void>;
112
+ /** Native subscription management UI. */
113
+ showManageSubscriptions(options?: {
114
+ subscriptionGroupId?: string;
115
+ }): Promise<void>;
116
+ }
117
+ export declare const billing: Billing;