@onborn/billing 0.1.0-beta.1 → 0.1.0-beta.2
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/CHANGELOG.md +7 -0
- package/README.md +5 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +3 -3
- package/dist/useOnbornOffering.d.ts +1 -2
- package/dist/useOnbornOffering.js +3 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.2
|
|
4
|
+
|
|
5
|
+
- Removed `offeringId` from `useOnbornOffering` and
|
|
6
|
+
`BillingClient.loadOffering`.
|
|
7
|
+
- Billing now loads only the offering marked Current for the project
|
|
8
|
+
environment.
|
|
9
|
+
|
|
3
10
|
## 0.1.0-beta.1
|
|
4
11
|
|
|
5
12
|
- Added headless offering, paywall, purchase, restore, and entitlement APIs.
|
package/README.md
CHANGED
|
@@ -36,6 +36,11 @@ function PremiumGate() {
|
|
|
36
36
|
The package owns the Onborn API URL. Configure credentials and user context
|
|
37
37
|
once through `Onborn.init`; hooks and adapters do not accept an API key.
|
|
38
38
|
|
|
39
|
+
`useOnbornOffering()` and `BillingClient.loadOffering()` always load the
|
|
40
|
+
offering marked **Current** for the active project and environment. The public
|
|
41
|
+
API accepts no offering ID. Select the current offering in Dashboard → Billing
|
|
42
|
+
before loading a custom paywall.
|
|
43
|
+
|
|
39
44
|
Installing `@onborn/billing` also installs its analytics and public-contract
|
|
40
45
|
dependencies. You do not need `@onborn/rn-sdk` unless you render Onborn-built
|
|
41
46
|
flows or paywalls.
|
package/dist/client.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class BillingClient {
|
|
|
10
10
|
private readonly emitAnalyticsEvents;
|
|
11
11
|
constructor(options?: BillingClientOptions);
|
|
12
12
|
loadPaywall(paywallId: string): Promise<GetPaywallResponse>;
|
|
13
|
-
loadOffering(
|
|
13
|
+
loadOffering(): Promise<GetOfferingResponse>;
|
|
14
14
|
validatePurchase(input: Omit<ValidatePurchaseRequest, "userId">): Promise<PurchaseValidationResponse>;
|
|
15
15
|
restorePurchases(input: Omit<RestorePurchasesRequest, "userId">): Promise<PurchaseValidationResponse>;
|
|
16
16
|
loadCustomerEntitlements(): Promise<CustomerEntitlementsResponse>;
|
package/dist/client.js
CHANGED
|
@@ -24,9 +24,9 @@ export class BillingClient {
|
|
|
24
24
|
}
|
|
25
25
|
return parsed.data;
|
|
26
26
|
}
|
|
27
|
-
async loadOffering(
|
|
28
|
-
const url = this.runtimeUrl(
|
|
29
|
-
const payload = await this.getJson(url,
|
|
27
|
+
async loadOffering() {
|
|
28
|
+
const url = this.runtimeUrl("/offerings/current");
|
|
29
|
+
const payload = await this.getJson(url, "current offering");
|
|
30
30
|
const parsed = GetOfferingResponseSchema.safeParse(payload);
|
|
31
31
|
if (!parsed.success) {
|
|
32
32
|
throw new Error("Invalid offering response payload");
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type CustomerEntitlement, type GetOfferingResponse } from "@onborn/sdk-contracts";
|
|
2
2
|
import type { OnbornBillingAdapter, OnbornPackageWithProduct, OnbornPurchaseResult, OnbornRestoreResult } from "./types";
|
|
3
3
|
export type UseOnbornOfferingOptions = {
|
|
4
|
-
offeringId: string;
|
|
5
4
|
initialPackageId?: string;
|
|
6
5
|
billingAdapter?: OnbornBillingAdapter;
|
|
7
6
|
onPurchaseStarted?: (item: OnbornPackageWithProduct) => void;
|
|
@@ -26,4 +25,4 @@ export type UseOnbornOfferingState = {
|
|
|
26
25
|
restorePurchases: () => Promise<OnbornRestoreResult>;
|
|
27
26
|
refetchCustomerEntitlements: () => Promise<OnbornRestoreResult>;
|
|
28
27
|
};
|
|
29
|
-
export declare function useOnbornOffering(options
|
|
28
|
+
export declare function useOnbornOffering(options?: UseOnbornOfferingOptions): UseOnbornOfferingState;
|
|
@@ -3,7 +3,7 @@ import { createBillingClient } from "./client";
|
|
|
3
3
|
import { useOnbornBillingConfig } from "./runtime";
|
|
4
4
|
import { findPackageWithProduct, getPackagesWithProducts, resolveDefaultPackageId, } from "./utils";
|
|
5
5
|
import { validateBillingPurchase, validateBillingRestore } from "./validation";
|
|
6
|
-
export function useOnbornOffering(options) {
|
|
6
|
+
export function useOnbornOffering(options = {}) {
|
|
7
7
|
const runtimeOptions = useOnbornBillingConfig(options);
|
|
8
8
|
const [data, setData] = useState(null);
|
|
9
9
|
const [selectedPackageId, setSelectedPackageId] = useState(runtimeOptions.initialPackageId ?? null);
|
|
@@ -12,7 +12,7 @@ export function useOnbornOffering(options) {
|
|
|
12
12
|
const [restoring, setRestoring] = useState(false);
|
|
13
13
|
const [error, setError] = useState(null);
|
|
14
14
|
const client = useMemo(() => createBillingClient({
|
|
15
|
-
sourceId:
|
|
15
|
+
sourceId: "offering:current",
|
|
16
16
|
}), [
|
|
17
17
|
runtimeOptions.apiKey,
|
|
18
18
|
runtimeOptions.appId,
|
|
@@ -23,7 +23,6 @@ export function useOnbornOffering(options) {
|
|
|
23
23
|
runtimeOptions.emitSdkConnectionSignal,
|
|
24
24
|
runtimeOptions.fetchImpl,
|
|
25
25
|
runtimeOptions.locale,
|
|
26
|
-
runtimeOptions.offeringId,
|
|
27
26
|
runtimeOptions.platform,
|
|
28
27
|
runtimeOptions.sdkVersion,
|
|
29
28
|
runtimeOptions.userId,
|
|
@@ -38,7 +37,7 @@ export function useOnbornOffering(options) {
|
|
|
38
37
|
setLoading(true);
|
|
39
38
|
setError(null);
|
|
40
39
|
try {
|
|
41
|
-
const response = await client.loadOffering(
|
|
40
|
+
const response = await client.loadOffering();
|
|
42
41
|
const products = await loadLocalizedProducts(runtimeOptions.billingAdapter, {
|
|
43
42
|
offering: response.offering,
|
|
44
43
|
products: response.products,
|
|
@@ -62,7 +61,6 @@ export function useOnbornOffering(options) {
|
|
|
62
61
|
}, [
|
|
63
62
|
client,
|
|
64
63
|
runtimeOptions.billingAdapter,
|
|
65
|
-
runtimeOptions.offeringId,
|
|
66
64
|
runtimeOptions.userId,
|
|
67
65
|
]);
|
|
68
66
|
useEffect(() => {
|