Skip to content

Remove stored credit card data from checkout and ordering - #994

Open
Soumilgit wants to merge 4 commits into
dotnet:mainfrom
Soumilgit:fix/issue-979-payment-data
Open

Soumilgit wants to merge 4 commits into
dotnet:mainfrom
Soumilgit:fix/issue-979-payment-data

Conversation

@Soumilgit

@Soumilgit Soumilgit commented Jun 7, 2026 •

Copy link
Copy Markdown

Summary

  • replace checkout/order card fields with a non-sensitive payment method reference
  • stop storing payment card details in Ordering and Identity database schemas
  • remove card details from identity claims, sample data, logs, web checkout, and client mock/order payloads
  • add migrations and update unit/functional test payloads for the new contract

Verification

  • dotnet restore eShop.Web.slnf
  • dotnet build eShop.Web.slnf --no-restore
  • dotnet test tests\Ordering.UnitTests\Ordering.UnitTests.csproj --no-build

Notes

  • Ordering functional tests currently time out during Aspire/DCP startup before API test bodies execute in this local environment.

Addresses #979

Breaking contract change: CreateOrderRequest replaces card details with PaymentToken; clients must send an opaque payment provider token.

@Soumilgit
Soumilgit marked this pull request as ready for review June 7, 2026 04:47
@Soumilgit

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@Soumilgit

Copy link
Copy Markdown
Author

Hi @davidfowl,
Please review this PR.

@Soumilgit

Copy link
Copy Markdown
Author

Hi, any update @davidfowl ?

@DamianEdwards DamianEdwards left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this, removing stored card data is the right direction, and the overall shape looks good. The app keeps its simulated payment flow (PaymentProcessor is still config-driven) but no longer stores, logs, or emits card details as claims.

There's one blocking issue, and a few smaller ones.

Blocking: the new migrations won't be applied. Neither 20260607000000_RemoveSensitivePaymentMethodData nor 20260607000000_RemoveSensitiveCardProfileData has a .Designer.cs file, so neither has the [DbContext]/[Migration] attributes. EF uses those attributes to find migrations, so MigrateAsync (run at startup through AddMigration<>) will skip both. As a result:

  • Identity: AspNetUsers keeps its NOT NULL card columns, but the model no longer writes them, so seeding alice and bob fails.
  • Ordering: paymentmethods has no PaymentMethodId column, and CardNumber/CardHolderName are still required, so checkout fails when it creates the buyer and payment method.

This likely explains the functional test timeouts you mentioned. Please remove the hand-written migrations and regenerate them with dotnet ef migrations add ... for each context, so the Designer files and snapshots are produced together.

Smaller items:

  • Card types are now unused: the CardType entity, the cardtypes table and seed data, the GET /api/orders/cardtypes endpoint, and ClientApp/Models/Orders/CardType.cs. Please remove them (dropping the table in the migration), or explain why they should stay.
  • The CreateOrderRequest contract changes shape (the card fields are replaced by PaymentMethodId). That's fine for this sample, but please mention the breaking change in the PR description.
  • Please rebase on main. The branch is about 19 commits behind.

@Soumilgit

Copy link
Copy Markdown
Author

Thanks for the feedback, @DamianEdwards. Good catch on the migrations and the extra card type cleanup. I'll regenerate them properly with the CLI, address the rest of your notes, and rebase onto main soon.

@Soumilgit
Soumilgit force-pushed the fix/issue-979-payment-data branch from eba9c46 to 00c9f81 Compare November 17, 2026 12:31
Copilot AI balanced review requested due to automatic review settings November 17, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Soumilgit

Soumilgit commented Nov 17, 2026 •

Copy link
Copy Markdown
Author

Hi @DamianEdwards ,
So I've addressed the review feedback, regenerated both EF migrations with designer files, removed the unused CardType feature, added distinct legacy payment-token backfills, and renamed the opaque token to PaymentToken throughout. Also, rebased on main and updated the PR description.
The PR touches several connected areas, and the EF migrations, generated files, and tests for the updated payment flow make the diff larger than usual. Could you take another look when you have a chance?

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.

3 participants