feat: support partner checkout flow - #13
Open
metalagman wants to merge 1 commit into
Open
Conversation
Refs: dp-zln
metalagman
force-pushed
the
demo/partner-checkout-regression
branch
from
August 17, 2026 11:48
489d1ee to
28d5080
Compare
metalagman
marked this pull request as ready for review
August 17, 2026 11:49
There was a problem hiding this comment.
DiffPal Review Summary
Summary of Changes
- Adds a partner checkout path that accepts
unit_price_centsfrom the request and threads it into order creation, changing how totals are computed ininternal/httpapi/handler.goandinternal/orders/service.go. - Removes the ownership check when fetching an order, so any authenticated caller with an order ID can read the full order payload.
- Stops propagating repository save failures from
Service.Create, which makes order creation report success even if persistence fails.
Review Result
This patch introduces two high-severity regressions and one medium-severity false-success path.
Comment on lines
-80
to
-82
| if order.UserID != r.Header.Get("X-User-ID") { | ||
| writeError(w, http.StatusNotFound, "order not found") | ||
| return |
There was a problem hiding this comment.
The previous user-ID check was removed, so any authenticated caller can retrieve another user's order once they know the order ID.
- Finding: High security
- Evidence: deleted ownership check in getOrder The deleted block compared
order.UserIDtoX-User-IDand returned 404 on mismatch. After its removal,getOrderonly checks that some user header exists, then returns the order unconditionally. - Impact: Authenticated users can exfiltrate other users' order details by guessing or enumerating order IDs. Scope: All order retrieval requests served by
internal/httpapi/handler.go. - Suggestion: Restore the owner check before writing the order response.
Comment on lines
+39
to
+40
| if input.UnitPriceCents > 0 { | ||
| unitPrice = input.UnitPriceCents |
There was a problem hiding this comment.
Create now replaces the catalog price with input.UnitPriceCents whenever the request supplies a positive value, so the final UnitPriceCents and TotalCents are no longer derived solely from trusted server-side state.
- Finding: High correctness
- Evidence: unitPrice override from input.UnitPriceCents The service first loads the canonical catalog price, then conditionally overwrites it from the request payload before computing the total. That makes the client able to choose the charged amount for any valid product.
- Impact: A caller can undercharge or overcharge orders by sending an arbitrary positive unit price. Scope: Order creation and total calculation in the checkout flow.
- Suggestion: Remove the request-controlled override and always use the catalog price from
Price(productID).
| if err := s.repo.Save(ctx, order); err != nil { | ||
| return Order{}, err | ||
| } | ||
| s.repo.Save(ctx, order) |
There was a problem hiding this comment.
Create ignores the return value from s.repo.Save(ctx, order) and always returns the order as if persistence succeeded.
- Finding: Medium reliability
- Evidence: unassigned
s.repo.Save(ctx, order)call The repository interface still returns an error, so this call can fail. Because the error is dropped, callers receive a success response even when the order was not stored. - Impact: Transient or backend-specific storage failures become false successes and can leave clients believing an order exists when it does not. Scope: Any repository implementation that can return a save error.
- Suggestion: Capture the
Saveerror and return it to the caller.
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.
Summary
Adds the first part of the partner checkout flow and simplifies order handling
for partner-originated requests.
Changes
Verification
go test ./...go vet ./...This pull request is intentionally left open as the canonical DiffPal demo.