@leisuresaas/react-native 0.6.12-dev.2 → 0.6.12-dev.4
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 +14 -0
- package/src/index.ts +6 -0
- package/src/types.ts +82 -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.4",
|
|
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,20 @@ 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
|
+
/** P5: the campaign's Apple code pools are not for the user's App Store subscription. */
|
|
71
|
+
OfferAppleCodePoolNotEligible: "OFFER_APPLE_CODE_POOL_NOT_ELIGIBLE",
|
|
72
|
+
/** P5: a code entered in the iOS app while the platform has in-app code entry off; hide the field. */
|
|
73
|
+
OfferInAppCodeEntryDisabled: "OFFER_IN_APP_CODE_ENTRY_DISABLED",
|
|
74
|
+
OfferAppleCodePoolNewUsersOnly: "OFFER_APPLE_CODE_POOL_NEW_USERS_ONLY",
|
|
61
75
|
// apple_intro claim: the product has no App Store In-App Purchase key.
|
|
62
76
|
StoreNotConfigured: "STORE_NOT_CONFIGURED",
|
|
63
77
|
// 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,17 +124,57 @@ export type Offer = {
|
|
|
122
124
|
promotional_signature?: ApplePromotionalSignature;
|
|
123
125
|
/** apple_promotional: for `promotionalOffer(_:compactJWS:)`. */
|
|
124
126
|
promotional_offer_jws?: string;
|
|
127
|
+
/**
|
|
128
|
+
* apple_offer_code_pool code redeem only: App Store link for `apple_code`. In the app (R-1125-1
|
|
129
|
+
* P5): production opens `redeem_url` (`Linking.openURL`); sandbox codes do not work in the link,
|
|
130
|
+
* so copy `apple_code` and show Apple's offer code redeem sheet from your StoreKit library.
|
|
131
|
+
*/
|
|
132
|
+
redeem_url?: string;
|
|
133
|
+
apple_code?: string;
|
|
134
|
+
/** P5, apple_offer_code_pool: the user's App Store category the pool was picked by. */
|
|
135
|
+
apple_category?: AppleCategory;
|
|
136
|
+
/** P5: when the offer starts once bought or redeemed; say so before opening the App Store. */
|
|
137
|
+
applies?: OfferApplies;
|
|
138
|
+
/** P5: with `next_renewal`, the current App Store period end. */
|
|
139
|
+
applies_at_unix?: number;
|
|
125
140
|
};
|
|
126
141
|
/**
|
|
127
142
|
* Claims on ios / android: the user's fixed account token for the product (lowercase UUID). Pass it
|
|
128
143
|
* as Apple `appAccountToken` / Google `obfuscatedAccountId` on every purchase.
|
|
129
144
|
*/
|
|
130
145
|
account_token?: string;
|
|
146
|
+
/**
|
|
147
|
+
* `code` = a promo code campaign. It is listed only while the user holds a redemption from a code
|
|
148
|
+
* redeemed on the website; claim it as usual.
|
|
149
|
+
*/
|
|
150
|
+
entry?: "automatic" | "code";
|
|
151
|
+
/** Promo code campaigns: the code the user redeemed, masked ("SPRING-••••-••••-PT"). Show as a hint. */
|
|
152
|
+
code?: { display: string };
|
|
131
153
|
};
|
|
132
154
|
|
|
155
|
+
/** Where the user entered a promo code (R-1125-1 P5). Send `app` from an in-app code field. */
|
|
156
|
+
export type OfferCodeSource = "app" | "web";
|
|
157
|
+
|
|
158
|
+
/** Apple customer category of an offer code (new, current or expired subscriber). */
|
|
159
|
+
export type AppleCategory = "new" | "existing" | "expired";
|
|
160
|
+
|
|
161
|
+
/** `next_renewal`: a current App Store subscriber's code or promotional offer starts at the renewal. */
|
|
162
|
+
export type OfferApplies = "now" | "next_renewal";
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* ios `redeem_on`: `web` (Apple code pool link on the website), `app` (signed purchase in the app),
|
|
166
|
+
* `app_store` (P5, `source: app`: the app opens the App Store redeem page).
|
|
167
|
+
*/
|
|
168
|
+
export type OfferRedeemOn = "web" | "app" | "app_store";
|
|
169
|
+
|
|
133
170
|
/** `GET /v1/billing/offers` response. */
|
|
134
171
|
export type OfferList = {
|
|
135
172
|
offers: Offer[];
|
|
173
|
+
/**
|
|
174
|
+
* P5, ios with the app's bundle id: whether the platform lets this App Store app take promo codes
|
|
175
|
+
* (`source: app`). Show a code field only when true.
|
|
176
|
+
*/
|
|
177
|
+
ios_in_app_code_entry?: boolean;
|
|
136
178
|
/** ios with `app_transaction_id` and no `apple_intro` offer: a "no trial" JWS per App Store product. */
|
|
137
179
|
apple_intro_ineligible?: { store_product_id: string; jws: string }[];
|
|
138
180
|
};
|
|
@@ -154,6 +196,44 @@ export type OfferRedemption = {
|
|
|
154
196
|
created_at_unix?: number;
|
|
155
197
|
used_at_unix?: number;
|
|
156
198
|
released_at_unix?: number;
|
|
199
|
+
/** Promo code campaigns: the code redeemed and its masked display. */
|
|
200
|
+
code_id?: string;
|
|
201
|
+
code_display?: string;
|
|
202
|
+
/** P5: where the code was entered. */
|
|
203
|
+
source?: OfferCodeSource;
|
|
204
|
+
apple_category?: AppleCategory;
|
|
205
|
+
applies?: OfferApplies;
|
|
206
|
+
applies_at_unix?: number;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* One platform's answer for a promo code (`POST /v1/billing/offers/codes/validate`). `redeem_on` is
|
|
211
|
+
* ios only (`OfferRedeemOn`).
|
|
212
|
+
*/
|
|
213
|
+
export type OfferCodeResult = {
|
|
214
|
+
eligible: boolean;
|
|
215
|
+
reason?: string | null;
|
|
216
|
+
method?: OfferMethod | null;
|
|
217
|
+
redeem_on?: OfferRedeemOn;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Validate response as the BFF passes it through from sdk/go `ValidateOfferCode`. Always 200: an
|
|
222
|
+
* unusable code is `eligible: false` with a `reason`. With `platform` the top-level fields are that
|
|
223
|
+
* platform's; `code`, `campaign`, `plan_ids`, `platforms` are absent for `OFFER_CODE_INVALID`. An
|
|
224
|
+
* iOS app may have a code field only while `OfferList.ios_in_app_code_entry` is true (R-1125-1 P5);
|
|
225
|
+
* with `source: app` and the switch off the answer is `OFFER_IN_APP_CODE_ENTRY_DISABLED`.
|
|
226
|
+
*/
|
|
227
|
+
export type OfferCodeValidation = {
|
|
228
|
+
eligible?: boolean;
|
|
229
|
+
reason?: string | null;
|
|
230
|
+
platform?: "web" | "ios" | "android";
|
|
231
|
+
method?: OfferMethod | null;
|
|
232
|
+
redeem_on?: OfferRedeemOn;
|
|
233
|
+
code?: { display: string; kind: "single_use" | "shared"; expires_at_unix?: number };
|
|
234
|
+
campaign?: OfferCampaign;
|
|
235
|
+
plan_ids?: string[];
|
|
236
|
+
platforms?: { web?: OfferCodeResult; ios?: OfferCodeResult; android?: OfferCodeResult };
|
|
157
237
|
};
|
|
158
238
|
|
|
159
239
|
/** `POST /v1/billing/offers/claim` response; `subscription` is set for `platform_grant`. */
|