@rocapine/react-native-onboarding 1.70.0 → 1.72.0
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/paywalls/types.d.ts +64 -1
- package/dist/paywalls/types.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.js +118 -11
- package/dist/products/adapters/expoIap.js.map +1 -1
- package/dist/steps/common.types.d.ts +2 -0
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +1 -0
- package/dist/steps/common.types.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/paywalls/types.ts +63 -1
- package/src/products/adapters/__tests__/expoIap.test.ts +210 -0
- package/src/products/adapters/expoIap.ts +121 -5
- package/src/steps/common.types.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type { Condition } from "./evaluateCondition";
|
|
|
16
16
|
export type { LeafCondition, ConditionGroup, ConditionValue, ConditionOperator, Branch, NextStep, } from "./steps/common.types";
|
|
17
17
|
export { BaseStepTypeSchema, LeafConditionSchema, ConditionGroupSchema, BranchSchema, NextStepSchema, ConditionOperatorSchema, ConditionValueSchema, UNARY_CONDITION_OPERATORS, isUnaryConditionOperator, ONBOARDING_END_STEP_ID, } from "./steps/common.types";
|
|
18
18
|
export * from "./products";
|
|
19
|
-
export type { Paywall, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, PresentErrorReason, } from "./paywalls/types";
|
|
19
|
+
export type { Paywall, PaywallCustomPayload, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, PresentErrorReason, } from "./paywalls/types";
|
|
20
20
|
export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
|
|
21
21
|
export type { PaywallContextValue } from "./paywalls/PaywallProvider";
|
|
22
22
|
export { usePaywall } from "./paywalls/usePaywall";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxF,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EACV,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,cAAc,YAAY,CAAC;AAE3B,YAAY,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,gCAA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C,wGAAA,UAAU,OAAA"}
|
package/dist/paywalls/types.d.ts
CHANGED
|
@@ -41,7 +41,62 @@ export type Paywall = {
|
|
|
41
41
|
stripe?: StripeProductRef;
|
|
42
42
|
}>;
|
|
43
43
|
configuration: Record<string, unknown> | null;
|
|
44
|
+
/**
|
|
45
|
+
* Who draws this paywall. `"elements"` (the default) renders the authored
|
|
46
|
+
* `elements` tree; `"custom"` hands it to a screen the HOST registered under
|
|
47
|
+
* `customScreenId` (see `PaywallHost`'s `customScreens` prop in the UI
|
|
48
|
+
* package), and `elements` is then ignored entirely.
|
|
49
|
+
*
|
|
50
|
+
* A property of the PAYWALL, not the moment — the same reasoning as
|
|
51
|
+
* `billing` above: one moment audience can weight an element-tree variant
|
|
52
|
+
* against a native-screen variant and ramp the change as an A/B test.
|
|
53
|
+
*
|
|
54
|
+
* OPTIONAL, and absent means `"elements"`. Not because the studio omits it
|
|
55
|
+
* (it always sends a value) but because a device on a NEW SDK can be talking
|
|
56
|
+
* to an OLDER `get-paywalls` that predates the field. Treating absent as
|
|
57
|
+
* `"custom"`, or as an error, would break every existing paywall on that
|
|
58
|
+
* pairing; treating it as `"elements"` is exactly the old behaviour.
|
|
59
|
+
*/
|
|
60
|
+
renderMode?: "elements" | "custom";
|
|
61
|
+
/**
|
|
62
|
+
* Which host-registered screen renders this paywall. Meaningful only when
|
|
63
|
+
* `renderMode` is `"custom"`.
|
|
64
|
+
*
|
|
65
|
+
* Nullable as well as optional: the studio accepts a custom paywall with no
|
|
66
|
+
* screen id (it warns rather than refusing), so an empty value is a state
|
|
67
|
+
* that genuinely arrives. `PaywallHost` reports it as
|
|
68
|
+
* `{ status: "error", reason: "unknown-custom-screen" }` rather than opening
|
|
69
|
+
* an empty full-screen Modal.
|
|
70
|
+
*/
|
|
71
|
+
customScreenId?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* The product map handed to that screen: slot key to per-platform store
|
|
74
|
+
* product id. This is the one thing a native paywall cannot get from
|
|
75
|
+
* anywhere else — the moment waterfall picked THIS variant, and which
|
|
76
|
+
* products it offers is an authoring decision, not something compiled into
|
|
77
|
+
* the app.
|
|
78
|
+
*
|
|
79
|
+
* Deliberately NOT the same thing as `products` above. Those slots exist to
|
|
80
|
+
* feed `{{product.<key>.price}}` interpolation into an element tree, and a
|
|
81
|
+
* custom screen has no interpolation — so a custom paywall carries product
|
|
82
|
+
* IDS and no prices, and the SDK resolves no store products for it at all
|
|
83
|
+
* (`collectProductRefs` does not walk this map). A native paywall asks the
|
|
84
|
+
* store for its own display prices, which is exactly what it does not need
|
|
85
|
+
* the studio for.
|
|
86
|
+
*/
|
|
87
|
+
customPayload?: PaywallCustomPayload;
|
|
44
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* `Paywall.customPayload` — slot key to per-platform product id.
|
|
91
|
+
*
|
|
92
|
+
* Both platform fields are optional: a paywall shipped on one platform only is
|
|
93
|
+
* legitimate, and so is a key whose ids have not been filled in yet (the
|
|
94
|
+
* studio warns about that rather than refusing to save it).
|
|
95
|
+
*/
|
|
96
|
+
export type PaywallCustomPayload = Record<string, {
|
|
97
|
+
ios?: string;
|
|
98
|
+
android?: string;
|
|
99
|
+
}>;
|
|
45
100
|
/** Full response body of `GET get-paywalls`. */
|
|
46
101
|
export type PaywallCatalog = {
|
|
47
102
|
metadata: {
|
|
@@ -147,8 +202,16 @@ export interface GetPaywallsResponseHeaders {
|
|
|
147
202
|
* Modal, a `presentation: "modal"` route, a StoreKit alert).
|
|
148
203
|
* - `paywall-disappeared` — the moment vanished from the catalog while it
|
|
149
204
|
* was on screen (a studio publish, or a query-key change mid-presentation).
|
|
205
|
+
* - `unknown-custom-screen` — the paywall is `renderMode: "custom"` and names
|
|
206
|
+
* a `customScreenId` this host did not register (or names none at all), so
|
|
207
|
+
* there was nothing to render and the Modal was never opened. Deliberately
|
|
208
|
+
* NOT folded into `parse-error`: that one is a CMS **data** bug the author
|
|
209
|
+
* must fix, this is a HOST **wiring** bug the app must fix — opposite
|
|
210
|
+
* remedies, and conflating them is the exact mistake this union's split
|
|
211
|
+
* already exists to avoid. `PaywallHost` logs both the missing id and the
|
|
212
|
+
* ids that ARE registered, which is usually the whole diagnosis.
|
|
150
213
|
*/
|
|
151
|
-
export type PresentErrorReason = "unknown-moment" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared";
|
|
214
|
+
export type PresentErrorReason = "unknown-moment" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared" | "unknown-custom-screen";
|
|
152
215
|
export type PresentResult = {
|
|
153
216
|
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
154
217
|
/** Why it failed. Set on `"error"` only — see `PresentErrorReason`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;;;;;OAQG;IACH,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;KAC3B,CAAC,CAAC;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAA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Ac,GAAG;IAC3B,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,0BAA0B;IACzC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;IAC1D,uEAAuE;IACvE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA8C,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA8C,MAAM,UAAU,CAAC;AA8D5F,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,GAAI,MAAK,GAAS,KAAG,eAgJvD,CAAC"}
|
|
@@ -23,6 +23,40 @@ const toPeriod = (iso) => {
|
|
|
23
23
|
// expo-iap surfaces a user cancellation as a code rather than a typed error.
|
|
24
24
|
const isCancellation = (e) => (e === null || e === void 0 ? void 0 : e.code) === "E_USER_CANCELLED" || (e === null || e === void 0 ? void 0 : e.code) === "USER_CANCELED" || (e === null || e === void 0 ? void 0 : e.userCancelled) === true;
|
|
25
25
|
const idFor = (ref) => react_native_1.Platform.OS === "ios" ? ref.ios : ref.android;
|
|
26
|
+
const ISO_UNIT = { day: "D", week: "W", month: "M", year: "Y" };
|
|
27
|
+
/**
|
|
28
|
+
* The store's billing period as an ISO-8601 duration.
|
|
29
|
+
*
|
|
30
|
+
* Load-bearing far beyond the `period` field: `deriveProductFields` computes
|
|
31
|
+
* `pricePerDay` / `pricePerWeek` / `pricePerMonth` / `pricePerYear` and
|
|
32
|
+
* `savingsPct` from `periodIso` alone. A null here does not degrade those — it
|
|
33
|
+
* removes them, so `{{product.yearly.pricePerWeek}}` renders EMPTY (an unknown
|
|
34
|
+
* variable interpolates to nothing, not to a literal) and a per-week-framed
|
|
35
|
+
* paywall silently loses its headline number.
|
|
36
|
+
*
|
|
37
|
+
* expo-iap has never exposed one ready-made, and the shape has moved:
|
|
38
|
+
* - ≤4.x published `subscriptionPeriodISO` / `subscriptionPeriod` on the product
|
|
39
|
+
* - 5.x publishes the iOS period SPLIT in two (`subscriptionPeriodUnitIOS`,
|
|
40
|
+
* `subscriptionPeriodNumberIOS`) and the Android one buried in the first
|
|
41
|
+
* pricing phase of the first subscription offer
|
|
42
|
+
* All three are read, newest-shape-last so an older peer keeps working.
|
|
43
|
+
*/
|
|
44
|
+
const periodIsoFrom = (s) => {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
46
|
+
const direct = (_a = s === null || s === void 0 ? void 0 : s.subscriptionPeriodISO) !== null && _a !== void 0 ? _a : s === null || s === void 0 ? void 0 : s.subscriptionPeriod;
|
|
47
|
+
if (typeof direct === "string" && direct)
|
|
48
|
+
return direct;
|
|
49
|
+
const unit = ISO_UNIT[String((_b = s === null || s === void 0 ? void 0 : s.subscriptionPeriodUnitIOS) !== null && _b !== void 0 ? _b : "").toLowerCase()];
|
|
50
|
+
if (unit) {
|
|
51
|
+
// `subscriptionPeriodNumberIOS` is typed as a STRING by expo-iap. Default to
|
|
52
|
+
// 1 rather than 0: StoreKit omits the count for a single-unit period, and
|
|
53
|
+
// "P0M" would make every derived price divide by zero.
|
|
54
|
+
const n = Number((_c = s === null || s === void 0 ? void 0 : s.subscriptionPeriodNumberIOS) !== null && _c !== void 0 ? _c : 1);
|
|
55
|
+
return `P${Number.isFinite(n) && n > 0 ? n : 1}${unit}`;
|
|
56
|
+
}
|
|
57
|
+
const androidPeriod = (_h = (_g = (_f = (_e = (_d = s === null || s === void 0 ? void 0 : s.subscriptionOffers) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.pricingPhasesAndroid) === null || _f === void 0 ? void 0 : _f.pricingPhaseList) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.billingPeriod;
|
|
58
|
+
return typeof androidPeriod === "string" && androidPeriod ? androidPeriod : null;
|
|
59
|
+
};
|
|
26
60
|
/** Direct StoreKit / Play Billing provider, no vendor in the path. */
|
|
27
61
|
const expoIapProductProvider = (Iap = IAP) => {
|
|
28
62
|
const required = () => {
|
|
@@ -31,32 +65,67 @@ const expoIapProductProvider = (Iap = IAP) => {
|
|
|
31
65
|
}
|
|
32
66
|
return Iap;
|
|
33
67
|
};
|
|
68
|
+
// Every expo-iap query fails until the store connection is open, and nothing
|
|
69
|
+
// opens it implicitly — `useIAP` does it for hook consumers, but this adapter
|
|
70
|
+
// is not a hook. Cached so concurrent getProducts/purchase/restore calls share
|
|
71
|
+
// one connect, and CLEARED on failure so a later call retries rather than
|
|
72
|
+
// replaying a rejected promise forever (a first call during airplane mode
|
|
73
|
+
// would otherwise poison the provider for the whole session).
|
|
74
|
+
let connecting = null;
|
|
75
|
+
const connect = async () => {
|
|
76
|
+
const M = required();
|
|
77
|
+
if (typeof M.initConnection !== "function")
|
|
78
|
+
return; // older peer: implicit connection
|
|
79
|
+
if (!connecting) {
|
|
80
|
+
connecting = Promise.resolve(M.initConnection()).catch((e) => {
|
|
81
|
+
connecting = null;
|
|
82
|
+
throw e;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
await connecting;
|
|
86
|
+
};
|
|
87
|
+
// The raw store product per resolved productId, captured during getProducts.
|
|
88
|
+
// `purchase()` needs expo-iap's own `type` discriminator ("in-app" | "subs")
|
|
89
|
+
// and the full Purchase to finish, neither of which survives the trip through
|
|
90
|
+
// `ResolvedProduct`. Same pattern as stripeLink's `linkByKey`.
|
|
91
|
+
const rawById = new Map();
|
|
34
92
|
return {
|
|
35
93
|
async getProducts(refs) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
95
|
const M = required();
|
|
38
96
|
const wanted = refs.map((r) => ({ ref: r, id: idFor(r) })).filter((x) => !!x.id);
|
|
39
97
|
if (wanted.length === 0)
|
|
40
98
|
return [];
|
|
99
|
+
await connect();
|
|
41
100
|
const skus = wanted.map((w) => w.id);
|
|
42
|
-
|
|
43
|
-
|
|
101
|
+
// 5.x renamed `getProducts(skus)` to `fetchProducts({ skus, type })` — an
|
|
102
|
+
// object arg, not a positional array. Calling the old name on 5.x throws
|
|
103
|
+
// "M.getProducts is not a function", so probe rather than assume; `"all"`
|
|
104
|
+
// because a paywall mixes subscriptions and one-off lifetime products.
|
|
105
|
+
const store = typeof M.fetchProducts === "function"
|
|
106
|
+
? await M.fetchProducts({ skus, type: "all" })
|
|
107
|
+
: await M.getProducts(skus);
|
|
108
|
+
const list = Array.isArray(store) ? store : [];
|
|
109
|
+
const byId = new Map(list.map((s) => { var _a; return [(_a = s.id) !== null && _a !== void 0 ? _a : s.productId, s]; }));
|
|
110
|
+
rawById.clear();
|
|
44
111
|
const out = [];
|
|
45
112
|
for (const { ref, id } of wanted) {
|
|
46
113
|
const s = byId.get(id);
|
|
47
114
|
if (!s)
|
|
48
115
|
continue;
|
|
49
|
-
const
|
|
116
|
+
const productId = (_a = s.id) !== null && _a !== void 0 ? _a : s.productId;
|
|
117
|
+
rawById.set(productId, s);
|
|
118
|
+
const iso = periodIsoFrom(s);
|
|
50
119
|
const { period, count } = toPeriod(iso);
|
|
51
120
|
out.push({
|
|
52
121
|
key: ref.key,
|
|
53
|
-
productId
|
|
122
|
+
productId,
|
|
54
123
|
store: react_native_1.Platform.OS === "ios" ? "app_store" : "play_store",
|
|
55
|
-
title: (
|
|
56
|
-
description: (
|
|
57
|
-
price: (
|
|
58
|
-
priceAmount: Number((
|
|
59
|
-
currencyCode: (
|
|
124
|
+
title: (_b = s.title) !== null && _b !== void 0 ? _b : "",
|
|
125
|
+
description: (_c = s.description) !== null && _c !== void 0 ? _c : "",
|
|
126
|
+
price: (_e = (_d = s.displayPrice) !== null && _d !== void 0 ? _d : s.localizedPrice) !== null && _e !== void 0 ? _e : "",
|
|
127
|
+
priceAmount: Number((_f = s.price) !== null && _f !== void 0 ? _f : 0),
|
|
128
|
+
currencyCode: (_h = (_g = s.currency) !== null && _g !== void 0 ? _g : s.currencyCode) !== null && _h !== void 0 ? _h : "",
|
|
60
129
|
period,
|
|
61
130
|
periodCount: count,
|
|
62
131
|
periodIso: iso,
|
|
@@ -65,9 +134,46 @@ const expoIapProductProvider = (Iap = IAP) => {
|
|
|
65
134
|
return out;
|
|
66
135
|
},
|
|
67
136
|
async purchase(product) {
|
|
137
|
+
var _a;
|
|
68
138
|
const M = required();
|
|
69
139
|
try {
|
|
70
|
-
await
|
|
140
|
+
await connect();
|
|
141
|
+
const raw = rawById.get(product.productId);
|
|
142
|
+
// A non-null period means a subscription even when the raw product is
|
|
143
|
+
// missing (a host that hydrated the runtime from elsewhere).
|
|
144
|
+
const isSubs = ((_a = raw === null || raw === void 0 ? void 0 : raw.type) !== null && _a !== void 0 ? _a : (product.period ? "subs" : "in-app")) === "subs";
|
|
145
|
+
const sku = product.productId;
|
|
146
|
+
// 5.x wants `{ request: { ios, android }, type }`. The old flat
|
|
147
|
+
// `{ request: { sku } }` reaches neither platform branch, so StoreKit is
|
|
148
|
+
// handed an undefined sku. `type` is required to tell a subscription
|
|
149
|
+
// from a one-off — Play rejects the wrong one outright.
|
|
150
|
+
const args = typeof M.fetchProducts === "function"
|
|
151
|
+
? {
|
|
152
|
+
request: { ios: { sku }, android: { skus: [sku] } },
|
|
153
|
+
type: isSubs ? "subs" : "in-app",
|
|
154
|
+
}
|
|
155
|
+
: { request: { sku } };
|
|
156
|
+
const result = await M.requestPurchase(args);
|
|
157
|
+
// `requestPurchase` resolves `Purchase | Purchase[] | null`. `null` is
|
|
158
|
+
// the normal 5.x outcome: the transaction is delivered to
|
|
159
|
+
// `purchaseUpdatedListener` instead, so at this point nothing is
|
|
160
|
+
// confirmed. Reporting "purchased" there would grant access for a
|
|
161
|
+
// purchase that may still fail — hence "pending", which is exactly the
|
|
162
|
+
// outcome `PurchaseButtonAction.onPending` exists to handle.
|
|
163
|
+
const purchase = Array.isArray(result) ? result[0] : result;
|
|
164
|
+
if (!purchase)
|
|
165
|
+
return { status: "pending" };
|
|
166
|
+
// Unfinished transactions are re-delivered by StoreKit on every launch
|
|
167
|
+
// until finished. Best-effort: a failure here does not un-buy anything,
|
|
168
|
+
// so it must not turn a completed purchase into an error.
|
|
169
|
+
if (typeof M.finishTransaction === "function") {
|
|
170
|
+
try {
|
|
171
|
+
await M.finishTransaction({ purchase, isConsumable: false });
|
|
172
|
+
}
|
|
173
|
+
catch (_b) {
|
|
174
|
+
// ignore — reported as purchased, will be re-delivered and finished later
|
|
175
|
+
}
|
|
176
|
+
}
|
|
71
177
|
return { status: "purchased", productKey: product.key };
|
|
72
178
|
}
|
|
73
179
|
catch (e) {
|
|
@@ -79,6 +185,7 @@ const expoIapProductProvider = (Iap = IAP) => {
|
|
|
79
185
|
async restore() {
|
|
80
186
|
const M = required();
|
|
81
187
|
try {
|
|
188
|
+
await connect();
|
|
82
189
|
const purchases = await M.getAvailablePurchases();
|
|
83
190
|
const ids = (purchases !== null && purchases !== void 0 ? purchases : []).map((p) => { var _a; return (_a = p.id) !== null && _a !== void 0 ? _a : p.productId; }).filter(Boolean);
|
|
84
191
|
return ids.length > 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoIap.js","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAGxC,gFAAgF;AAChF,IAAI,GAAQ,CAAC;AACb,IAAI,CAAC;IACH,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC5B,CAAC;AAAC,WAAM,CAAC;IACP,GAAG,GAAG,IAAI,CAAC;AACb,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAmD,EAAE;;IACnG,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC5C,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1C,MAAM,GAAG,GAAkC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3F,OAAO,EAAE,MAAM,EAAE,MAAA,GAAG,CAAC,CAAC,CAAC,CA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ACX,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnF,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAhJW,QAAA,sBAAsB,0BAgJjC"}
|
|
@@ -95,6 +95,8 @@ export type PurchaseButtonAction = {
|
|
|
95
95
|
onSuccess?: ButtonAction[];
|
|
96
96
|
onCancel?: ButtonAction[];
|
|
97
97
|
onError?: ButtonAction[];
|
|
98
|
+
/** Runs on `"pending"` — unconfirmed, not paid. A Stripe Payment Link always resolves this. */
|
|
99
|
+
onPending?: ButtonAction[];
|
|
98
100
|
};
|
|
99
101
|
export type RestoreButtonAction = {
|
|
100
102
|
type: "restore";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB,kEAA0C,CAAC;AAE3E,eAAO,MAAM,iBAAiB;;;;;;mBAS5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,aAAa;;;iBAGxB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAMH,eAAO,MAAM,iBAAiB;;;;;;;EAO5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAY5D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;iBAInC,CA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,oBAAoB,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAO1D,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;iBAGvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;mBAMX,CAAC;AACjB,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAIhD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa7B,CAAC"}
|
|
@@ -65,6 +65,7 @@ exports.PurchaseButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
|
65
65
|
onSuccess: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
66
66
|
onCancel: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
67
67
|
onError: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
68
|
+
onPending: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
68
69
|
}));
|
|
69
70
|
exports.RestoreButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
70
71
|
type: zod_1.z.literal("restore"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.types.js","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAE9D,QAAA,iBAAiB,GAAG,OAAC,CAAC,KAAK,CAAC;IACvC,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,OA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AC,GAAG,CAAC,CAAC,CAAC;IACtC,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,oBAAY,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5C,CAAC;KACD,QAAQ,EAAE;KACV,OAAO,CAAC,IAAI,CAAC,CAAC;AAGjB;;;;;;GAMG;AACU,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAEhD,iFAAiF;AAEpE,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,2EAA2E;IAC3E,qEAAqE;IACrE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,8BAAsB,EAAE;QACzD,OAAO,EAAE,IAAI,8BAAsB,8EAA8E;KAClH,CAAC;IACF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,OAAC,CAAC,OAAO,EAAE;IAClC,aAAa,EAAE,2BAAmB;IAClC,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,aAAa,EAAE,2BAAmB,CAAC,QAAQ,EAAE;IAC7C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC9B,QAAQ,EAAE,sBAAc;CACzB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.72.0",
|
|
4
4
|
"description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/index.ts
CHANGED
|
@@ -90,6 +90,9 @@ export * from "./products";
|
|
|
90
90
|
// Paywalls (paywall phase 5) — catalog types, provider, and the `usePaywall` hook
|
|
91
91
|
export type {
|
|
92
92
|
Paywall,
|
|
93
|
+
// Exported so a host's custom paywall screen can type the product map it
|
|
94
|
+
// receives without restating the shape.
|
|
95
|
+
PaywallCustomPayload,
|
|
93
96
|
PaywallCatalog,
|
|
94
97
|
PaywallOptions,
|
|
95
98
|
GetPaywallsResponseHeaders,
|
package/src/paywalls/types.ts
CHANGED
|
@@ -43,8 +43,61 @@ export type Paywall = {
|
|
|
43
43
|
stripe?: StripeProductRef;
|
|
44
44
|
}>;
|
|
45
45
|
configuration: Record<string, unknown> | null;
|
|
46
|
+
/**
|
|
47
|
+
* Who draws this paywall. `"elements"` (the default) renders the authored
|
|
48
|
+
* `elements` tree; `"custom"` hands it to a screen the HOST registered under
|
|
49
|
+
* `customScreenId` (see `PaywallHost`'s `customScreens` prop in the UI
|
|
50
|
+
* package), and `elements` is then ignored entirely.
|
|
51
|
+
*
|
|
52
|
+
* A property of the PAYWALL, not the moment — the same reasoning as
|
|
53
|
+
* `billing` above: one moment audience can weight an element-tree variant
|
|
54
|
+
* against a native-screen variant and ramp the change as an A/B test.
|
|
55
|
+
*
|
|
56
|
+
* OPTIONAL, and absent means `"elements"`. Not because the studio omits it
|
|
57
|
+
* (it always sends a value) but because a device on a NEW SDK can be talking
|
|
58
|
+
* to an OLDER `get-paywalls` that predates the field. Treating absent as
|
|
59
|
+
* `"custom"`, or as an error, would break every existing paywall on that
|
|
60
|
+
* pairing; treating it as `"elements"` is exactly the old behaviour.
|
|
61
|
+
*/
|
|
62
|
+
renderMode?: "elements" | "custom";
|
|
63
|
+
/**
|
|
64
|
+
* Which host-registered screen renders this paywall. Meaningful only when
|
|
65
|
+
* `renderMode` is `"custom"`.
|
|
66
|
+
*
|
|
67
|
+
* Nullable as well as optional: the studio accepts a custom paywall with no
|
|
68
|
+
* screen id (it warns rather than refusing), so an empty value is a state
|
|
69
|
+
* that genuinely arrives. `PaywallHost` reports it as
|
|
70
|
+
* `{ status: "error", reason: "unknown-custom-screen" }` rather than opening
|
|
71
|
+
* an empty full-screen Modal.
|
|
72
|
+
*/
|
|
73
|
+
customScreenId?: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* The product map handed to that screen: slot key to per-platform store
|
|
76
|
+
* product id. This is the one thing a native paywall cannot get from
|
|
77
|
+
* anywhere else — the moment waterfall picked THIS variant, and which
|
|
78
|
+
* products it offers is an authoring decision, not something compiled into
|
|
79
|
+
* the app.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately NOT the same thing as `products` above. Those slots exist to
|
|
82
|
+
* feed `{{product.<key>.price}}` interpolation into an element tree, and a
|
|
83
|
+
* custom screen has no interpolation — so a custom paywall carries product
|
|
84
|
+
* IDS and no prices, and the SDK resolves no store products for it at all
|
|
85
|
+
* (`collectProductRefs` does not walk this map). A native paywall asks the
|
|
86
|
+
* store for its own display prices, which is exactly what it does not need
|
|
87
|
+
* the studio for.
|
|
88
|
+
*/
|
|
89
|
+
customPayload?: PaywallCustomPayload;
|
|
46
90
|
};
|
|
47
91
|
|
|
92
|
+
/**
|
|
93
|
+
* `Paywall.customPayload` — slot key to per-platform product id.
|
|
94
|
+
*
|
|
95
|
+
* Both platform fields are optional: a paywall shipped on one platform only is
|
|
96
|
+
* legitimate, and so is a key whose ids have not been filled in yet (the
|
|
97
|
+
* studio warns about that rather than refusing to save it).
|
|
98
|
+
*/
|
|
99
|
+
export type PaywallCustomPayload = Record<string, { ios?: string; android?: string }>;
|
|
100
|
+
|
|
48
101
|
/** Full response body of `GET get-paywalls`. */
|
|
49
102
|
export type PaywallCatalog = {
|
|
50
103
|
metadata: {
|
|
@@ -153,6 +206,14 @@ export interface GetPaywallsResponseHeaders {
|
|
|
153
206
|
* Modal, a `presentation: "modal"` route, a StoreKit alert).
|
|
154
207
|
* - `paywall-disappeared` — the moment vanished from the catalog while it
|
|
155
208
|
* was on screen (a studio publish, or a query-key change mid-presentation).
|
|
209
|
+
* - `unknown-custom-screen` — the paywall is `renderMode: "custom"` and names
|
|
210
|
+
* a `customScreenId` this host did not register (or names none at all), so
|
|
211
|
+
* there was nothing to render and the Modal was never opened. Deliberately
|
|
212
|
+
* NOT folded into `parse-error`: that one is a CMS **data** bug the author
|
|
213
|
+
* must fix, this is a HOST **wiring** bug the app must fix — opposite
|
|
214
|
+
* remedies, and conflating them is the exact mistake this union's split
|
|
215
|
+
* already exists to avoid. `PaywallHost` logs both the missing id and the
|
|
216
|
+
* ids that ARE registered, which is usually the whole diagnosis.
|
|
156
217
|
*/
|
|
157
218
|
export type PresentErrorReason =
|
|
158
219
|
| "unknown-moment"
|
|
@@ -160,7 +221,8 @@ export type PresentErrorReason =
|
|
|
160
221
|
| "parse-error"
|
|
161
222
|
| "render-error"
|
|
162
223
|
| "host-never-presented"
|
|
163
|
-
| "paywall-disappeared"
|
|
224
|
+
| "paywall-disappeared"
|
|
225
|
+
| "unknown-custom-screen";
|
|
164
226
|
|
|
165
227
|
export type PresentResult = {
|
|
166
228
|
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
// The adapter imports `Platform` from react-native, whose entry point is Flow
|
|
4
|
+
// and cannot be parsed by vitest's transformer. Same one-line stub every other
|
|
5
|
+
// react-native-touching test in this package uses.
|
|
6
|
+
vi.mock("react-native", () => ({ Platform: { OS: "ios" } }));
|
|
7
|
+
|
|
8
|
+
import { expoIapProductProvider } from "../expoIap";
|
|
9
|
+
import type { ProductRef } from "../../types";
|
|
10
|
+
|
|
11
|
+
// The adapter resolves ids by platform and vitest runs the iOS branch of the
|
|
12
|
+
// `react-native` Platform shim, so every ref here carries `ios`.
|
|
13
|
+
const YEARLY: ProductRef = { key: "yearly", ios: "pro_yearly" };
|
|
14
|
+
const LIFETIME: ProductRef = { key: "lifetime", ios: "pro_lifetime" };
|
|
15
|
+
|
|
16
|
+
// A subscription as expo-iap 5.x actually reports it: the period is SPLIT into
|
|
17
|
+
// a unit and a stringly count, and there is no `subscriptionPeriodISO` at all.
|
|
18
|
+
const iap5Yearly = {
|
|
19
|
+
id: "pro_yearly",
|
|
20
|
+
type: "subs",
|
|
21
|
+
title: "Pro Yearly",
|
|
22
|
+
description: "Best value",
|
|
23
|
+
displayPrice: "$59.99",
|
|
24
|
+
price: 59.99,
|
|
25
|
+
currency: "USD",
|
|
26
|
+
subscriptionPeriodUnitIOS: "year",
|
|
27
|
+
subscriptionPeriodNumberIOS: "1",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const iap5Lifetime = {
|
|
31
|
+
id: "pro_lifetime",
|
|
32
|
+
type: "in-app",
|
|
33
|
+
title: "Lifetime",
|
|
34
|
+
description: "One time",
|
|
35
|
+
displayPrice: "$119.99",
|
|
36
|
+
price: 119.99,
|
|
37
|
+
currency: "USD",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const mock5 = (over: Record<string, any> = {}) => ({
|
|
41
|
+
initConnection: vi.fn().mockResolvedValue(true),
|
|
42
|
+
fetchProducts: vi.fn().mockResolvedValue([iap5Yearly, iap5Lifetime]),
|
|
43
|
+
requestPurchase: vi.fn().mockResolvedValue(null),
|
|
44
|
+
finishTransaction: vi.fn().mockResolvedValue(undefined),
|
|
45
|
+
getAvailablePurchases: vi.fn().mockResolvedValue([]),
|
|
46
|
+
...over,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("expoIapProductProvider — expo-iap 5.x API", () => {
|
|
50
|
+
it("calls fetchProducts, not the removed getProducts", async () => {
|
|
51
|
+
// 5.x deleted `getProducts`; calling it threw "M.getProducts is not a
|
|
52
|
+
// function" and every product silently failed to resolve. A mock with NO
|
|
53
|
+
// getProducts is what pins that.
|
|
54
|
+
const M = mock5();
|
|
55
|
+
const products = await expoIapProductProvider(M).getProducts([YEARLY, LIFETIME]);
|
|
56
|
+
expect(M.fetchProducts).toHaveBeenCalledWith({ skus: ["pro_yearly", "pro_lifetime"], type: "all" });
|
|
57
|
+
expect(products.map((p) => p.key)).toEqual(["yearly", "lifetime"]);
|
|
58
|
+
expect(products[0].price).toBe("$59.99");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("opens the store connection before querying, exactly once", async () => {
|
|
62
|
+
const M = mock5();
|
|
63
|
+
const provider = expoIapProductProvider(M);
|
|
64
|
+
await provider.getProducts([YEARLY]);
|
|
65
|
+
await provider.getProducts([YEARLY]);
|
|
66
|
+
await provider.restore();
|
|
67
|
+
expect(M.initConnection).toHaveBeenCalledTimes(1);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("retries the connection after a failed one instead of replaying the rejection", async () => {
|
|
71
|
+
// A first call while offline must not poison the provider for the session.
|
|
72
|
+
const initConnection = vi
|
|
73
|
+
.fn()
|
|
74
|
+
.mockRejectedValueOnce(new Error("offline"))
|
|
75
|
+
.mockResolvedValue(true);
|
|
76
|
+
const M = mock5({ initConnection });
|
|
77
|
+
const provider = expoIapProductProvider(M);
|
|
78
|
+
await expect(provider.getProducts([YEARLY])).rejects.toThrow("offline");
|
|
79
|
+
await expect(provider.getProducts([YEARLY])).resolves.toHaveLength(1);
|
|
80
|
+
expect(initConnection).toHaveBeenCalledTimes(2);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("derives periodIso from the split iOS fields", async () => {
|
|
84
|
+
// The whole point: `periodIso` feeds deriveProductFields, so a null here
|
|
85
|
+
// removes pricePerWeek/pricePerMonth/savingsPct rather than degrading them.
|
|
86
|
+
const [yearly, lifetime] = await expoIapProductProvider(mock5()).getProducts([YEARLY, LIFETIME]);
|
|
87
|
+
expect(yearly.periodIso).toBe("P1Y");
|
|
88
|
+
expect(yearly.period).toBe("year");
|
|
89
|
+
expect(yearly.periodCount).toBe(1);
|
|
90
|
+
// A one-off product has no period at all — not "P1Y" by accident.
|
|
91
|
+
expect(lifetime.periodIso).toBeNull();
|
|
92
|
+
expect(lifetime.period).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("defaults a missing period count to 1, never 0", async () => {
|
|
96
|
+
// StoreKit omits the count for a single-unit period. "P0M" would make every
|
|
97
|
+
// derived per-unit price divide by zero.
|
|
98
|
+
const M = mock5({
|
|
99
|
+
fetchProducts: vi.fn().mockResolvedValue([
|
|
100
|
+
{ ...iap5Yearly, subscriptionPeriodUnitIOS: "month", subscriptionPeriodNumberIOS: undefined },
|
|
101
|
+
]),
|
|
102
|
+
});
|
|
103
|
+
const [p] = await expoIapProductProvider(M).getProducts([YEARLY]);
|
|
104
|
+
expect(p.periodIso).toBe("P1M");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("reads the Android billing period out of the first pricing phase", async () => {
|
|
108
|
+
const M = mock5({
|
|
109
|
+
fetchProducts: vi.fn().mockResolvedValue([
|
|
110
|
+
{
|
|
111
|
+
id: "pro_yearly",
|
|
112
|
+
type: "subs",
|
|
113
|
+
displayPrice: "$59.99",
|
|
114
|
+
price: 59.99,
|
|
115
|
+
currency: "USD",
|
|
116
|
+
subscriptionOffers: [
|
|
117
|
+
{ pricingPhasesAndroid: { pricingPhaseList: [{ billingPeriod: "P1Y" }] } },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
]),
|
|
121
|
+
});
|
|
122
|
+
const [p] = await expoIapProductProvider(M).getProducts([YEARLY]);
|
|
123
|
+
expect(p.periodIso).toBe("P1Y");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("still honours a pre-5.x product that publishes the ISO period directly", async () => {
|
|
127
|
+
const M = mock5({
|
|
128
|
+
fetchProducts: vi
|
|
129
|
+
.fn()
|
|
130
|
+
.mockResolvedValue([{ ...iap5Yearly, subscriptionPeriodISO: "P6M", subscriptionPeriodUnitIOS: "year" }]),
|
|
131
|
+
});
|
|
132
|
+
const [p] = await expoIapProductProvider(M).getProducts([YEARLY]);
|
|
133
|
+
expect(p.periodIso).toBe("P6M");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("falls back to the legacy getProducts when fetchProducts is absent", async () => {
|
|
137
|
+
// A host pinned to expo-iap ≤4 must keep working.
|
|
138
|
+
const getProducts = vi.fn().mockResolvedValue([{ ...iap5Yearly, subscriptionPeriodISO: "P1Y" }]);
|
|
139
|
+
const M = { getProducts, requestPurchase: vi.fn(), getAvailablePurchases: vi.fn() };
|
|
140
|
+
const [p] = await expoIapProductProvider(M).getProducts([YEARLY]);
|
|
141
|
+
expect(getProducts).toHaveBeenCalledWith(["pro_yearly"]);
|
|
142
|
+
expect(p.periodIso).toBe("P1Y");
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe("expoIapProductProvider — purchase", () => {
|
|
147
|
+
const resolved = async (M: any) => (await expoIapProductProvider(M).getProducts([YEARLY]))[0];
|
|
148
|
+
|
|
149
|
+
it("sends the per-platform request shape with the subscription type", async () => {
|
|
150
|
+
// The old flat `{ request: { sku } }` reached neither platform branch, so
|
|
151
|
+
// StoreKit received an undefined sku.
|
|
152
|
+
const M = mock5({ requestPurchase: vi.fn().mockResolvedValue({ id: "tx" }) });
|
|
153
|
+
const provider = expoIapProductProvider(M);
|
|
154
|
+
const product = (await provider.getProducts([YEARLY]))[0];
|
|
155
|
+
await provider.purchase(product);
|
|
156
|
+
expect(M.requestPurchase).toHaveBeenCalledWith({
|
|
157
|
+
request: { ios: { sku: "pro_yearly" }, android: { skus: ["pro_yearly"] } },
|
|
158
|
+
type: "subs",
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("sends type in-app for a one-off product", async () => {
|
|
163
|
+
const M = mock5({ requestPurchase: vi.fn().mockResolvedValue({ id: "tx" }) });
|
|
164
|
+
const provider = expoIapProductProvider(M);
|
|
165
|
+
const product = (await provider.getProducts([LIFETIME]))[0];
|
|
166
|
+
await provider.purchase(product);
|
|
167
|
+
expect(M.requestPurchase.mock.calls[0][0].type).toBe("in-app");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("resolves pending — not purchased — when requestPurchase resolves null", async () => {
|
|
171
|
+
// The normal 5.x outcome: the transaction arrives via purchaseUpdatedListener,
|
|
172
|
+
// so nothing is confirmed yet. Reporting "purchased" granted access for a
|
|
173
|
+
// purchase that may still fail.
|
|
174
|
+
const M = mock5({ requestPurchase: vi.fn().mockResolvedValue(null) });
|
|
175
|
+
const provider = expoIapProductProvider(M);
|
|
176
|
+
const product = (await provider.getProducts([YEARLY]))[0];
|
|
177
|
+
expect(await provider.purchase(product)).toEqual({ status: "pending" });
|
|
178
|
+
expect(M.finishTransaction).not.toHaveBeenCalled();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("finishes the transaction when one comes back", async () => {
|
|
182
|
+
// Unfinished transactions are re-delivered by StoreKit on every launch.
|
|
183
|
+
const purchase = { id: "tx-1" };
|
|
184
|
+
const M = mock5({ requestPurchase: vi.fn().mockResolvedValue(purchase) });
|
|
185
|
+
const provider = expoIapProductProvider(M);
|
|
186
|
+
const product = (await provider.getProducts([YEARLY]))[0];
|
|
187
|
+
expect(await provider.purchase(product)).toEqual({ status: "purchased", productKey: "yearly" });
|
|
188
|
+
expect(M.finishTransaction).toHaveBeenCalledWith({ purchase, isConsumable: false });
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("still reports purchased when finishing throws", async () => {
|
|
192
|
+
// A finish failure does not un-buy anything; it must not become an error.
|
|
193
|
+
const M = mock5({
|
|
194
|
+
requestPurchase: vi.fn().mockResolvedValue({ id: "tx-1" }),
|
|
195
|
+
finishTransaction: vi.fn().mockRejectedValue(new Error("finish failed")),
|
|
196
|
+
});
|
|
197
|
+
const provider = expoIapProductProvider(M);
|
|
198
|
+
const product = (await provider.getProducts([YEARLY]))[0];
|
|
199
|
+
expect(await provider.purchase(product)).toEqual({ status: "purchased", productKey: "yearly" });
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("maps a user cancellation to cancelled, not error", async () => {
|
|
203
|
+
const M = mock5({
|
|
204
|
+
requestPurchase: vi.fn().mockRejectedValue({ code: "E_USER_CANCELLED" }),
|
|
205
|
+
});
|
|
206
|
+
const provider = expoIapProductProvider(M);
|
|
207
|
+
const product = (await provider.getProducts([YEARLY]))[0];
|
|
208
|
+
expect(await provider.purchase(product)).toEqual({ status: "cancelled" });
|
|
209
|
+
});
|
|
210
|
+
});
|
|
@@ -24,6 +24,43 @@ const isCancellation = (e: any): boolean =>
|
|
|
24
24
|
const idFor = (ref: ProductRef): string | undefined =>
|
|
25
25
|
Platform.OS === "ios" ? ref.ios : ref.android;
|
|
26
26
|
|
|
27
|
+
const ISO_UNIT: Record<string, string> = { day: "D", week: "W", month: "M", year: "Y" };
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The store's billing period as an ISO-8601 duration.
|
|
31
|
+
*
|
|
32
|
+
* Load-bearing far beyond the `period` field: `deriveProductFields` computes
|
|
33
|
+
* `pricePerDay` / `pricePerWeek` / `pricePerMonth` / `pricePerYear` and
|
|
34
|
+
* `savingsPct` from `periodIso` alone. A null here does not degrade those — it
|
|
35
|
+
* removes them, so `{{product.yearly.pricePerWeek}}` renders EMPTY (an unknown
|
|
36
|
+
* variable interpolates to nothing, not to a literal) and a per-week-framed
|
|
37
|
+
* paywall silently loses its headline number.
|
|
38
|
+
*
|
|
39
|
+
* expo-iap has never exposed one ready-made, and the shape has moved:
|
|
40
|
+
* - ≤4.x published `subscriptionPeriodISO` / `subscriptionPeriod` on the product
|
|
41
|
+
* - 5.x publishes the iOS period SPLIT in two (`subscriptionPeriodUnitIOS`,
|
|
42
|
+
* `subscriptionPeriodNumberIOS`) and the Android one buried in the first
|
|
43
|
+
* pricing phase of the first subscription offer
|
|
44
|
+
* All three are read, newest-shape-last so an older peer keeps working.
|
|
45
|
+
*/
|
|
46
|
+
const periodIsoFrom = (s: any): string | null => {
|
|
47
|
+
const direct = s?.subscriptionPeriodISO ?? s?.subscriptionPeriod;
|
|
48
|
+
if (typeof direct === "string" && direct) return direct;
|
|
49
|
+
|
|
50
|
+
const unit = ISO_UNIT[String(s?.subscriptionPeriodUnitIOS ?? "").toLowerCase()];
|
|
51
|
+
if (unit) {
|
|
52
|
+
// `subscriptionPeriodNumberIOS` is typed as a STRING by expo-iap. Default to
|
|
53
|
+
// 1 rather than 0: StoreKit omits the count for a single-unit period, and
|
|
54
|
+
// "P0M" would make every derived price divide by zero.
|
|
55
|
+
const n = Number(s?.subscriptionPeriodNumberIOS ?? 1);
|
|
56
|
+
return `P${Number.isFinite(n) && n > 0 ? n : 1}${unit}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const androidPeriod =
|
|
60
|
+
s?.subscriptionOffers?.[0]?.pricingPhasesAndroid?.pricingPhaseList?.[0]?.billingPeriod;
|
|
61
|
+
return typeof androidPeriod === "string" && androidPeriod ? androidPeriod : null;
|
|
62
|
+
};
|
|
63
|
+
|
|
27
64
|
/** Direct StoreKit / Play Billing provider, no vendor in the path. */
|
|
28
65
|
export const expoIapProductProvider = (Iap: any = IAP): ProductProvider => {
|
|
29
66
|
const required = () => {
|
|
@@ -35,23 +72,62 @@ export const expoIapProductProvider = (Iap: any = IAP): ProductProvider => {
|
|
|
35
72
|
return Iap;
|
|
36
73
|
};
|
|
37
74
|
|
|
75
|
+
// Every expo-iap query fails until the store connection is open, and nothing
|
|
76
|
+
// opens it implicitly — `useIAP` does it for hook consumers, but this adapter
|
|
77
|
+
// is not a hook. Cached so concurrent getProducts/purchase/restore calls share
|
|
78
|
+
// one connect, and CLEARED on failure so a later call retries rather than
|
|
79
|
+
// replaying a rejected promise forever (a first call during airplane mode
|
|
80
|
+
// would otherwise poison the provider for the whole session).
|
|
81
|
+
let connecting: Promise<unknown> | null = null;
|
|
82
|
+
const connect = async () => {
|
|
83
|
+
const M = required();
|
|
84
|
+
if (typeof M.initConnection !== "function") return; // older peer: implicit connection
|
|
85
|
+
if (!connecting) {
|
|
86
|
+
connecting = Promise.resolve(M.initConnection()).catch((e: unknown) => {
|
|
87
|
+
connecting = null;
|
|
88
|
+
throw e;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
await connecting;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// The raw store product per resolved productId, captured during getProducts.
|
|
95
|
+
// `purchase()` needs expo-iap's own `type` discriminator ("in-app" | "subs")
|
|
96
|
+
// and the full Purchase to finish, neither of which survives the trip through
|
|
97
|
+
// `ResolvedProduct`. Same pattern as stripeLink's `linkByKey`.
|
|
98
|
+
const rawById = new Map<string, any>();
|
|
99
|
+
|
|
38
100
|
return {
|
|
39
101
|
async getProducts(refs: ProductRef[]): Promise<ResolvedProduct[]> {
|
|
40
102
|
const M = required();
|
|
41
103
|
const wanted = refs.map((r) => ({ ref: r, id: idFor(r) })).filter((x) => !!x.id);
|
|
42
104
|
if (wanted.length === 0) return [];
|
|
105
|
+
await connect();
|
|
43
106
|
const skus = wanted.map((w) => w.id as string);
|
|
44
|
-
|
|
45
|
-
|
|
107
|
+
|
|
108
|
+
// 5.x renamed `getProducts(skus)` to `fetchProducts({ skus, type })` — an
|
|
109
|
+
// object arg, not a positional array. Calling the old name on 5.x throws
|
|
110
|
+
// "M.getProducts is not a function", so probe rather than assume; `"all"`
|
|
111
|
+
// because a paywall mixes subscriptions and one-off lifetime products.
|
|
112
|
+
const store =
|
|
113
|
+
typeof M.fetchProducts === "function"
|
|
114
|
+
? await M.fetchProducts({ skus, type: "all" })
|
|
115
|
+
: await M.getProducts(skus);
|
|
116
|
+
|
|
117
|
+
const list: any[] = Array.isArray(store) ? store : [];
|
|
118
|
+
const byId = new Map<string, any>(list.map((s: any) => [s.id ?? s.productId, s]));
|
|
119
|
+
rawById.clear();
|
|
46
120
|
const out: ResolvedProduct[] = [];
|
|
47
121
|
for (const { ref, id } of wanted) {
|
|
48
122
|
const s = byId.get(id as string);
|
|
49
123
|
if (!s) continue;
|
|
50
|
-
const
|
|
124
|
+
const productId = s.id ?? s.productId;
|
|
125
|
+
rawById.set(productId, s);
|
|
126
|
+
const iso = periodIsoFrom(s);
|
|
51
127
|
const { period, count } = toPeriod(iso);
|
|
52
128
|
out.push({
|
|
53
129
|
key: ref.key,
|
|
54
|
-
productId
|
|
130
|
+
productId,
|
|
55
131
|
store: Platform.OS === "ios" ? "app_store" : "play_store",
|
|
56
132
|
title: s.title ?? "",
|
|
57
133
|
description: s.description ?? "",
|
|
@@ -69,7 +145,46 @@ export const expoIapProductProvider = (Iap: any = IAP): ProductProvider => {
|
|
|
69
145
|
async purchase(product) {
|
|
70
146
|
const M = required();
|
|
71
147
|
try {
|
|
72
|
-
await
|
|
148
|
+
await connect();
|
|
149
|
+
const raw = rawById.get(product.productId);
|
|
150
|
+
// A non-null period means a subscription even when the raw product is
|
|
151
|
+
// missing (a host that hydrated the runtime from elsewhere).
|
|
152
|
+
const isSubs = (raw?.type ?? (product.period ? "subs" : "in-app")) === "subs";
|
|
153
|
+
const sku = product.productId;
|
|
154
|
+
|
|
155
|
+
// 5.x wants `{ request: { ios, android }, type }`. The old flat
|
|
156
|
+
// `{ request: { sku } }` reaches neither platform branch, so StoreKit is
|
|
157
|
+
// handed an undefined sku. `type` is required to tell a subscription
|
|
158
|
+
// from a one-off — Play rejects the wrong one outright.
|
|
159
|
+
const args =
|
|
160
|
+
typeof M.fetchProducts === "function"
|
|
161
|
+
? {
|
|
162
|
+
request: { ios: { sku }, android: { skus: [sku] } },
|
|
163
|
+
type: isSubs ? "subs" : "in-app",
|
|
164
|
+
}
|
|
165
|
+
: { request: { sku } };
|
|
166
|
+
|
|
167
|
+
const result = await M.requestPurchase(args as any);
|
|
168
|
+
|
|
169
|
+
// `requestPurchase` resolves `Purchase | Purchase[] | null`. `null` is
|
|
170
|
+
// the normal 5.x outcome: the transaction is delivered to
|
|
171
|
+
// `purchaseUpdatedListener` instead, so at this point nothing is
|
|
172
|
+
// confirmed. Reporting "purchased" there would grant access for a
|
|
173
|
+
// purchase that may still fail — hence "pending", which is exactly the
|
|
174
|
+
// outcome `PurchaseButtonAction.onPending` exists to handle.
|
|
175
|
+
const purchase = Array.isArray(result) ? result[0] : result;
|
|
176
|
+
if (!purchase) return { status: "pending" };
|
|
177
|
+
|
|
178
|
+
// Unfinished transactions are re-delivered by StoreKit on every launch
|
|
179
|
+
// until finished. Best-effort: a failure here does not un-buy anything,
|
|
180
|
+
// so it must not turn a completed purchase into an error.
|
|
181
|
+
if (typeof M.finishTransaction === "function") {
|
|
182
|
+
try {
|
|
183
|
+
await M.finishTransaction({ purchase, isConsumable: false });
|
|
184
|
+
} catch {
|
|
185
|
+
// ignore — reported as purchased, will be re-delivered and finished later
|
|
186
|
+
}
|
|
187
|
+
}
|
|
73
188
|
return { status: "purchased", productKey: product.key };
|
|
74
189
|
} catch (e: any) {
|
|
75
190
|
if (isCancellation(e)) return { status: "cancelled" };
|
|
@@ -80,6 +195,7 @@ export const expoIapProductProvider = (Iap: any = IAP): ProductProvider => {
|
|
|
80
195
|
async restore() {
|
|
81
196
|
const M = required();
|
|
82
197
|
try {
|
|
198
|
+
await connect();
|
|
83
199
|
const purchases = await M.getAvailablePurchases();
|
|
84
200
|
const ids: string[] = (purchases ?? []).map((p: any) => p.id ?? p.productId).filter(Boolean);
|
|
85
201
|
return ids.length > 0
|
|
@@ -112,6 +112,8 @@ export type PurchaseButtonAction = {
|
|
|
112
112
|
onSuccess?: ButtonAction[];
|
|
113
113
|
onCancel?: ButtonAction[];
|
|
114
114
|
onError?: ButtonAction[];
|
|
115
|
+
/** Runs on `"pending"` — unconfirmed, not paid. A Stripe Payment Link always resolves this. */
|
|
116
|
+
onPending?: ButtonAction[];
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
export type RestoreButtonAction = {
|
|
@@ -162,6 +164,7 @@ export const PurchaseButtonActionSchema: z.ZodType<PurchaseButtonAction> = z.laz
|
|
|
162
164
|
onSuccess: z.array(ButtonActionSchema).optional(),
|
|
163
165
|
onCancel: z.array(ButtonActionSchema).optional(),
|
|
164
166
|
onError: z.array(ButtonActionSchema).optional(),
|
|
167
|
+
onPending: z.array(ButtonActionSchema).optional(),
|
|
165
168
|
})
|
|
166
169
|
);
|
|
167
170
|
|