fix: use basketItemsUpdate and checkoutConfirmOrderV4 for REOPENED fulfillment orders#19
Open
tapnl wants to merge 1 commit into
Open
fix: use basketItemsUpdate and checkoutConfirmOrderV4 for REOPENED fulfillment orders#19tapnl wants to merge 1 commit into
tapnl wants to merge 1 commit into
Conversation
Owner
|
Thanks for debugging this nasty issue! Some requests:
|
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
Calling
AddToOrder(PUT/mobile-services/order/v1/items) afterReopenOrdersilently succeeds (HTTP 200) but does not actually modify the fulfillment order.
The order remains empty in the AH app.
Three root causes were identified via mitmproxy traffic analysis of the official
AH iOS app:
1. Wrong endpoint
AddToOrderuses the REST endpoint/mobile-services/order/v1/items.The AH app never uses this endpoint for modifying orders.
It exclusively uses GraphQL.
2. Missing
basketItemsUpdatemutationThe correct way to add/update items in a REOPENED order is the GraphQL mutation:
mutation UpdateMyListBasket($items: [BasketMutation!]!, $input: BasketInput) {
basketItemsUpdate(items: $items, input: $input) {
__typename
status
}
}
With variables:
{
"input": null,
"items": [
{
"id": <product_id>,
"isStrikethrough": false,
"newPosition": 0,
"quantity":
}
]
}
3. Wrong resubmit method
RevertOrder(orderRevertmutation) does not correctly close a REOPENED orderafter item changes. The AH app uses
checkoutConfirmOrderV4instead:mutation CheckoutConfirmOrder($orderId: Int!, $orderInfo: CheckoutConfirmOrderPayloadV4!) {
checkoutConfirmOrderV4(orderId: $orderId, orderInfo: $orderInfo) {
__typename
status
}
}
With variables:
{
"orderId": <order_id>,
"orderInfo": {
"channel": "IOS",
"orderLastModified": "",
"paymentMethod": "PAY_AT_DELIVERY",
"purchaseStampsBookletsApplied": 0
}
}
The
orderLastModifiedtimestamp must be fetched from the basket summaryimmediately after
basketItemsUpdate:query FetchBasketSummary {
basket {
summary {
lastUserChangeDateTime
}
}
}
Fix
Three new functions are needed:
AddToBasket(ctx, items)— usesbasketItemsUpdateGraphQL mutationGetBasketLastModified(ctx)— fetcheslastUserChangeDateTimefrom basket summaryConfirmOrder(ctx, orderID, lastModified)— usescheckoutConfirmOrderV4mutationThe correct flow for modifying a fulfillment order is:
ReopenOrder(ctx, orderID)AddToBasket(ctx, items)GetBasketLastModified(ctx)→ get timestampConfirmOrder(ctx, orderID, timestamp)Additional finding:
/summaries/activereturns no hash for REOPENED ordersGetOrderon a REOPENED order returnshash: "". Theappie-current-order-hashheader is therefore never sent for fulfillment order modifications. This is not
the root cause of the issue (the real problem is the wrong endpoint) but worth
noting.
Environment