Skip to content

feat: Add fiatPayment into transactionData#8093

Open
OGPoyraz wants to merge 3 commits intomainfrom
ogp/7070
Open

feat: Add fiatPayment into transactionData#8093
OGPoyraz wants to merge 3 commits intomainfrom
ogp/7070

Conversation

@OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Mar 3, 2026

Explanation

Adds fiatPayment state to TransactionPayController and introduces an atomic updateFiatPayment API with incremental patch semantics.

TransactionData now includes fiatPayment (selectedPaymentMethodId, amount, quickBuyOrderId), the new TransactionPayController:updateFiatPayment action is registered and exported, and transaction initialization/reset paths now consistently default fiat fields to null (including reset on payment-token changes).

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes the shape and initialization/reset behavior of TransactionPayController per-transaction state, which may affect downstream consumers and state-dependent logic. Adds a new messenger action and mutation path that needs validation across clients integrating pay flows.

Overview
Adds a new fiatPayment object to per-transaction transactionData (tracking amount, selectedPaymentMethodId, and quickBuyOrderId) with default null initialization when a transaction entry is first created.

Introduces an atomic TransactionPayController:updateFiatPayment messenger action and updateFiatPayment helper that applies patch semantics (only updates provided fields; supports clearing via null) and throws if the transaction cannot be found. Updating the payment token now also resets fiatPayment to defaults to clear any prior payment-token-specific fiat state; types/exports and tests are updated accordingly, and the changelog is amended.

Written by Cursor Bugbot for commit d8c2b71. This will update automatically on new commits. Configure here.

@OGPoyraz OGPoyraz requested review from a team as code owners March 3, 2026 13:53
};

/** Action to update fiat payment state for a transaction. */
export type TransactionPayControllerUpdateFiatPaymentAction = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, alphabetical? 😄

/** Fiat payment state stored per transaction. */
export type TransactionFiatPayment = {
/** Entered fiat amount for the selected payment method. */
amount: string | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go with amountFiat to be explicit and avoid breaking changes?

Assuming we'll also want to record the original input value.

/** Selected fiat payment method ID. */
selectedPaymentMethodId: string | null;

/** Quick-buy order ID in normalized format (/providers/{provider}/orders/{id}). */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we don't persist, should we instead store transactionId in the Ramps state?

amount: string | null;

/** Selected fiat payment method ID. */
selectedPaymentMethodId: string | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, if this is required, but can not exist initially, should we instead do an optional instead of null to match other types?

};

/** Request to update fiat payment state for a transaction. */
export type UpdateFiatPaymentRequest = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While they align, should we do a union of TransactionFiatPayment, can always diverge later if needed?


### Added

- Add `fiatPayment` transaction state into `transactionData` and `updateFiatPayment` atomic patch action, including defaults initialization and payment-token reset behavior ([#8093](https://github.com/MetaMask/core/pull/8093))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, is everything after the comma needed?

selectedPaymentMethodId: null,
};

const patch = pickBy(
Copy link
Member

@matthewwalsh0 matthewwalsh0 Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing a pickBy which has implicit overwrite behaviour, should we go the callback route like in updateTransactionConfig so it's explicit and totally flexible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants