Deduplicate deals and use consistent unique_app_id#3539
Open
Deduplicate deals and use consistent unique_app_id#3539
Conversation
Prevent duplicate cart-add deals by looking up existing deals by dealname and a new consistent unique_app_id before creating; update existing deals when found. Change OrderToDealSerializer.get_unique_app_id to generate a stable ID based on purchaser email and the purchasable object (fallback to order id for orders without lines) so cart-add and checkout flows use the same identifier. Update tests to assert the new unique_app_id generation logic.
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
for more information, see https://pre-commit.ci
…-both-xpro-and-mitxonline-accounts' of https://github.com/mitodl/mitxonline into 11103-hubspot-deals-are-begin-duplicated-and-created-in-both-xpro-and-mitxonline-accounts
rhysyngsun
reviewed
May 1, 2026
…-created-in-both-xpro-and-mitxonline-accounts
annagav
approved these changes
May 5, 2026
Contributor
There was a problem hiding this comment.
I think this is working. I was able to verify that the deal was created on "add_to_cart" and updated on checkout. However, I had to use coupon for checkout in order to close the order.
I saw some strange things which I think were happening because I could add multiple courses to cart, so I hope that is not an issue.
Another, thing is that we usually don't create an order on "add_to_cart" (at least that was the behavior I see locally), but when we sync this "event" with hubspot an order was created in order to sync, and when I further checkout out I verified that it didn't get duplicated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevent duplicate cart-add deals by looking up existing deals by dealname and a new consistent unique_app_id before creating; update existing deals when found. Change OrderToDealSerializer.get_unique_app_id to generate a stable ID based on purchaser email and the purchasable object (fallback to order id for orders without lines) so cart-add and checkout flows use the same identifier. Update tests to assert the new unique_app_id generation logic.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/11103
Description (What does it do?)
Hoping that this fixes an issue where multiple new deals were being created between the mitx online and xpro hubspot accounts, and sometimes duplicated on the same hubspot account, when a user adds a UAI course to their cart and completes the checkout process.
How can this be tested?
is_uai_course_run.