@leisuresaas/react-native 0.6.11-dev.1 → 0.6.12-dev.1
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 +4 -0
- package/package.json +1 -1
- package/src/errors.ts +18 -0
- package/src/index.ts +8 -0
- package/src/types.ts +102 -0
package/README.md
CHANGED
|
@@ -58,6 +58,10 @@ Admin → Social login 必须配置,否则换产品会话失败。Publishable
|
|
|
58
58
|
|
|
59
59
|
注册页按 `getPublicAppConfig` 返回的 `consents` 画勾选框,勾选项传给 `register({ consents })`。登录后调 `getConsents`,`allRequiredAccepted` 为假时显示同意页,再 `submitConsents`。详见 [AGENTS.md](AGENTS.md) §2c。
|
|
60
60
|
|
|
61
|
+
## 商店优惠
|
|
62
|
+
|
|
63
|
+
`Offer`、`OfferList`、`ClaimOfferResult`、`SubscriptionOffer` 等类型和 `ErrorReason.Offer*` 用于读产品 BFF 透传的优惠(试用)结果,SDK 不调 billing。见 AGENTS.md 4e。
|
|
64
|
+
|
|
61
65
|
## Push(产品 BFF 登记)
|
|
62
66
|
|
|
63
67
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leisuresaas/react-native",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12-dev.1",
|
|
4
4
|
"description": "React Native SDK for LeisureSaas: OAuth, Public Ads/App Config, Drive User Plane (publishable keys). Frontend-only — no Integration Key.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/src/errors.ts
CHANGED
|
@@ -36,6 +36,24 @@ export const ErrorReason = {
|
|
|
36
36
|
FallbackPlanMissing: "FALLBACK_PLAN_MISSING",
|
|
37
37
|
WorkspaceHasMembers: "WORKSPACE_HAS_MEMBERS",
|
|
38
38
|
SubscriptionActiveOtherSource: "SUBSCRIPTION_ACTIVE_OTHER_SOURCE",
|
|
39
|
+
// Offers (R-1125-1), passed through by the product BFF from claim / checkout. The user or another
|
|
40
|
+
// workspace member already had a trial of the product / the workspace subscribed before / outside
|
|
41
|
+
// the audience / no mapping for this platform or app / iOS new user without apple_intro / plan not
|
|
42
|
+
// in the campaign / before or after the campaign dates / limit used up / no such offer / the
|
|
43
|
+
// redemption is already used or released.
|
|
44
|
+
OfferTrialAlreadyUsed: "OFFER_TRIAL_ALREADY_USED",
|
|
45
|
+
OfferPreviousSubscriber: "OFFER_PREVIOUS_SUBSCRIBER",
|
|
46
|
+
OfferNotEligible: "OFFER_NOT_ELIGIBLE",
|
|
47
|
+
OfferPlatformNotSupported: "OFFER_PLATFORM_NOT_SUPPORTED",
|
|
48
|
+
OfferAppleNewUserNotSupported: "OFFER_APPLE_NEW_USER_NOT_SUPPORTED",
|
|
49
|
+
OfferPlanNotApplicable: "OFFER_PLAN_NOT_APPLICABLE",
|
|
50
|
+
OfferNotStarted: "OFFER_NOT_STARTED",
|
|
51
|
+
OfferExpired: "OFFER_EXPIRED",
|
|
52
|
+
OfferLimitReached: "OFFER_LIMIT_REACHED",
|
|
53
|
+
OfferNotFound: "OFFER_NOT_FOUND",
|
|
54
|
+
OfferRedemptionNotHeld: "OFFER_REDEMPTION_NOT_HELD",
|
|
55
|
+
// apple_intro claim: the product has no App Store In-App Purchase key.
|
|
56
|
+
StoreNotConfigured: "STORE_NOT_CONFIGURED",
|
|
39
57
|
// The token's workspace is no longer the user's active one: refresh the token, then retry.
|
|
40
58
|
ActiveWorkspaceChanged: "ACTIVE_WORKSPACE_CHANGED",
|
|
41
59
|
// Sessions: signed out because the user signed in on another device / a sign-in refused because
|
package/src/index.ts
CHANGED
|
@@ -219,12 +219,20 @@ export type {
|
|
|
219
219
|
AdFeedSource,
|
|
220
220
|
AdsFeedResponse,
|
|
221
221
|
AuthConfig,
|
|
222
|
+
ClaimOfferResult,
|
|
222
223
|
EnablePushOptions,
|
|
223
224
|
Entitlement,
|
|
224
225
|
LeisureSaasAuthConfig,
|
|
225
226
|
MobilePlatform,
|
|
227
|
+
Offer,
|
|
228
|
+
OfferBenefit,
|
|
229
|
+
OfferCampaign,
|
|
230
|
+
OfferList,
|
|
231
|
+
OfferMethod,
|
|
232
|
+
OfferRedemption,
|
|
226
233
|
Plan,
|
|
227
234
|
RegisterDeviceTokenInput,
|
|
235
|
+
SubscriptionOffer,
|
|
228
236
|
SubscriptionStatus,
|
|
229
237
|
} from "./types";
|
|
230
238
|
|
package/src/types.ts
CHANGED
|
@@ -23,6 +23,108 @@ export type SubscriptionStatus = {
|
|
|
23
23
|
plan_version_id?: string;
|
|
24
24
|
billing_source?: string;
|
|
25
25
|
current_period_end_unix?: number;
|
|
26
|
+
cancel_at_period_end?: boolean;
|
|
27
|
+
price_id?: string;
|
|
28
|
+
/** The offer the subscription is under or came from (R-1125-1); absent when none. */
|
|
29
|
+
offer?: SubscriptionOffer;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Offer on a subscription. `phase` is `trial` or `intro` while it lasts and empty after conversion;
|
|
34
|
+
* `type` stays.
|
|
35
|
+
*/
|
|
36
|
+
export type SubscriptionOffer = {
|
|
37
|
+
type:
|
|
38
|
+
| "introductory"
|
|
39
|
+
| "promotional"
|
|
40
|
+
| "offer_code"
|
|
41
|
+
| "win_back"
|
|
42
|
+
| "offer"
|
|
43
|
+
| "promo_code"
|
|
44
|
+
| "platform_offer"
|
|
45
|
+
| "stripe_trial";
|
|
46
|
+
id?: string;
|
|
47
|
+
phase?: "" | "trial" | "intro";
|
|
48
|
+
phase_ends_at_unix?: number;
|
|
49
|
+
/** Platform campaign; absent for a store offer the platform did not hand out. */
|
|
50
|
+
campaign_id?: string;
|
|
51
|
+
redemption_id?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* How an offer is used: `platform_grant` / `stripe_trial` (web), `google_offer` (android: buy with
|
|
56
|
+
* the Play offer), `apple_intro` (ios: buy with `ios.intro_eligibility_jws`).
|
|
57
|
+
*/
|
|
58
|
+
export type OfferMethod = "platform_grant" | "stripe_trial" | "google_offer" | "apple_intro";
|
|
59
|
+
|
|
60
|
+
export type OfferBenefit = {
|
|
61
|
+
type: "free_days" | "percent_off" | "amount_off";
|
|
62
|
+
free_days?: number;
|
|
63
|
+
percent_off?: number;
|
|
64
|
+
amount_off_cents?: number;
|
|
65
|
+
currency?: string;
|
|
66
|
+
duration_periods?: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type OfferCampaign = {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
purpose: "trial" | "promotion";
|
|
73
|
+
benefit: OfferBenefit;
|
|
74
|
+
ends_at_unix?: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* An offer as the product BFF returns it from sdk/go `ListOffers` / `ClaimOffer` (Integration
|
|
79
|
+
* `GET /v1/billing/offers`, `POST /v1/billing/offers/claim`). The app never calls billing itself.
|
|
80
|
+
*/
|
|
81
|
+
export type Offer = {
|
|
82
|
+
/** Pass to the BFF's claim. */
|
|
83
|
+
offer_ref: string;
|
|
84
|
+
campaign: OfferCampaign;
|
|
85
|
+
/** Plans the offer applies to; empty = every paid plan. */
|
|
86
|
+
plan_ids: string[];
|
|
87
|
+
method: OfferMethod;
|
|
88
|
+
/** Set while the user holds this offer (until `held_until_unix`). */
|
|
89
|
+
redemption_id?: string | null;
|
|
90
|
+
held_until_unix?: number;
|
|
91
|
+
price_id?: string;
|
|
92
|
+
android?: { package_name?: string; store_product_id: string; base_plan_id: string; offer_id: string };
|
|
93
|
+
/** `intro_eligibility_jws` is set on claims only. */
|
|
94
|
+
ios?: { bundle_id?: string; store_product_id: string; intro_eligibility_jws?: string };
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** `GET /v1/billing/offers` response. */
|
|
98
|
+
export type OfferList = {
|
|
99
|
+
offers: Offer[];
|
|
100
|
+
/** ios with `app_transaction_id` and no `apple_intro` offer: a "no trial" JWS per App Store product. */
|
|
101
|
+
apple_intro_ineligible?: { store_product_id: string; jws: string }[];
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type OfferRedemption = {
|
|
105
|
+
id: string;
|
|
106
|
+
campaign_id?: string;
|
|
107
|
+
platform: "web" | "ios" | "android";
|
|
108
|
+
method: string;
|
|
109
|
+
purpose: "trial" | "promotion";
|
|
110
|
+
status: "held" | "used" | "released";
|
|
111
|
+
plan_id?: string;
|
|
112
|
+
price_id?: string;
|
|
113
|
+
held_until_unix?: number;
|
|
114
|
+
subscription_id?: string;
|
|
115
|
+
order_id?: string;
|
|
116
|
+
outcome?: "active" | "converted" | "expired" | "replaced";
|
|
117
|
+
release_reason?: "expired" | "user" | "replaced" | "checkout_expired" | "admin";
|
|
118
|
+
created_at_unix?: number;
|
|
119
|
+
used_at_unix?: number;
|
|
120
|
+
released_at_unix?: number;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** `POST /v1/billing/offers/claim` response; `subscription` is set for `platform_grant`. */
|
|
124
|
+
export type ClaimOfferResult = {
|
|
125
|
+
redemption: OfferRedemption;
|
|
126
|
+
offer: Offer;
|
|
127
|
+
subscription?: SubscriptionStatus;
|
|
26
128
|
};
|
|
27
129
|
|
|
28
130
|
export type Entitlement = {
|