Skip to main content

SubscriptionDelegationService Actions

3 actions registered.

NameDeprecated
checkMoneyAccountBalance
prepareDelegation
startSubscriptionWithDelegation

SubscriptionDelegationService:checkMoneyAccountBalance​

Package: @metamask/subscription-controller

Checks whether the Money Account holds enough convertible mUSD value to cover pricing unitAmount × minBillingCyclesForBalance.

Parameters:

NameDescription
requestPayer address and pricing amount fields.

Returns: Balance comparison in mUSD base units (6 decimals).

Handler signature:

(request: MoneyAccountBalanceCheckRequest) => Promise<MoneyAccountBalanceCheckResult>

SubscriptionDelegationService:prepareDelegation​

Package: @metamask/subscription-controller

Prepares a cash-subscription delegation and returns its hash.

Reuses a stored AUS delegation that matches the semantic fingerprint when one exists (ensuring a CHOMP intent is active for its hash, unless skipChompInteractions is true). Reuse classifies period startDate as trial-deferred (> now) vs immediately redeemable, matching creation. When several records match, the latest period startDate is reused so a forceNew replacement is preferred over an older equivalent permission. If there is no match, builds, signs, optionally verifies with CHOMP, persists, and optionally registers a new delegation.

When skipChompInteractions is true, CHOMP verify and intent calls are skipped; the returned hash is computed locally.

Parameters:

NameDescription
requestAuthoritative pricing and payer details for the delegation.
forceNewWhether to create a replacement instead of reusing a matching stored delegation.

Returns: The delegation hash (CHOMP-verified unless skipped) and whether it was created or reused.

Handler signature:

(request: PrepareSubscriptionDelegationRequest, forceNew?: boolean) => Promise<PreparedSubscriptionDelegation>

SubscriptionDelegationService:startSubscriptionWithDelegation​

Package: @metamask/subscription-controller

Runs the complete Money Account subscription checkout authorization flow.

Subscriptions are refreshed first. An active subscription for the product is rejected before Money Account upgrade, delegation signing, persistence, or CHOMP registration.

The caller must obtain user consent and initiate funding before calling. MoneyAccountUpgradeController ensures the Money Account vault delegations and CHOMP intents exist. The Subscription API validates those delegations and the Money Account balance server-side. No payment delegation signing, persistence, or intent mutation occurs before the account is upgraded.

Parameters:

NameDescription
requestProduct selection and Money Account identity.

Returns: The result from SubscriptionController:startSubscriptionWithCrypto.

Handler signature:

(request: StartSubscriptionWithDelegationRequest) => Promise<StartSubscriptionWithDelegationResult>