@virex-tech/paywallo-sdk 2.2.1 → 2.2.3
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 +99 -0
- package/dist/index.d.mts +609 -549
- package/dist/index.d.ts +609 -549
- package/dist/index.js +6425 -6132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6447 -6158
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,105 @@ const isActive = await PaywalloClient.hasActiveSubscription();
|
|
|
96
96
|
| `isRestoring` | `boolean` | Restore in progress |
|
|
97
97
|
| `error` | `PurchaseError \| null` | Last error |
|
|
98
98
|
|
|
99
|
+
## Plans & Offerings
|
|
100
|
+
|
|
101
|
+
An offering is a group of products configured in the dashboard that you display together on a paywall. You can swap the active offering in the dashboard without shipping a new app version.
|
|
102
|
+
|
|
103
|
+
### useOfferings()
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { useOfferings, useOfferingPurchase } from "@virex-tech/paywallo-sdk";
|
|
107
|
+
|
|
108
|
+
// Fetch specific offerings by identifier
|
|
109
|
+
const { offerings } = useOfferings(["mensal", "anual", "lifetime"]);
|
|
110
|
+
|
|
111
|
+
// Fetch all offerings
|
|
112
|
+
const { offerings } = useOfferings();
|
|
113
|
+
|
|
114
|
+
// Purchase
|
|
115
|
+
const { purchase } = useOfferingPurchase();
|
|
116
|
+
purchase(offering.product.productId);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
| Property | Type | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `offerings` | `Offering[]` | List of offerings |
|
|
122
|
+
| `isLoading` | `boolean` | Loading state |
|
|
123
|
+
|
|
124
|
+
### useOfferingPurchase()
|
|
125
|
+
|
|
126
|
+
| Property | Type | Description |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| `purchase(productId)` | `Promise<PurchaseOutcome>` | Purchase a product from the offering |
|
|
129
|
+
| `isPurchasing` | `boolean` | Purchase in progress |
|
|
130
|
+
|
|
131
|
+
### Offering type
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
interface Offering {
|
|
135
|
+
id: string;
|
|
136
|
+
name: string;
|
|
137
|
+
identifier: string;
|
|
138
|
+
isCurrent: boolean;
|
|
139
|
+
product: OfferingProduct;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface OfferingProduct {
|
|
143
|
+
id: string;
|
|
144
|
+
name: string;
|
|
145
|
+
productId: string; // App Store / Play Store identifier
|
|
146
|
+
priceUsd: number;
|
|
147
|
+
billingPeriod: string; // "monthly" | "annual" | "lifetime" | ...
|
|
148
|
+
trialDays: number | null;
|
|
149
|
+
|
|
150
|
+
// Intro offer (synced automatically from Apple/Google)
|
|
151
|
+
introOfferMode: "FREE_TRIAL" | "PAY_AS_YOU_GO" | "PAY_UP_FRONT" | null;
|
|
152
|
+
introOfferPrice: number | null;
|
|
153
|
+
introOfferCurrency: string | null;
|
|
154
|
+
introOfferCycles: number | null;
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Example
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { useOfferings, useOfferingPurchase } from "@virex-tech/paywallo-sdk";
|
|
162
|
+
|
|
163
|
+
function Paywall() {
|
|
164
|
+
const { offerings, isLoading } = useOfferings(["mensal", "anual"]);
|
|
165
|
+
const { purchase, isPurchasing } = useOfferingPurchase();
|
|
166
|
+
|
|
167
|
+
if (isLoading) return null;
|
|
168
|
+
|
|
169
|
+
return offerings.map(offering => (
|
|
170
|
+
<View key={offering.id}>
|
|
171
|
+
<Text>{offering.product.name} — ${offering.product.priceUsd}</Text>
|
|
172
|
+
|
|
173
|
+
{offering.product.introOfferMode === "FREE_TRIAL" && (
|
|
174
|
+
<Text>{offering.product.trialDays}-day free trial</Text>
|
|
175
|
+
)}
|
|
176
|
+
{offering.product.introOfferMode === "PAY_AS_YOU_GO" && (
|
|
177
|
+
<Text>
|
|
178
|
+
{offering.product.introOfferCurrency} {offering.product.introOfferPrice}/period
|
|
179
|
+
for {offering.product.introOfferCycles} cycles
|
|
180
|
+
</Text>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
<Button
|
|
184
|
+
onPress={() => purchase(offering.product.productId)}
|
|
185
|
+
disabled={isPurchasing}
|
|
186
|
+
>
|
|
187
|
+
Subscribe
|
|
188
|
+
</Button>
|
|
189
|
+
</View>
|
|
190
|
+
));
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Intro offers are synced automatically from App Store Connect and Google Play — no manual setup needed.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
99
198
|
## Imperative API
|
|
100
199
|
|
|
101
200
|
For use outside React components:
|