@metamask/subscription-controller 12.0.1 → 14.0.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/dist/SubscriptionController-method-action-types.d.ts +14 -4
  3. package/dist/SubscriptionController-method-action-types.d.ts.map +1 -1
  4. package/dist/SubscriptionController-method-action-types.js.map +1 -1
  5. package/dist/SubscriptionController.d.ts +16 -5
  6. package/dist/SubscriptionController.d.ts.map +1 -1
  7. package/dist/SubscriptionController.js +61 -16
  8. package/dist/SubscriptionController.js.map +1 -1
  9. package/dist/SubscriptionService-structs.d.ts +36 -36
  10. package/dist/SubscriptionService-structs.js +4 -4
  11. package/dist/SubscriptionService-structs.js.map +1 -1
  12. package/dist/constants.d.ts +6 -2
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +39 -2
  15. package/dist/constants.js.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts +9 -14
  21. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.d.ts.map +1 -1
  22. package/dist/subscription-delegation/SubscriptionDelegationService-method-action-types.js.map +1 -1
  23. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts +11 -17
  24. package/dist/subscription-delegation/SubscriptionDelegationService.d.ts.map +1 -1
  25. package/dist/subscription-delegation/SubscriptionDelegationService.js +35 -107
  26. package/dist/subscription-delegation/SubscriptionDelegationService.js.map +1 -1
  27. package/dist/subscription-delegation/types.d.ts +0 -21
  28. package/dist/subscription-delegation/types.d.ts.map +1 -1
  29. package/dist/subscription-delegation/types.js +0 -1
  30. package/dist/subscription-delegation/types.js.map +1 -1
  31. package/dist/types.d.ts +18 -4
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/types.js.map +1 -1
  34. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [14.0.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** `SubscriptionDelegationServiceMessenger` now requires `SubscriptionController:isUserEligibleForTrial` ([#10795](https://github.com/MetaMask/core/pull/10795))
15
+ - Clients that construct this messenger must delegate `SubscriptionController:isUserEligibleForTrial`.
16
+ - Bump `@metamask/profile-sync-controller` from `^34.0.2` to `^34.0.3` ([#10761](https://github.com/MetaMask/core/pull/10761))
17
+ - Require `Subscription.currentPeriodStart`, `currentPeriodEnd`, `cancelType`, and `isEligibleForSupport` in the subscription response and runtime validation. ([#10765](https://github.com/MetaMask/core/pull/10765))
18
+ - Bump `@metamask/transaction-controller` from `^72.1.0` to `^72.2.0` ([#10772](https://github.com/MetaMask/core/pull/10772))
19
+
20
+ ### Fixed
21
+
22
+ - Fixed Money Account Plus checkout requesting a trial for a user `isUserEligibleForTrial` rejects ([#10795](https://github.com/MetaMask/core/pull/10795))
23
+ - `SubscriptionController:unCancelSubscription` refreshes subscriptions after a successful uncancel. ([#10802](https://github.com/MetaMask/core/pull/10802))
24
+ - The stored subscription is replaced with the uncancel response instead of merged with it, so optional fields the response omits (such as `cancelAtPeriodEnd` and `canceledAt`) no longer keep stale values, including when the subscription refresh fails.
25
+
26
+ ## [13.0.0]
27
+
28
+ ### Added
29
+
30
+ - Add optional `isEligibleForRefund` on `StartSubscriptionRequest` and `StartCryptoSubscriptionRequest` ([#10674](https://github.com/MetaMask/core/pull/10674))
31
+ - When the caller provides it, `SubscriptionController` sends that value and skips the geolocation check.
32
+ - When omitted, the controller sets it from geolocation (EU 27 + EEA), or `false` if the lookup fails.
33
+
34
+ ### Changed
35
+
36
+ - **BREAKING:** `SubscriptionControllerMessenger` now requires `GeolocationController:getGeolocationData` so `startSubscriptionWithCard` and `startSubscriptionWithCrypto` can resolve refund eligibility ([#10674](https://github.com/MetaMask/core/pull/10674))
37
+ - Clients that construct this messenger must delegate `GeolocationController:getGeolocationData` before calling those actions.
38
+ - Add `@metamask/geolocation-controller` `^2.0.0` as a dependency ([#10674](https://github.com/MetaMask/core/pull/10674))
39
+ - **BREAKING:** `SubscriptionDelegationService:startSubscriptionWithDelegation` no longer requests an approval. Callers must obtain consent and initiate funding (for example, a `membershipSubscription` transaction) before calling. ([#10666](https://github.com/MetaMask/core/pull/10666))
40
+ - `skipApproval` is removed from `StartSubscriptionWithDelegationRequest`.
41
+ - Bump `@metamask/profile-sync-controller` from `^34.0.0` to `^34.0.2` ([#10752](https://github.com/MetaMask/core/pull/10752), [#10756](https://github.com/MetaMask/core/pull/10756))
42
+ - Bump `@metamask/seedless-onboarding-controller` from `^11.0.1` to `^12.0.0` ([#10756](https://github.com/MetaMask/core/pull/10756))
43
+
44
+ ### Removed
45
+
46
+ - **BREAKING:** Remove the subscription delegation approval contracts. ([#10666](https://github.com/MetaMask/core/pull/10666))
47
+ - Remove `SUBSCRIPTION_DELEGATION_APPROVAL_TYPE`, `SubscriptionFundingRequest`, and `SubscriptionDelegationApprovalResult`.
48
+ - Remove `ApprovalResultMissing` and `InvalidFundingTransactionHash` from `SubscriptionDelegationServiceErrorMessage`.
49
+ - `SubscriptionDelegationServiceMessenger` no longer allows `ApprovalController:addRequest`. Clients that construct this messenger must stop delegating that action.
50
+ - Remove the `@metamask/approval-controller` dependency. ([#10666](https://github.com/MetaMask/core/pull/10666))
51
+
10
52
  ## [12.0.1]
11
53
 
12
54
  ### Changed
@@ -604,7 +646,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
604
646
  - Bump `@metamask/controller-utils` from `^11.12.0` to `^11.14.0` ([#6620](https://github.com/MetaMask/core/pull/6620), [#6629](https://github.com/MetaMask/core/pull/6629))
605
647
  - Bump `@metamask/utils` from `^11.4.2` to `^11.8.0` ([#6588](https://github.com/MetaMask/core/pull/6588))
606
648
 
607
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@12.0.1...HEAD
649
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@14.0.0...HEAD
650
+ [14.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@13.0.0...@metamask/subscription-controller@14.0.0
651
+ [13.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@12.0.1...@metamask/subscription-controller@13.0.0
608
652
  [12.0.1]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@12.0.0...@metamask/subscription-controller@12.0.1
609
653
  [12.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@11.0.0...@metamask/subscription-controller@12.0.0
610
654
  [11.0.0]: https://github.com/MetaMask/core/compare/@metamask/subscription-controller@10.0.1...@metamask/subscription-controller@11.0.0
@@ -75,8 +75,13 @@ export type SubscriptionControllerUnCancelSubscriptionAction = {
75
75
  * Starts a card-paid subscription checkout session for the requested products
76
76
  * (e.g. Shield or Money Account Plus).
77
77
  *
78
- * `isTrialRequested` on the request is ignored and overwritten from pricing
79
- * (`trialPeriodDays > 0`) and `trialedProducts`.
78
+ * `isTrialRequested` on the request is ignored and overwritten from
79
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
80
+ * when it has not been trialed. Money Account Plus is eligible when it has
81
+ * not been trialed and the user is authenticated with social login.
82
+ *
83
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
84
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
80
85
  *
81
86
  * @param request - The start subscription request.
82
87
  * @returns The checkout session response.
@@ -91,8 +96,13 @@ export type SubscriptionControllerStartSubscriptionWithCardAction = {
91
96
  * creates the subscription immediately, so local state is refreshed
92
97
  * afterwards.
93
98
  *
94
- * `isTrialRequested` on the request is ignored and overwritten from pricing
95
- * (`trialPeriodDays > 0`) and `trialedProducts`.
99
+ * `isTrialRequested` on the request is ignored and overwritten from
100
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
101
+ * when it has not been trialed. Money Account Plus is eligible when it has
102
+ * not been trialed and the user is authenticated with social login.
103
+ *
104
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
105
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
96
106
  *
97
107
  * @param request - The start crypto subscription request.
98
108
  * @returns The start crypto subscription response.
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionController-method-action-types.d.ts","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,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AAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,kDAAkD,CAAC;IACzD,OAAO,EAAE,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC3C,sCAAsC,GACtC,4CAA4C,GAC5C,uCAAuC,GACvC,oDAAoD,GACpD,kDAAkD,GAClD,yDAAyD,GACzD,8CAA8C,GAC9C,gDAAgD,GAChD,qDAAqD,GACrD,uDAAuD,GACvD,4DAA4D,GAC5D,6DAA6D,GAC7D,+CAA+C,GAC/C,+CAA+C,GAC/C,0DAA0D,GAC1D,0DAA0D,GAC1D,oDAAoD,GACpD,2CAA2C,GAC3C,8CAA8C,GAC9C,uCAAuC,GACvC,iDAAiD,GACjD,wDAAwD,GACxD,sCAAsC,GACtC,qDAAqD,GACrD,0CAA0C,CAAC"}
1
+ {"version":3,"file":"SubscriptionController-method-action-types.d.ts","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;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C9C,uCAAuC,GACvC,iDAAiD,GACjD,wDAAwD,GACxD,sCAAsC,GACtC,qDAAqD,GACrD,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionController-method-action-types.js","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionController } from './SubscriptionController.js';\n\n/**\n * Gets the pricing information from the subscription service.\n *\n * @returns The pricing information.\n */\nexport type SubscriptionControllerGetPricingAction = {\n type: `SubscriptionController:getPricing`;\n handler: SubscriptionController['getPricing'];\n};\n\nexport type SubscriptionControllerGetSubscriptionsAction = {\n type: `SubscriptionController:getSubscriptions`;\n handler: SubscriptionController['getSubscriptions'];\n};\n\n/**\n * Gets and stores the user's subscription benefits.\n *\n * @returns The benefits response.\n * @throws If the user is not an active Money Account Plus subscriber or is\n * not eligible for benefits.\n */\nexport type SubscriptionControllerGetBenefitsAction = {\n type: `SubscriptionController:getBenefits`;\n handler: SubscriptionController['getBenefits'];\n};\n\n/**\n * Get the subscription by product.\n *\n * @param productType - The product type.\n * @returns The subscription.\n */\nexport type SubscriptionControllerGetSubscriptionByProductAction = {\n type: `SubscriptionController:getSubscriptionByProduct`;\n handler: SubscriptionController['getSubscriptionByProduct'];\n};\n\n/**\n * Whether the user is eligible to start a trial for the given product.\n *\n * Shield is eligible when the user has not trialed Shield before.\n * Money Account Plus is eligible when the user has not trialed it before\n * and is authenticated with social login. Only an unlocked wallet can\n * subscribe, so `SeedlessOnboardingController:getIsUserAuthenticated` is a\n * sufficient social-login check.\n *\n * @param productType - The product to check.\n * @returns Whether the user is eligible for a trial.\n */\nexport type SubscriptionControllerIsUserEligibleForTrialAction = {\n type: `SubscriptionController:isUserEligibleForTrial`;\n handler: SubscriptionController['isUserEligibleForTrial'];\n};\n\n/**\n * Get the subscriptions eligibilities.\n *\n * @param request - Optional request object containing user balance to check cohort eligibility.\n * @returns The subscriptions eligibilities.\n */\nexport type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionController:getSubscriptionsEligibilities`;\n handler: SubscriptionController['getSubscriptionsEligibilities'];\n};\n\nexport type SubscriptionControllerCancelSubscriptionAction = {\n type: `SubscriptionController:cancelSubscription`;\n handler: SubscriptionController['cancelSubscription'];\n};\n\nexport type SubscriptionControllerUnCancelSubscriptionAction = {\n type: `SubscriptionController:unCancelSubscription`;\n handler: SubscriptionController['unCancelSubscription'];\n};\n\n/**\n * Starts a card-paid subscription checkout session for the requested products\n * (e.g. Shield or Money Account Plus).\n *\n * `isTrialRequested` on the request is ignored and overwritten from pricing\n * (`trialPeriodDays > 0`) and `trialedProducts`.\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\nexport type SubscriptionControllerStartSubscriptionWithCardAction = {\n type: `SubscriptionController:startSubscriptionWithCard`;\n handler: SubscriptionController['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a crypto-paid subscription for the requested products\n * (e.g. Shield or Money Account Plus). Unlike card checkout, this\n * creates the subscription immediately, so local state is refreshed\n * afterwards.\n *\n * `isTrialRequested` on the request is ignored and overwritten from pricing\n * (`trialPeriodDays > 0`) and `trialedProducts`.\n *\n * @param request - The start crypto subscription request.\n * @returns The start crypto subscription response.\n * @throws If `products` is empty.\n */\nexport type SubscriptionControllerStartSubscriptionWithCryptoAction = {\n type: `SubscriptionController:startSubscriptionWithCrypto`;\n handler: SubscriptionController['startSubscriptionWithCrypto'];\n};\n\n/**\n * Submits a Shield ERC-20 crypto approval transaction to start or update a\n * crypto subscription.\n *\n * This handler is Shield / `TransactionType.shieldSubscriptionApprove` only.\n * Delegation-based products (e.g. Money Account) must call\n * `startSubscriptionWithCrypto` instead.\n *\n * @param request - The crypto approval request.\n * @param request.productType - The subscription product. Typed as\n * `typeof PRODUCT_TYPES.SHIELD` only at the moment (future might support more\n * product).\n * @param request.txMeta - The transaction metadata. Must have type\n * `TransactionType.shieldSubscriptionApprove`.\n * @param request.isSponsored - Whether the transaction is sponsored.\n * @param request.rewardAccountId - The account ID of the reward subscription\n * to link.\n * @throws If `productType` is not Shield or `txMeta.type` is not\n * `shieldSubscriptionApprove`.\n * @returns void\n */\nexport type SubscriptionControllerSubmitSubscriptionCryptoApprovalAction = {\n type: `SubscriptionController:submitSubscriptionCryptoApproval`;\n handler: SubscriptionController['submitSubscriptionCryptoApproval'];\n};\n\n/**\n * Get transaction params to create crypto approve transaction for subscription payment\n *\n * @param request - The request object\n * @param request.chainId - The chain ID\n * @param request.tokenAddress - The address of the token\n * @param request.productType - The product type\n * @param request.interval - The interval\n * @returns The crypto approve transaction params\n */\nexport type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {\n type: `SubscriptionController:getCryptoApproveTransactionParams`;\n handler: SubscriptionController['getCryptoApproveTransactionParams'];\n};\n\nexport type SubscriptionControllerUpdatePaymentMethodAction = {\n type: `SubscriptionController:updatePaymentMethod`;\n handler: SubscriptionController['updatePaymentMethod'];\n};\n\n/**\n * Gets the billing portal URL.\n *\n * @returns The billing portal URL\n */\nexport type SubscriptionControllerGetBillingPortalUrlAction = {\n type: `SubscriptionController:getBillingPortalUrl`;\n handler: SubscriptionController['getBillingPortalUrl'];\n};\n\n/**\n * Cache the last selected payment method for a specific product.\n *\n * @param request - The request object.\n * @param request.product - The product to cache the payment method for.\n * @param request.paymentMethod - The payment method to cache.\n * @param request.paymentMethod.type - The type of the payment method.\n * @param request.paymentMethod.paymentTokenAddress - The payment token address.\n * @param request.paymentMethod.plan - The plan of the payment method.\n */\nexport type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:cacheLastSelectedPaymentMethod`;\n handler: SubscriptionController['cacheLastSelectedPaymentMethod'];\n};\n\n/**\n * Clear the last selected payment method for a specific product.\n *\n * @param product - The product to clear the payment method for.\n */\nexport type SubscriptionControllerClearLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:clearLastSelectedPaymentMethod`;\n handler: SubscriptionController['clearLastSelectedPaymentMethod'];\n};\n\n/**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n * @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false if the chain does not support sponsorship or the user has already trialed\n * @throws If the crypto payment method or chain is missing from pricing\n */\nexport type SubscriptionControllerSubmitSponsorshipIntentsAction = {\n type: `SubscriptionController:submitSponsorshipIntents`;\n handler: SubscriptionController['submitSponsorshipIntents'];\n};\n\n/**\n * Submit a user event from the UI. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionControllerSubmitUserEventAction = {\n type: `SubscriptionController:submitUserEvent`;\n handler: SubscriptionController['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionControllerAssignUserToCohortAction = {\n type: `SubscriptionController:assignUserToCohort`;\n handler: SubscriptionController['assignUserToCohort'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward subscription ID.\n * @param request.subscriptionId - The ID of the subscription to link rewards to.\n * @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.\n * @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns Resolves when the rewards are linked successfully.\n */\nexport type SubscriptionControllerLinkRewardsAction = {\n type: `SubscriptionController:linkRewards`;\n handler: SubscriptionController['linkRewards'];\n};\n\n/**\n * Calculate token approve amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token approve amount\n */\nexport type SubscriptionControllerGetTokenApproveAmountAction = {\n type: `SubscriptionController:getTokenApproveAmount`;\n handler: SubscriptionController['getTokenApproveAmount'];\n};\n\n/**\n * Calculate token minimum balance amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token balance amount\n */\nexport type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {\n type: `SubscriptionController:getTokenMinimumBalanceAmount`;\n handler: SubscriptionController['getTokenMinimumBalanceAmount'];\n};\n\n/**\n * Clears the subscription state and resets to default values.\n */\nexport type SubscriptionControllerClearStateAction = {\n type: `SubscriptionController:clearState`;\n handler: SubscriptionController['clearState'];\n};\n\n/**\n * Triggers an access token refresh.\n */\nexport type SubscriptionControllerTriggerAccessTokenRefreshAction = {\n type: `SubscriptionController:triggerAccessTokenRefresh`;\n handler: SubscriptionController['triggerAccessTokenRefresh'];\n};\n\nexport type SubscriptionControllerStopAllPollingAction = {\n type: `SubscriptionController:stopAllPolling`;\n handler: SubscriptionController['stopAllPolling'];\n};\n\n/**\n * Union of all SubscriptionController action types.\n */\nexport type SubscriptionControllerMethodActions =\n | SubscriptionControllerGetPricingAction\n | SubscriptionControllerGetSubscriptionsAction\n | SubscriptionControllerGetBenefitsAction\n | SubscriptionControllerGetSubscriptionByProductAction\n | SubscriptionControllerIsUserEligibleForTrialAction\n | SubscriptionControllerGetSubscriptionsEligibilitiesAction\n | SubscriptionControllerCancelSubscriptionAction\n | SubscriptionControllerUnCancelSubscriptionAction\n | SubscriptionControllerStartSubscriptionWithCardAction\n | SubscriptionControllerStartSubscriptionWithCryptoAction\n | SubscriptionControllerSubmitSubscriptionCryptoApprovalAction\n | SubscriptionControllerGetCryptoApproveTransactionParamsAction\n | SubscriptionControllerUpdatePaymentMethodAction\n | SubscriptionControllerGetBillingPortalUrlAction\n | SubscriptionControllerCacheLastSelectedPaymentMethodAction\n | SubscriptionControllerClearLastSelectedPaymentMethodAction\n | SubscriptionControllerSubmitSponsorshipIntentsAction\n | SubscriptionControllerSubmitUserEventAction\n | SubscriptionControllerAssignUserToCohortAction\n | SubscriptionControllerLinkRewardsAction\n | SubscriptionControllerGetTokenApproveAmountAction\n | SubscriptionControllerGetTokenMinimumBalanceAmountAction\n | SubscriptionControllerClearStateAction\n | SubscriptionControllerTriggerAccessTokenRefreshAction\n | SubscriptionControllerStopAllPollingAction;\n"]}
1
+ {"version":3,"file":"SubscriptionController-method-action-types.js","sourceRoot":"","sources":["../src/SubscriptionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SubscriptionController } from './SubscriptionController.js';\n\n/**\n * Gets the pricing information from the subscription service.\n *\n * @returns The pricing information.\n */\nexport type SubscriptionControllerGetPricingAction = {\n type: `SubscriptionController:getPricing`;\n handler: SubscriptionController['getPricing'];\n};\n\nexport type SubscriptionControllerGetSubscriptionsAction = {\n type: `SubscriptionController:getSubscriptions`;\n handler: SubscriptionController['getSubscriptions'];\n};\n\n/**\n * Gets and stores the user's subscription benefits.\n *\n * @returns The benefits response.\n * @throws If the user is not an active Money Account Plus subscriber or is\n * not eligible for benefits.\n */\nexport type SubscriptionControllerGetBenefitsAction = {\n type: `SubscriptionController:getBenefits`;\n handler: SubscriptionController['getBenefits'];\n};\n\n/**\n * Get the subscription by product.\n *\n * @param productType - The product type.\n * @returns The subscription.\n */\nexport type SubscriptionControllerGetSubscriptionByProductAction = {\n type: `SubscriptionController:getSubscriptionByProduct`;\n handler: SubscriptionController['getSubscriptionByProduct'];\n};\n\n/**\n * Whether the user is eligible to start a trial for the given product.\n *\n * Shield is eligible when the user has not trialed Shield before.\n * Money Account Plus is eligible when the user has not trialed it before\n * and is authenticated with social login. Only an unlocked wallet can\n * subscribe, so `SeedlessOnboardingController:getIsUserAuthenticated` is a\n * sufficient social-login check.\n *\n * @param productType - The product to check.\n * @returns Whether the user is eligible for a trial.\n */\nexport type SubscriptionControllerIsUserEligibleForTrialAction = {\n type: `SubscriptionController:isUserEligibleForTrial`;\n handler: SubscriptionController['isUserEligibleForTrial'];\n};\n\n/**\n * Get the subscriptions eligibilities.\n *\n * @param request - Optional request object containing user balance to check cohort eligibility.\n * @returns The subscriptions eligibilities.\n */\nexport type SubscriptionControllerGetSubscriptionsEligibilitiesAction = {\n type: `SubscriptionController:getSubscriptionsEligibilities`;\n handler: SubscriptionController['getSubscriptionsEligibilities'];\n};\n\nexport type SubscriptionControllerCancelSubscriptionAction = {\n type: `SubscriptionController:cancelSubscription`;\n handler: SubscriptionController['cancelSubscription'];\n};\n\nexport type SubscriptionControllerUnCancelSubscriptionAction = {\n type: `SubscriptionController:unCancelSubscription`;\n handler: SubscriptionController['unCancelSubscription'];\n};\n\n/**\n * Starts a card-paid subscription checkout session for the requested products\n * (e.g. Shield or Money Account Plus).\n *\n * `isTrialRequested` on the request is ignored and overwritten from\n * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible\n * when it has not been trialed. Money Account Plus is eligible when it has\n * not been trialed and the user is authenticated with social login.\n *\n * `isEligibleForRefund` is sent as provided. When omitted, it is resolved\n * from geolocation (EU/EEA), or `false` if the lookup fails.\n *\n * @param request - The start subscription request.\n * @returns The checkout session response.\n */\nexport type SubscriptionControllerStartSubscriptionWithCardAction = {\n type: `SubscriptionController:startSubscriptionWithCard`;\n handler: SubscriptionController['startSubscriptionWithCard'];\n};\n\n/**\n * Starts a crypto-paid subscription for the requested products\n * (e.g. Shield or Money Account Plus). Unlike card checkout, this\n * creates the subscription immediately, so local state is refreshed\n * afterwards.\n *\n * `isTrialRequested` on the request is ignored and overwritten from\n * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible\n * when it has not been trialed. Money Account Plus is eligible when it has\n * not been trialed and the user is authenticated with social login.\n *\n * `isEligibleForRefund` is sent as provided. When omitted, it is resolved\n * from geolocation (EU/EEA), or `false` if the lookup fails.\n *\n * @param request - The start crypto subscription request.\n * @returns The start crypto subscription response.\n * @throws If `products` is empty.\n */\nexport type SubscriptionControllerStartSubscriptionWithCryptoAction = {\n type: `SubscriptionController:startSubscriptionWithCrypto`;\n handler: SubscriptionController['startSubscriptionWithCrypto'];\n};\n\n/**\n * Submits a Shield ERC-20 crypto approval transaction to start or update a\n * crypto subscription.\n *\n * This handler is Shield / `TransactionType.shieldSubscriptionApprove` only.\n * Delegation-based products (e.g. Money Account) must call\n * `startSubscriptionWithCrypto` instead.\n *\n * @param request - The crypto approval request.\n * @param request.productType - The subscription product. Typed as\n * `typeof PRODUCT_TYPES.SHIELD` only at the moment (future might support more\n * product).\n * @param request.txMeta - The transaction metadata. Must have type\n * `TransactionType.shieldSubscriptionApprove`.\n * @param request.isSponsored - Whether the transaction is sponsored.\n * @param request.rewardAccountId - The account ID of the reward subscription\n * to link.\n * @throws If `productType` is not Shield or `txMeta.type` is not\n * `shieldSubscriptionApprove`.\n * @returns void\n */\nexport type SubscriptionControllerSubmitSubscriptionCryptoApprovalAction = {\n type: `SubscriptionController:submitSubscriptionCryptoApproval`;\n handler: SubscriptionController['submitSubscriptionCryptoApproval'];\n};\n\n/**\n * Get transaction params to create crypto approve transaction for subscription payment\n *\n * @param request - The request object\n * @param request.chainId - The chain ID\n * @param request.tokenAddress - The address of the token\n * @param request.productType - The product type\n * @param request.interval - The interval\n * @returns The crypto approve transaction params\n */\nexport type SubscriptionControllerGetCryptoApproveTransactionParamsAction = {\n type: `SubscriptionController:getCryptoApproveTransactionParams`;\n handler: SubscriptionController['getCryptoApproveTransactionParams'];\n};\n\nexport type SubscriptionControllerUpdatePaymentMethodAction = {\n type: `SubscriptionController:updatePaymentMethod`;\n handler: SubscriptionController['updatePaymentMethod'];\n};\n\n/**\n * Gets the billing portal URL.\n *\n * @returns The billing portal URL\n */\nexport type SubscriptionControllerGetBillingPortalUrlAction = {\n type: `SubscriptionController:getBillingPortalUrl`;\n handler: SubscriptionController['getBillingPortalUrl'];\n};\n\n/**\n * Cache the last selected payment method for a specific product.\n *\n * @param request - The request object.\n * @param request.product - The product to cache the payment method for.\n * @param request.paymentMethod - The payment method to cache.\n * @param request.paymentMethod.type - The type of the payment method.\n * @param request.paymentMethod.paymentTokenAddress - The payment token address.\n * @param request.paymentMethod.plan - The plan of the payment method.\n */\nexport type SubscriptionControllerCacheLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:cacheLastSelectedPaymentMethod`;\n handler: SubscriptionController['cacheLastSelectedPaymentMethod'];\n};\n\n/**\n * Clear the last selected payment method for a specific product.\n *\n * @param product - The product to clear the payment method for.\n */\nexport type SubscriptionControllerClearLastSelectedPaymentMethodAction = {\n type: `SubscriptionController:clearLastSelectedPaymentMethod`;\n handler: SubscriptionController['clearLastSelectedPaymentMethod'];\n};\n\n/**\n * Submit sponsorship intents to the Subscription Service backend.\n *\n * This is intended to be used together with the crypto subscription flow.\n * When the user has enabled the smart transaction feature, we will sponsor the gas fees for the subscription approval transaction.\n *\n * @param request - Request object containing the address and products.\n * @example {\n * address: '0x1234567890123456789012345678901234567890',\n * products: [ProductType.Shield],\n * recurringInterval: RecurringInterval.Month,\n * billingCycles: 1,\n * }\n * @returns resolves to true if the sponsorship is supported and intents were submitted successfully, false if the chain does not support sponsorship or the user has already trialed\n * @throws If the crypto payment method or chain is missing from pricing\n */\nexport type SubscriptionControllerSubmitSponsorshipIntentsAction = {\n type: `SubscriptionController:submitSponsorshipIntents`;\n handler: SubscriptionController['submitSponsorshipIntents'];\n};\n\n/**\n * Submit a user event from the UI. (e.g. shield modal viewed)\n *\n * @param request - Request object containing the event to submit.\n * @example { event: SubscriptionUserEvent.ShieldEntryModalViewed, cohort: 'post_tx' }\n */\nexport type SubscriptionControllerSubmitUserEventAction = {\n type: `SubscriptionController:submitUserEvent`;\n handler: SubscriptionController['submitUserEvent'];\n};\n\n/**\n * Assign user to a cohort.\n *\n * @param request - Request object containing the cohort to assign the user to.\n * @example { cohort: 'post_tx' }\n */\nexport type SubscriptionControllerAssignUserToCohortAction = {\n type: `SubscriptionController:assignUserToCohort`;\n handler: SubscriptionController['assignUserToCohort'];\n};\n\n/**\n * Link rewards to a subscription.\n *\n * @param request - Request object containing the reward subscription ID.\n * @param request.subscriptionId - The ID of the subscription to link rewards to.\n * @param request.rewardAccountId - The account ID of the reward subscription to link to the subscription.\n * @example { subscriptionId: '1234567890', rewardAccountId: 'eip155:1:0x1234567890123456789012345678901234567890' }\n * @returns Resolves when the rewards are linked successfully.\n */\nexport type SubscriptionControllerLinkRewardsAction = {\n type: `SubscriptionController:linkRewards`;\n handler: SubscriptionController['linkRewards'];\n};\n\n/**\n * Calculate token approve amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token approve amount\n */\nexport type SubscriptionControllerGetTokenApproveAmountAction = {\n type: `SubscriptionController:getTokenApproveAmount`;\n handler: SubscriptionController['getTokenApproveAmount'];\n};\n\n/**\n * Calculate token minimum balance amount from price info\n *\n * @param price - The price info\n * @param tokenPaymentInfo - The token price info\n * @returns The token balance amount\n */\nexport type SubscriptionControllerGetTokenMinimumBalanceAmountAction = {\n type: `SubscriptionController:getTokenMinimumBalanceAmount`;\n handler: SubscriptionController['getTokenMinimumBalanceAmount'];\n};\n\n/**\n * Clears the subscription state and resets to default values.\n */\nexport type SubscriptionControllerClearStateAction = {\n type: `SubscriptionController:clearState`;\n handler: SubscriptionController['clearState'];\n};\n\n/**\n * Triggers an access token refresh.\n */\nexport type SubscriptionControllerTriggerAccessTokenRefreshAction = {\n type: `SubscriptionController:triggerAccessTokenRefresh`;\n handler: SubscriptionController['triggerAccessTokenRefresh'];\n};\n\nexport type SubscriptionControllerStopAllPollingAction = {\n type: `SubscriptionController:stopAllPolling`;\n handler: SubscriptionController['stopAllPolling'];\n};\n\n/**\n * Union of all SubscriptionController action types.\n */\nexport type SubscriptionControllerMethodActions =\n | SubscriptionControllerGetPricingAction\n | SubscriptionControllerGetSubscriptionsAction\n | SubscriptionControllerGetBenefitsAction\n | SubscriptionControllerGetSubscriptionByProductAction\n | SubscriptionControllerIsUserEligibleForTrialAction\n | SubscriptionControllerGetSubscriptionsEligibilitiesAction\n | SubscriptionControllerCancelSubscriptionAction\n | SubscriptionControllerUnCancelSubscriptionAction\n | SubscriptionControllerStartSubscriptionWithCardAction\n | SubscriptionControllerStartSubscriptionWithCryptoAction\n | SubscriptionControllerSubmitSubscriptionCryptoApprovalAction\n | SubscriptionControllerGetCryptoApproveTransactionParamsAction\n | SubscriptionControllerUpdatePaymentMethodAction\n | SubscriptionControllerGetBillingPortalUrlAction\n | SubscriptionControllerCacheLastSelectedPaymentMethodAction\n | SubscriptionControllerClearLastSelectedPaymentMethodAction\n | SubscriptionControllerSubmitSponsorshipIntentsAction\n | SubscriptionControllerSubmitUserEventAction\n | SubscriptionControllerAssignUserToCohortAction\n | SubscriptionControllerLinkRewardsAction\n | SubscriptionControllerGetTokenApproveAmountAction\n | SubscriptionControllerGetTokenMinimumBalanceAmountAction\n | SubscriptionControllerClearStateAction\n | SubscriptionControllerTriggerAccessTokenRefreshAction\n | SubscriptionControllerStopAllPollingAction;\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { ControllerStateChangeEvent, ControllerGetStateAction } from '@metamask/base-controller';
2
+ import type { GeolocationControllerGetGeolocationDataAction } from '@metamask/geolocation-controller';
2
3
  import type { Messenger } from '@metamask/messenger';
3
4
  import type { AuthenticationController } from '@metamask/profile-sync-controller';
4
5
  import type { SeedlessOnboardingControllerGetIsUserAuthenticatedAction } from '@metamask/seedless-onboarding-controller';
@@ -28,7 +29,7 @@ export type SubscriptionControllerState = {
28
29
  };
29
30
  export type SubscriptionControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SubscriptionControllerState>;
30
31
  export type SubscriptionControllerActions = SubscriptionControllerGetStateAction | SubscriptionControllerMethodActions;
31
- type AllowedActions = SubscriptionServiceGetPricingAction | SubscriptionServiceGetSubscriptionsAction | SubscriptionServiceGetBenefitsAction | SubscriptionServiceGetSubscriptionsEligibilitiesAction | SubscriptionServiceCancelSubscriptionAction | SubscriptionServiceUnCancelSubscriptionAction | SubscriptionServiceStartSubscriptionWithCardAction | SubscriptionServiceStartSubscriptionWithCryptoAction | SubscriptionServiceUpdatePaymentMethodCardAction | SubscriptionServiceUpdatePaymentMethodCryptoAction | SubscriptionServiceGetBillingPortalUrlAction | SubscriptionServiceSubmitSponsorshipIntentsAction | SubscriptionServiceSubmitUserEventAction | SubscriptionServiceAssignUserToCohortAction | SubscriptionServiceLinkRewardsAction | AuthenticationController.AuthenticationControllerPerformSignOutAction | SeedlessOnboardingControllerGetIsUserAuthenticatedAction;
32
+ type AllowedActions = SubscriptionServiceGetPricingAction | SubscriptionServiceGetSubscriptionsAction | SubscriptionServiceGetBenefitsAction | SubscriptionServiceGetSubscriptionsEligibilitiesAction | SubscriptionServiceCancelSubscriptionAction | SubscriptionServiceUnCancelSubscriptionAction | SubscriptionServiceStartSubscriptionWithCardAction | SubscriptionServiceStartSubscriptionWithCryptoAction | SubscriptionServiceUpdatePaymentMethodCardAction | SubscriptionServiceUpdatePaymentMethodCryptoAction | SubscriptionServiceGetBillingPortalUrlAction | SubscriptionServiceSubmitSponsorshipIntentsAction | SubscriptionServiceSubmitUserEventAction | SubscriptionServiceAssignUserToCohortAction | SubscriptionServiceLinkRewardsAction | AuthenticationController.AuthenticationControllerPerformSignOutAction | SeedlessOnboardingControllerGetIsUserAuthenticatedAction | GeolocationControllerGetGeolocationDataAction;
32
33
  export type SubscriptionControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SubscriptionControllerState>;
33
34
  export type SubscriptionControllerEvents = SubscriptionControllerStateChangeEvent;
34
35
  type AllowedEvents = never;
@@ -131,8 +132,13 @@ export declare class SubscriptionController extends SubscriptionController_base<
131
132
  * Starts a card-paid subscription checkout session for the requested products
132
133
  * (e.g. Shield or Money Account Plus).
133
134
  *
134
- * `isTrialRequested` on the request is ignored and overwritten from pricing
135
- * (`trialPeriodDays > 0`) and `trialedProducts`.
135
+ * `isTrialRequested` on the request is ignored and overwritten from
136
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
137
+ * when it has not been trialed. Money Account Plus is eligible when it has
138
+ * not been trialed and the user is authenticated with social login.
139
+ *
140
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
141
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
136
142
  *
137
143
  * @param request - The start subscription request.
138
144
  * @returns The checkout session response.
@@ -144,8 +150,13 @@ export declare class SubscriptionController extends SubscriptionController_base<
144
150
  * creates the subscription immediately, so local state is refreshed
145
151
  * afterwards.
146
152
  *
147
- * `isTrialRequested` on the request is ignored and overwritten from pricing
148
- * (`trialPeriodDays > 0`) and `trialedProducts`.
153
+ * `isTrialRequested` on the request is ignored and overwritten from
154
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
155
+ * when it has not been trialed. Money Account Plus is eligible when it has
156
+ * not been trialed and the user is authenticated with social login.
157
+ *
158
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
159
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
149
160
  *
150
161
  * @param request - The start crypto subscription request.
151
162
  * @returns The start crypto subscription response.
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionController.d.ts","sourceRoot":"","sources":["../src/SubscriptionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,wDAAwD,EAAE,MAAM,0CAA0C,CAAC;AAEzH,OAAO,KAAK,EAAE,aAAa,EAAO,MAAM,iBAAiB,CAAC;AAI1D,OAAO,EAEL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAC3G,OAAO,KAA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;;;;OAIG;IACH,8BAA8B,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAOzD;IAED;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC5B,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,OAAO,CAAC,CAyClB;IAED;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;IAED;;;;;OAKG;IACG,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpE;IAED;;;;;;;;OAQG;IACG,WAAW,CACf,OAAO,EAAE,kBAAkB,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GACvD,OAAO,CAAC,IAAI,CAAC,CAcf;IAEK,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElC;IAsDD;;;;;;OAMG;IACH,qBAAqB,CACnB,KAAK,EAAE,YAAY,EACnB,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,CAgBR;IAED;;;;;;OAMG;IACH,4BAA4B,CAC1B,KAAK,EAAE,YAAY,EACnB,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,CAiBR;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAKjB;IAED;;OAEG;IACH,yBAAyB,IAAI,IAAI,CAKhC;CA2XF"}
1
+ {"version":3,"file":"SubscriptionController.d.ts","sourceRoot":"","sources":["../src/SubscriptionController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,wDAAwD,EAAE,MAAM,0CAA0C,CAAC;A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GAC5B,OAAO,CAAC,+BAA+B,GAAG,YAAY,EAAE,CAAC,CAgB3D;IAED;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAE1D;IAED;;;;;;;;;OASG;IACH,8BAA8B,CAC5B,OAAO,EAAE,qCAAqC,GAC7C,IAAI,CAiBN;IAED;;;;OAIG;IACH,8BAA8B,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAOzD;IAED;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAC5B,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,OAAO,CAAC,CAyClB;IAED;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;IAED;;;;;OAKG;IACG,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpE;IAED;;;;;;;;OAQG;IACG,WAAW,CACf,OAAO,EAAE,kBAAkB,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GACvD,OAAO,CAAC,IAAI,CAAC,CAcf;IAEK,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElC;IAsDD;;;;;;OAMG;IACH,qBAAqB,CACnB,KAAK,EAAE,YAAY,EACnB,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,CAgBR;IAED;;;;;;OAMG;IACH,4BAA4B,CAC1B,KAAK,EAAE,YAAY,EACnB,gBAAgB,EAAE,gBAAgB,GACjC,MAAM,CAiBR;IAED;;OAEG;IACH,UAAU,IAAI,IAAI,CAKjB;IAED;;OAEG;IACH,yBAAyB,IAAI,IAAI,CAKhC;CA2ZF"}
@@ -2,7 +2,7 @@ import { StaticIntervalPollingController } from '@metamask/polling-controller';
2
2
  import { TransactionType } from '@metamask/transaction-controller';
3
3
  import { BigNumber } from 'bignumber.js';
4
4
  import deepEqual from 'fast-deep-equal';
5
- import { ACTIVE_SUBSCRIPTION_STATUSES, controllerName, DEFAULT_POLLING_INTERVAL, SubscriptionControllerErrorMessage, SubscriptionDelegationServiceErrorMessage, } from './constants.js';
5
+ import { ACTIVE_SUBSCRIPTION_STATUSES, controllerName, DEFAULT_POLLING_INTERVAL, REFUND_ELIGIBLE_COUNTRIES, SubscriptionControllerErrorMessage, SubscriptionDelegationServiceErrorMessage, } from './constants.js';
6
6
  import { createModuleLogger, projectLogger } from './logger.js';
7
7
  import { CRYPTO_AUTH_METHODS, PAYMENT_TYPES, PRODUCT_TYPES, SUBSCRIPTION_STATUSES, } from './types.js';
8
8
  const log = createModuleLogger(projectLogger, controllerName);
@@ -304,20 +304,36 @@ export class SubscriptionController extends StaticIntervalPollingController() {
304
304
  const uncancelledSubscription = await this.messenger.call('SubscriptionService:unCancelSubscription', {
305
305
  subscriptionId: request.subscriptionId,
306
306
  });
307
+ // Replace rather than merge: optional fields the response omits (e.g.
308
+ // `cancelAtPeriodEnd`, `canceledAt`) must not survive from the
309
+ // pending-cancellation state.
307
310
  this.update((state) => {
308
311
  state.subscriptions = state.subscriptions.map((subscription) => subscription.id === request.subscriptionId
309
- ? { ...subscription, ...uncancelledSubscription }
312
+ ? uncancelledSubscription
310
313
  : subscription);
311
314
  });
312
- await this.#refreshBenefitsIfActive();
315
+ try {
316
+ await this.#getSubscriptions();
317
+ }
318
+ catch (error) {
319
+ log('Failed to refresh subscriptions after uncancellation', error);
320
+ // Preserve the existing best-effort benefits refresh behavior if the
321
+ // canonical subscription refresh is unavailable.
322
+ await this.#refreshBenefitsIfActive();
323
+ }
313
324
  this.triggerAccessTokenRefresh();
314
325
  }
315
326
  /**
316
327
  * Starts a card-paid subscription checkout session for the requested products
317
328
  * (e.g. Shield or Money Account Plus).
318
329
  *
319
- * `isTrialRequested` on the request is ignored and overwritten from pricing
320
- * (`trialPeriodDays > 0`) and `trialedProducts`.
330
+ * `isTrialRequested` on the request is ignored and overwritten from
331
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
332
+ * when it has not been trialed. Money Account Plus is eligible when it has
333
+ * not been trialed and the user is authenticated with social login.
334
+ *
335
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
336
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
321
337
  *
322
338
  * @param request - The start subscription request.
323
339
  * @returns The checkout session response.
@@ -326,9 +342,11 @@ export class SubscriptionController extends StaticIntervalPollingController() {
326
342
  // get the latest subscriptions state before computing trial eligibility
327
343
  await this.getSubscriptions();
328
344
  this.#assertIsUserNotSubscribed({ products: request.products });
345
+ const isTrialRequested = await this.#getIsTrialRequested(request.products, request.recurringInterval);
329
346
  const response = await this.messenger.call('SubscriptionService:startSubscriptionWithCard', {
330
347
  ...request,
331
- isTrialRequested: this.#getIsTrialRequested(request.products, request.recurringInterval),
348
+ isTrialRequested,
349
+ isEligibleForRefund: await this.#getIsEligibleForRefund(request.isEligibleForRefund),
332
350
  });
333
351
  // note: no need to trigger access token refresh after startSubscriptionWithCard request because this only return stripe checkout session url, subscription not created yet
334
352
  return response;
@@ -339,8 +357,13 @@ export class SubscriptionController extends StaticIntervalPollingController() {
339
357
  * creates the subscription immediately, so local state is refreshed
340
358
  * afterwards.
341
359
  *
342
- * `isTrialRequested` on the request is ignored and overwritten from pricing
343
- * (`trialPeriodDays > 0`) and `trialedProducts`.
360
+ * `isTrialRequested` on the request is ignored and overwritten from
361
+ * `isUserEligibleForTrial` and `trialPeriodDays > 0`. Shield is eligible
362
+ * when it has not been trialed. Money Account Plus is eligible when it has
363
+ * not been trialed and the user is authenticated with social login.
364
+ *
365
+ * `isEligibleForRefund` is sent as provided. When omitted, it is resolved
366
+ * from geolocation (EU/EEA), or `false` if the lookup fails.
344
367
  *
345
368
  * @param request - The start crypto subscription request.
346
369
  * @returns The start crypto subscription response.
@@ -353,7 +376,7 @@ export class SubscriptionController extends StaticIntervalPollingController() {
353
376
  // get the latest subscriptions state before computing trial eligibility
354
377
  await this.#getSubscriptions({ refreshBenefits: false });
355
378
  this.#assertIsUserNotSubscribed({ products: request.products });
356
- const isTrialRequested = this.#getIsTrialRequested(request.products, request.recurringInterval);
379
+ const isTrialRequested = await this.#getIsTrialRequested(request.products, request.recurringInterval);
357
380
  if (request.assertTrialEligibility &&
358
381
  request.isTrialRequested !== isTrialRequested) {
359
382
  throw new Error(SubscriptionDelegationServiceErrorMessage.TrialEligibilityChanged);
@@ -362,6 +385,7 @@ export class SubscriptionController extends StaticIntervalPollingController() {
362
385
  const response = await this.messenger.call('SubscriptionService:startSubscriptionWithCrypto', {
363
386
  ...subscriptionRequest,
364
387
  isTrialRequested,
388
+ isEligibleForRefund: await this.#getIsEligibleForRefund(request.isEligibleForRefund),
365
389
  });
366
390
  // Crypto start creates the subscription immediately (unlike card checkout).
367
391
  await this.getSubscriptions();
@@ -413,7 +437,7 @@ export class SubscriptionController extends StaticIntervalPollingController() {
413
437
  const productPrice = this.#getProductPriceByProductAndPlan(productType, lastSelectedPaymentMethodForProduct.plan);
414
438
  // get the latest subscriptions state before computing trial eligibility
415
439
  await this.#getSubscriptions({ refreshBenefits: false });
416
- const isTrialRequested = this.#getIsTrialRequested([productType], lastSelectedPaymentMethodForProduct.plan);
440
+ const isTrialRequested = await this.#getIsTrialRequested([productType], lastSelectedPaymentMethodForProduct.plan);
417
441
  const currentSubscription = this.getSubscriptionByProduct(productType);
418
442
  this.#assertValidSubscriptionStateForCryptoApproval({
419
443
  productType,
@@ -823,21 +847,42 @@ export class SubscriptionController extends StaticIntervalPollingController() {
823
847
  }
824
848
  /**
825
849
  * Whether a trial should be requested for the given products and plan.
826
- * True only when every product has `trialPeriodDays > 0` and has not
827
- * already been trialed.
850
+ * True only when every product is eligible via `isUserEligibleForTrial`
851
+ * and its price has `trialPeriodDays > 0`.
828
852
  *
829
853
  * @param products - The products to check.
830
854
  * @param plan - The recurring interval to look up pricing for.
831
855
  * @returns Whether a trial should be requested.
832
856
  */
833
- #getIsTrialRequested(products, plan) {
834
- return products.every((productType) => {
835
- if (this.state.trialedProducts.includes(productType)) {
857
+ async #getIsTrialRequested(products, plan) {
858
+ const results = await Promise.all(products.map(async (productType) => {
859
+ if (!(await this.isUserEligibleForTrial(productType))) {
836
860
  return false;
837
861
  }
838
862
  const productPrice = this.#getProductPriceByProductAndPlan(productType, plan);
839
863
  return productPrice.trialPeriodDays > 0;
840
- });
864
+ }));
865
+ return results.every(Boolean);
866
+ }
867
+ /**
868
+ * Returns the caller-provided refund eligibility when set. Otherwise
869
+ * resolves it from geolocation (EU/EEA), or `false` if the lookup fails.
870
+ *
871
+ * @param isEligibleForRefund - Caller-provided eligibility, if any.
872
+ * @returns Whether the user is eligible for a refund.
873
+ */
874
+ async #getIsEligibleForRefund(isEligibleForRefund) {
875
+ if (isEligibleForRefund !== undefined) {
876
+ return isEligibleForRefund;
877
+ }
878
+ try {
879
+ const { country } = await this.messenger.call('GeolocationController:getGeolocationData');
880
+ return (country !== null && REFUND_ELIGIBLE_COUNTRIES.has(country.toUpperCase()));
881
+ }
882
+ catch (error) {
883
+ log('Failed to resolve geolocation for refund eligibility', error);
884
+ return false;
885
+ }
841
886
  }
842
887
  #findCryptoPaymentMethod(productType, cryptoAuthMethod) {
843
888
  const matches = [];