expo-superwall 0.5.0 → 0.5.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/CHANGELOG.md +8 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/expo/modules/superwallexpo/json/RedemptionResult.kt +1 -0
- package/build/package.json +1 -1
- package/build/src/CustomPurchaseControllerProvider.d.ts.map +1 -1
- package/build/src/CustomPurchaseControllerProvider.js +6 -4
- package/build/src/CustomPurchaseControllerProvider.js.map +1 -1
- package/build/src/compat/lib/RedemptionResults.d.ts +2 -0
- package/build/src/compat/lib/RedemptionResults.d.ts.map +1 -1
- package/build/src/compat/lib/RedemptionResults.js +1 -0
- package/build/src/compat/lib/RedemptionResults.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -43,7 +43,7 @@ android {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
dependencies {
|
|
46
|
-
implementation "com.superwall.sdk:superwall-android:2.6.
|
|
46
|
+
implementation "com.superwall.sdk:superwall-android:2.6.3"
|
|
47
47
|
implementation 'com.android.billingclient:billing:8.0.0'
|
|
48
48
|
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2'
|
|
49
49
|
}
|
package/build/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPurchaseControllerProvider.d.ts","sourceRoot":"","sources":["../../src/CustomPurchaseControllerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAKnE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,UA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,UAAU,EAAE,+BAA+B,CAAA;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,GAAI,2BAG9C,qCAAqC,gCAyCvC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,8CAIvC,CAAA"}
|
|
@@ -21,9 +21,10 @@ export const CustomPurchaseControllerProvider = ({ children, controller, }) => {
|
|
|
21
21
|
onPurchase: async (params) => {
|
|
22
22
|
try {
|
|
23
23
|
const result = await controller.onPurchase(params);
|
|
24
|
+
const type = result?.type ?? "purchased";
|
|
24
25
|
SuperwallExpoModule.didPurchase({
|
|
25
|
-
type
|
|
26
|
-
|
|
26
|
+
type,
|
|
27
|
+
...(type === "failed" && { error: result?.error || "Unknown error" }),
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
catch (error) {
|
|
@@ -36,9 +37,10 @@ export const CustomPurchaseControllerProvider = ({ children, controller, }) => {
|
|
|
36
37
|
onPurchaseRestore: async () => {
|
|
37
38
|
try {
|
|
38
39
|
const result = await controller.onPurchaseRestore();
|
|
40
|
+
const resultType = result?.type ?? "restored";
|
|
39
41
|
SuperwallExpoModule.didRestore({
|
|
40
|
-
result:
|
|
41
|
-
|
|
42
|
+
result: resultType,
|
|
43
|
+
...(resultType === "failed" && { errorMessage: result?.error || "Unknown error" }),
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPurchaseControllerProvider.js","sourceRoot":"","sources":["../../src/CustomPurchaseControllerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,+BAA+B,GAAG,aAAa,CAAyC,IAAI,CAAC,CAAA;AAsCnG;;;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AO,IAAI,eAAe;iBACzC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,iBAAiB,EAAE,KAAK,IAAI,EAAE;YAC5B,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAA;gBACnD,MAAM,UAAU,GAAG,MAAM,EAAE,IAAI,IAAI,UAAU,CAAA;gBAE7C,mBAAmB,CAAC,UAAU,CAAC;oBAC7B,MAAM,EAAE,UAAU;oBAClB,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;iBACnF,CAAC,CAAA;YACJ,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,mBAAmB,CAAC,UAAU,CAAC;oBAC7B,MAAM,EAAE,QAAQ;oBAChB,YAAY,EAAE,KAAK,EAAE,OAAO,IAAI,eAAe;iBAChD,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,CACL,CAAC,+BAA+B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAC1D;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,+BAA+B,CAAC,QAAQ,CAAC,CAC5C,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,+BAA+B,CAAC,CAAA;IAE3D,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { createContext, useContext } from \"react\"\nimport SuperwallExpoModule from \"./SuperwallExpoModule\"\nimport type { OnPurchaseParams } from \"./SuperwallExpoModule.types\"\nimport { useSuperwallEvents } from \"./useSuperwallEvents\"\n\nconst customPurchaseControllerContext = createContext<CustomPurchaseControllerContext | null>(null)\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n */\nexport type PurchaseResult = {\n type: \"cancelled\" | \"failed\" | \"purchased\" | \"pending\"\n error?: string\n}\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n */\nexport type RestoreResult = {\n type: \"restored\" | \"failed\"\n error?: string\n}\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n */\nexport interface CustomPurchaseControllerContext {\n onPurchase: (params: OnPurchaseParams) => Promise<PurchaseResult | undefined>\n onPurchaseRestore: () => Promise<RestoreResult | undefined>\n}\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n */\nexport interface CustomPurchaseControllerProviderProps {\n children: React.ReactNode\n controller: CustomPurchaseControllerContext\n}\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n * Provider component for custom purchase controller logic.\n *\n * This component allows you to integrate your own purchase handling logic\n * with the Superwall SDK. It listens for purchase and restore events from\n * Superwall and delegates them to the provided `controller`.\n *\n * @param props - The properties for the CustomPurchaseControllerProvider.\n * @param props.children - The child components that will be wrapped by this provider.\n * @param props.controller - An object implementing the `CustomPurchaseControllerContext`\n * interface, which defines how to handle purchases and restores.\n */\nexport const CustomPurchaseControllerProvider = ({\n children,\n controller,\n}: CustomPurchaseControllerProviderProps) => {\n useSuperwallEvents({\n onPurchase: async (params) => {\n try {\n const result = await controller.onPurchase(params)\n const type = result?.type ?? \"purchased\"\n\n SuperwallExpoModule.didPurchase({\n type,\n ...(type === \"failed\" && { error: result?.error || \"Unknown error\" }),\n })\n } catch (error: any) {\n SuperwallExpoModule.didPurchase({\n type: \"failed\",\n error: error?.message || \"Unknown error\",\n })\n }\n },\n onPurchaseRestore: async () => {\n try {\n const result = await controller.onPurchaseRestore()\n const resultType = result?.type ?? \"restored\"\n\n SuperwallExpoModule.didRestore({\n result: resultType,\n ...(resultType === \"failed\" && { errorMessage: result?.error || \"Unknown error\" }),\n })\n } catch (error: any) {\n SuperwallExpoModule.didRestore({\n result: \"failed\",\n errorMessage: error?.message || \"Unknown error\",\n })\n }\n },\n })\n\n return (\n <customPurchaseControllerContext.Provider value={controller}>\n {children}\n </customPurchaseControllerContext.Provider>\n )\n}\n\n/**\n * @category Purchase Controller\n * @since 0.0.15\n * Hook to access the custom purchase controller context.\n *\n * This hook provides access to the `controller` object that was passed\n * to the `CustomPurchaseControllerProvider`. It can be used by child\n * components to trigger purchase or restore flows using the custom logic.\n *\n * @returns The `CustomPurchaseControllerContext` object, or `null` if not\n * used within a `CustomPurchaseControllerProvider`.\n */\nexport const useCustomPurchaseController = () => {\n const context = useContext(customPurchaseControllerContext)\n\n return context\n}\n"]}
|
|
@@ -81,6 +81,8 @@ export interface PaywallInfo {
|
|
|
81
81
|
variantId: string;
|
|
82
82
|
/** The ID of the experiment that the paywall belongs to */
|
|
83
83
|
experimentId: string;
|
|
84
|
+
/** The product identifier that the user purchased */
|
|
85
|
+
productIdentifier?: string;
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
86
88
|
* @category Models
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedemptionResults.d.ts","sourceRoot":"","sources":["../../../../src/compat/lib/RedemptionResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,MAAM,EAAE,OAAO,CAAA;IACf,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAExC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,KAAK,EAAE,QAAQ,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAChC,GACD;IACE,KAAK,EAAE,QAAQ,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,qBAAqB,EAAE,MAAM,EAAE,CAAA;CAChC,GACD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+DAA+D;IAC/D,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAA;IACrB,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"RedemptionResults.d.ts","sourceRoot":"","sources":["../../../../src/compat/lib/RedemptionResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,MAAM,EAAE,OAAO,CAAA;IACf,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,UAAU,CAAC;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WAAW,EAAE,CAAA;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAAE,GACnE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC;IACE,MAAM,EAAE,sBAAsB,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,cAAc,CAAA;CAC/B,CAAA;AAEL;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,gBAAgB;IAgD5C,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsBlC,OAAO,CAAC,MAAM,CAAC,cAAc;IAmB7B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAajC,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAWrC"}
|
|
@@ -65,6 +65,7 @@ export class RedemptionResults {
|
|
|
65
65
|
placementParams: json.paywallInfo.placementParams || {},
|
|
66
66
|
variantId: json.paywallInfo.variantId,
|
|
67
67
|
experimentId: json.paywallInfo.experimentId,
|
|
68
|
+
productIdentifier: json.paywallInfo.productIdentifier || undefined
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedemptionResults.js","sourceRoot":"","sources":["../../../../src/compat/lib/RedemptionResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eA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MAAM,GAAkB;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,gBAAgB,CAAC;SACjF,CAAA;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAC3B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,IAAS;QAC5C,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO;gBACL,KAAK,EAAE,QAAQ;gBACf,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,IAAI,EAAE;aACxD,CAAA;QACH,CAAC;QAED,OAAO,EAAE,GAAG,IAAI,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["/**\n * RedemptionResult and related types\n * Corresponds to the Swift RedemptionResult enum and its associated types\n */\n\nimport { Entitlement } from \"./Entitlement\"\n\n/**\n * @category Models\n * @since 0.0.15\n * Information about an error that occurred during code redemption\n */\nexport interface ErrorInfo {\n /** The error message */\n message: string\n}\n\n/**\n * @category Models\n * @since 0.0.15\n * Information about an expired redemption code\n */\nexport interface ExpiredCodeInfo {\n /** Whether the redemption email was resent */\n resent: boolean\n /** Optional obfuscated email address that the redemption email was sent to */\n obfuscatedEmail?: string\n}\n\n/**\n * @category Types\n * @since 0.0.15\n * Represents the ownership of a redemption code\n */\nexport type Ownership =\n | { type: \"APP_USER\"; appUserId: string }\n | { type: \"DEVICE\"; deviceId: string }\n\n/**\n * @category Types\n * @since 0.0.15\n * Store identifiers for the purchase\n */\nexport type StoreIdentifiers =\n | {\n store: \"STRIPE\"\n stripeCustomerId: string\n stripeSubscriptionIds: string[]\n }\n | {\n store: \"PADDLE\"\n paddleCustomerId: string\n paddleSubscriptionIds: string[]\n }\n | { store: string; [key: string]: any } // For unknown store types\n\n/**\n * @category Models\n * @since 0.0.15\n * Information about the purchaser\n */\nexport interface PurchaserInfo {\n /** The app user ID of the purchaser */\n appUserId: string\n /** The email address of the purchaser (optional) */\n email?: string\n /** The identifiers for the store the purchase was made from */\n storeIdentifiers: StoreIdentifiers\n}\n\n/**\n * @category Models\n * @since 0.0.15\n * Information about the paywall the purchase was made from\n */\nexport interface PaywallInfo {\n /** The identifier of the paywall */\n identifier: string\n /** The name of the placement */\n placementName: string\n /** The params of the placement */\n placementParams: Record<string, any>\n /** The ID of the paywall variant */\n variantId: string\n /** The ID of the experiment that the paywall belongs to */\n experimentId: string\n /** The product identifier that the user purchased */\n productIdentifier?: string \n}\n\n/**\n * @category Models\n * @since 0.0.15\n * Information about a successful redemption\n */\nexport interface RedemptionInfo {\n /** The ownership of the code */\n ownership: Ownership\n /** Information about the purchaser */\n purchaserInfo: PurchaserInfo\n /** Information about the paywall the purchase was made from (optional) */\n paywallInfo?: PaywallInfo\n /** The entitlements granted by the redemption */\n entitlements: Entitlement[]\n}\n\n/**\n * @category Types\n * @since 0.0.15\n * The result of redeeming a code via web checkout\n */\nexport type RedemptionResult =\n | { status: \"SUCCESS\"; code: string; redemptionInfo: RedemptionInfo }\n | { status: \"ERROR\"; code: string; error: ErrorInfo }\n | { status: \"CODE_EXPIRED\"; code: string; expired: ExpiredCodeInfo }\n | { status: \"INVALID_CODE\"; code: string }\n | {\n status: \"EXPIRED_SUBSCRIPTION\"\n code: string\n redemptionInfo: RedemptionInfo\n }\n\n/**\n * @category Utils\n * @since 0.0.15\n * Static methods for working with RedemptionResult\n */\nexport class RedemptionResults {\n static fromJson(json: any): RedemptionResult {\n const { status, code } = json\n\n switch (status) {\n case \"SUCCESS\":\n return {\n status,\n code,\n redemptionInfo: RedemptionResults.parseRedemptionInfo(json.redemptionInfo),\n }\n\n case \"ERROR\":\n return {\n status,\n code,\n error: {\n message: json.error.message,\n },\n }\n\n case \"CODE_EXPIRED\":\n return {\n status,\n code,\n expired: {\n resent: json.expired.resent,\n obfuscatedEmail: json.expired.obfuscatedEmail,\n },\n }\n\n case \"INVALID_CODE\":\n return {\n status,\n code,\n }\n\n case \"EXPIRED_SUBSCRIPTION\":\n return {\n status,\n code,\n redemptionInfo: RedemptionResults.parseRedemptionInfo(json.redemptionInfo),\n }\n\n default:\n throw new Error(`Unknown RedemptionResult status: ${status}`)\n }\n }\n\n private static parseRedemptionInfo(json: any): RedemptionInfo {\n const result: RedemptionInfo = {\n ownership: RedemptionResults.parseOwnership(json.ownership),\n purchaserInfo: RedemptionResults.parsePurchaserInfo(json.purchaserInfo),\n entitlements: Array.isArray(json.entitlements)\n ? json.entitlements.map((e: any) => Entitlement.fromJson(e))\n : [],\n }\n\n if (json.paywallInfo) {\n result.paywallInfo = {\n identifier: json.paywallInfo.identifier,\n placementName: json.paywallInfo.placementName,\n placementParams: json.paywallInfo.placementParams || {},\n variantId: json.paywallInfo.variantId,\n experimentId: json.paywallInfo.experimentId,\n productIdentifier: json.paywallInfo.productIdentifier || undefined\n }\n }\n\n return result\n }\n private static parseOwnership(json: any): Ownership {\n switch (json.type) {\n case \"APP_USER\":\n return {\n type: \"APP_USER\",\n appUserId: json.appUserId,\n }\n\n case \"DEVICE\":\n return {\n type: \"DEVICE\",\n deviceId: json.deviceId,\n }\n\n default:\n throw new Error(`Unknown ownership type: ${json.type}`)\n }\n }\n\n private static parsePurchaserInfo(json: any): PurchaserInfo {\n const result: PurchaserInfo = {\n appUserId: json.appUserId,\n storeIdentifiers: RedemptionResults.parseStoreIdentifiers(json.storeIdentifiers),\n }\n\n if (json.email) {\n result.email = json.email\n }\n\n return result\n }\n\n private static parseStoreIdentifiers(json: any): StoreIdentifiers {\n if (json.store === \"STRIPE\") {\n return {\n store: \"STRIPE\",\n stripeCustomerId: json.stripeCustomerId,\n stripeSubscriptionIds: json.stripeSubscriptionIds || [],\n }\n }\n\n return { ...json }\n }\n}\n"]}
|