@leisuresaas/react-native 0.6.12-dev.2 → 0.6.12-dev.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/package.json +1 -1
- package/src/errors.ts +10 -0
- package/src/index.ts +2 -0
- package/src/types.ts +47 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leisuresaas/react-native",
|
|
3
|
-
"version": "0.6.12-dev.
|
|
3
|
+
"version": "0.6.12-dev.3",
|
|
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
|
@@ -58,6 +58,16 @@ export const ErrorReason = {
|
|
|
58
58
|
OfferNotASubscriber: "OFFER_NOT_A_SUBSCRIBER",
|
|
59
59
|
OfferNotInList: "OFFER_NOT_IN_LIST",
|
|
60
60
|
OfferAlreadySubscribed: "OFFER_ALREADY_SUBSCRIBED",
|
|
61
|
+
// Promo codes (R-1125-1 P4), from the BFF's ClaimOffer (and a code redeem in an Android app): the
|
|
62
|
+
// code is unknown, disabled or its campaign is not live / already used / too many invalid codes
|
|
63
|
+
// (429) / a code campaign claimed without redeeming a code (internal) / the iOS Apple code pool is
|
|
64
|
+
// empty / the code pool is for new iOS users only.
|
|
65
|
+
OfferCodeInvalid: "OFFER_CODE_INVALID",
|
|
66
|
+
OfferCodeAlreadyRedeemed: "OFFER_CODE_ALREADY_REDEEMED",
|
|
67
|
+
OfferCodeRateLimited: "OFFER_CODE_RATE_LIMITED",
|
|
68
|
+
OfferCodeRequired: "OFFER_CODE_REQUIRED",
|
|
69
|
+
OfferPoolExhausted: "OFFER_POOL_EXHAUSTED",
|
|
70
|
+
OfferAppleCodePoolNewUsersOnly: "OFFER_APPLE_CODE_POOL_NEW_USERS_ONLY",
|
|
61
71
|
// apple_intro claim: the product has no App Store In-App Purchase key.
|
|
62
72
|
StoreNotConfigured: "STORE_NOT_CONFIGURED",
|
|
63
73
|
// The token's workspace is no longer the user's active one: refresh the token, then retry.
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -56,7 +56,8 @@ export type SubscriptionOffer = {
|
|
|
56
56
|
* How an offer is used: `platform_grant` / `stripe_trial` / `stripe_coupon` (web), `google_offer`
|
|
57
57
|
* (android: buy with the Play offer), `apple_intro` (ios: buy with `ios.intro_eligibility_jws`),
|
|
58
58
|
* `apple_promotional` (ios: buy with `ios.promotional_offer_id` + signature or JWS and
|
|
59
|
-
* `appAccountToken = account_token`)
|
|
59
|
+
* `appAccountToken = account_token`), `apple_offer_code_pool` (ios promo code for new users: redeemed
|
|
60
|
+
* on the product's website through `ios.redeem_url`, never in the app).
|
|
60
61
|
*/
|
|
61
62
|
export type OfferMethod =
|
|
62
63
|
| "platform_grant"
|
|
@@ -64,7 +65,8 @@ export type OfferMethod =
|
|
|
64
65
|
| "stripe_coupon"
|
|
65
66
|
| "google_offer"
|
|
66
67
|
| "apple_intro"
|
|
67
|
-
| "apple_promotional"
|
|
68
|
+
| "apple_promotional"
|
|
69
|
+
| "apple_offer_code_pool";
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
72
|
* Classic Apple promotional offer signature (`ios.promotional_signature`), for
|
|
@@ -122,12 +124,22 @@ export type Offer = {
|
|
|
122
124
|
promotional_signature?: ApplePromotionalSignature;
|
|
123
125
|
/** apple_promotional: for `promotionalOffer(_:compactJWS:)`. */
|
|
124
126
|
promotional_offer_jws?: string;
|
|
127
|
+
/** apple_offer_code_pool code redeem only (on the website): App Store link for `apple_code`. */
|
|
128
|
+
redeem_url?: string;
|
|
129
|
+
apple_code?: string;
|
|
125
130
|
};
|
|
126
131
|
/**
|
|
127
132
|
* Claims on ios / android: the user's fixed account token for the product (lowercase UUID). Pass it
|
|
128
133
|
* as Apple `appAccountToken` / Google `obfuscatedAccountId` on every purchase.
|
|
129
134
|
*/
|
|
130
135
|
account_token?: string;
|
|
136
|
+
/**
|
|
137
|
+
* `code` = a promo code campaign. It is listed only while the user holds a redemption from a code
|
|
138
|
+
* redeemed on the website; claim it as usual.
|
|
139
|
+
*/
|
|
140
|
+
entry?: "automatic" | "code";
|
|
141
|
+
/** Promo code campaigns: the code the user redeemed, masked ("SPRING-••••-••••-PT"). Show as a hint. */
|
|
142
|
+
code?: { display: string };
|
|
131
143
|
};
|
|
132
144
|
|
|
133
145
|
/** `GET /v1/billing/offers` response. */
|
|
@@ -154,6 +166,39 @@ export type OfferRedemption = {
|
|
|
154
166
|
created_at_unix?: number;
|
|
155
167
|
used_at_unix?: number;
|
|
156
168
|
released_at_unix?: number;
|
|
169
|
+
/** Promo code campaigns: the code redeemed and its masked display. */
|
|
170
|
+
code_id?: string;
|
|
171
|
+
code_display?: string;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* One platform's answer for a promo code (`POST /v1/billing/offers/codes/validate`, for an Android
|
|
176
|
+
* app that lets users enter codes). `redeem_on` is ios only: `web` (Apple code pool link on the
|
|
177
|
+
* website) or `app` (redeem on the website, then claim in the app).
|
|
178
|
+
*/
|
|
179
|
+
export type OfferCodeResult = {
|
|
180
|
+
eligible: boolean;
|
|
181
|
+
reason?: string | null;
|
|
182
|
+
method?: OfferMethod | null;
|
|
183
|
+
redeem_on?: "web" | "app";
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Validate response as the BFF passes it through from sdk/go `ValidateOfferCode`. Always 200: an
|
|
188
|
+
* unusable code is `eligible: false` with a `reason`. With `platform` the top-level fields are that
|
|
189
|
+
* platform's; `code`, `campaign`, `plan_ids`, `platforms` are absent for `OFFER_CODE_INVALID`. Do not
|
|
190
|
+
* add a code field to an iOS app (App Store 3.1.1); iOS users enter codes on the website.
|
|
191
|
+
*/
|
|
192
|
+
export type OfferCodeValidation = {
|
|
193
|
+
eligible?: boolean;
|
|
194
|
+
reason?: string | null;
|
|
195
|
+
platform?: "web" | "ios" | "android";
|
|
196
|
+
method?: OfferMethod | null;
|
|
197
|
+
redeem_on?: "web" | "app";
|
|
198
|
+
code?: { display: string; kind: "single_use" | "shared"; expires_at_unix?: number };
|
|
199
|
+
campaign?: OfferCampaign;
|
|
200
|
+
plan_ids?: string[];
|
|
201
|
+
platforms?: { web?: OfferCodeResult; ios?: OfferCodeResult; android?: OfferCodeResult };
|
|
157
202
|
};
|
|
158
203
|
|
|
159
204
|
/** `POST /v1/billing/offers/claim` response; `subscription` is set for `platform_grant`. */
|