fix(buy): confirm placed orders via success banner / thank-you URL#15
Merged
Conversation
The post-Place-Order confirmation read recognized only a scraped order id or grand total. When neither matched — e.g. Amazon's confirmation showed 'Order placed, thanks!' with no scrapeable dashed number and stale total selectors — a genuinely placed order fell through to needs_review with the 'order MAY have been placed' warning. Add a positive, first-class success signal: CONFIRMATION_MARKERS (banner text) and CONFIRMATION_URL_MARKERS (thank-you URL fragments) on the base class, checked via _looks_confirmed. _scrape_confirmation now returns (order_id, total, confirmed); buy() routes to placed when any signal is present and only to needs_review when none is. The submitted->never-failed double-order guard is unchanged. Seed markers for Amazon (from the observed success page) and Costco (backup to its order-number detection); both flagged TODO: verify DOM.
The Buy-Now button is injected by the turbo-checkout widget after load, so the static selectors (#buy-now-button, submit.buy-now) never matched and the flow always fell back to add-to-cart -> proceed. Lead with Amazon's own turboState initiate selector [id^=buy-now-button] (from the 2026-06-21 live PDP dump); keep the exact/legacy ids as fallbacks. Also drop the dead #submit\.buy-now guess and refresh the price / add-to-cart comments to note they're verified against the same dump. Place-order and order-total selectors are unchanged — they live on the checkout/confirmation pages, which dump-dom can't reach, so they stay flagged TODO(amazon).
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.
Problem
After clicking Place Order, the buy flow recognized a confirmation by only two signals (
BasePurchaser._scrape_confirmation):ORDER_TOTAL_SELECTORS(Amazon's are staleTODO(amazon)guesses).When neither matched,⚠️ … the order MAY have been placed" warning. This fired on a genuinely successful Amazon order whose confirmation page rendered the canonical "Order placed, thanks!" banner — the code never checked for a success banner or the thank-you URL, so a real success was misreported as ambiguous.
buy()routed to_submitted_unconfirmed→needs_reviewwith the "Fix
Add a positive, first-class success signal:
CONFIRMATION_MARKERS(success-banner body text) andCONFIRMATION_URL_MARKERS(thank-you URL fragments), checked by the new_looks_confirmed(page, body)._scrape_confirmationnow returns(order_id, total, confirmed), whereconfirmedis true on any signal (banner / URL / order id / total). The retry loop breaks as soon as a positive signal appears.buy()decides onconfirmed: a recognized banner/URL is authoritative →placed(review-page total stands in when none scrapes); only a total absence of signal →needs_review."Order placed, thanks!"page +/gp/buy/thankyou) and Costco (backup to its order-number detection). Both flaggedTODO: verify against live DOM.The double-order safety is unchanged: post-
submittedpaths still never reportfailed.Tests
_scrape_confirmationcallers updated to the 3-tuple;_ConfirmPagefixture gained aurl.needs_review).Verification done
roomieorder dump-dom --provider amazon paper_towels: logged-in session OK, price read$30.99, add-to-cart present. dump-dom is read-only and never reaches the thank-you page, so it cannot verify the confirmation markers — those rest on the captured success screenshot and remain flaggedTODO: verify.count=0on the live PDP — worth a future selector refresh.Selector refresh (second commit)
roomieorder dump-dom --provider amazon paper_towelsconfirmed the live PDP DOM:#buy-now-button/submit.buy-nownever matched and the flow always fell back to add-to-cart → proceed. Now leads with Amazon's ownturboStateinitiate selector[id^=buy-now-button], keeping the exact/legacy ids as fallbacks.#submit\.buy-nowguess dropped.count=0was because they live on the checkout/confirmation pages, which a PDP dump can't reach. That is not evidence of staleness, so they stay flaggedTODO(amazon)rather than blindly re-guessed.Follow-ups
TODO(amazon)flags.