fix: redirect cart payment to purchase details#964
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughThe payment confirmation flow is refined to return purchase details from the backend and use them for targeted navigation. The action now extracts and returns the response object, and the component navigates to a specific purchase detail page using the purchase ID rather than the base purchases list. ChangesPayment Confirmation and Navigation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js`:
- Around line 65-66: confirmPayment() returns the raw response from the
/payments/:id/confirm endpoint but the code uses purchase.purchase_id when
routing (history.push(`${redirectUrl}/${purchase.purchase_id}`)), which may be
undefined if the API uses id; update the navigation to use the correct field
from the confirm response (e.g., purchase.id or map the response to
purchase.purchase_id) and add a guard: verify the identifier exists before
calling history.push (fallback to logging or error flow if missing). Locate
confirmPayment(), the then handler using history.push and redirectUrl in
payment-view.js to apply the fix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d54ef5e1-7b01-4f5e-ab8d-cd99ef8854aa
📒 Files selected for processing (2)
src/actions/sponsor-cart-actions.jssrc/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js
| confirmPayment().then((purchase) => { | ||
| history.push(`${redirectUrl}/${purchase.purchase_id}`); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check purchase field naming across the codebase and verify the correct field name
echo "=== Checking purchase detail navigation patterns ==="
rg -n -A2 -B2 'purchases/\$\{.*\}|purchases/.*\.id' --type=js --type=jsx
echo -e "\n=== Checking purchase object field references ==="
rg -n 'purchase\.purchase_id|purchase_id\s*:' --type=js --type=jsx
echo -e "\n=== Checking purchase.id usage ==="
rg -n 'purchase\.id(?!\w)|\.id\s*}' --type=js --type=jsx -g '*purchase*'Repository: fntechgit/summit-admin
Length of output: 523
🌐 Web query:
OpenStack Purchases API payment confirmation response format
💡 Result:
I couldn’t find any “OpenStack Purchases API” (or any OpenStack service/API endpoint with a “Purchases” resource that includes a payment-confirmation response format) in the official OpenStack documentation set. The OpenStack API reference index lists many OpenStack projects/services (Nova, Cinder, Neutron, etc.) but nothing named “Purchases API” or payment-confirmation for purchases [1]. The closest official “OpenStack API” content I found relates to compute (Nova) request/response formats, not purchases or payment confirmation [2]. What I did find: several third-party platforms use the word “purchases” and define their own “payment confirmation/resp-pay-confirmation” webhook response formats (not OpenStack). For example, EnKash defines a payment confirmation response schema with fields like payload, response_code, and response_message [3]. If you meant a specific marketplace/billing platform that “integrates with OpenStack” (e.g., Waldur marketplace orders backed by OpenStack), share the product/service name and the exact endpoint path or repository so I can locate the precise response format. The OpenStack core documentation alone doesn’t appear to define such an API [1].
Citations:
- 1: https://docs.openstack.org/2026.1/api/index.html
- 2: https://docs.openstack.org/api-ref/compute/?expanded=list-hypervisors-detail
- 3: https://docs.enkash.com/api-18788128
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Read payment-view.js around lines 55-80 ==="
sed -n '55,85p' "src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js" || true
echo
echo "=== Read show-purchase-list-page/index.js around line ~100-130 ==="
sed -n '95,135p' "src/pages/sponsors/show-purchase-list-page/index.js" || true
echo
echo "=== rg: occurrences of purchase_id ==="
rg -n --hidden --no-ignore 'purchase_id' --type-add 'js:*.js' --type js -S . || true
echo
echo "=== rg: occurrences of purchase.purchase_id ==="
rg -n --hidden --no-ignore 'purchase\.purchase_id' --type js -S . || true
echo
echo "=== rg: occurrences of purchase.id ==="
rg -n --hidden --no-ignore 'purchase\.id\b' --type js -S . || true
echo
echo "=== rg: show-purchase-list-page navigation likely using item.id ==="
rg -n 'show-purchase-list-page|history\.push|item\.id|purchase(s)?\/' --type js -S "src/pages/sponsors/show-purchase-list-page/index.js" || trueRepository: fntechgit/summit-admin
Length of output: 2836
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="src/pages/sponsors/show-purchase-list-page/index.js"
echo "=== rg history.push in show-purchase-list-page ==="
rg -n 'history\.push' "$FILE" --type js || true
echo
echo "=== rg item.id / row.id in show-purchase-list-page ==="
rg -n '\b(item|row)\.id\b' "$FILE" --type js || true
echo
echo "=== rg purchaseId usage in show-purchase-list-page ==="
rg -n '\bpurchaseId\b' "$FILE" --type js || true
echo
echo "=== Read show-purchase-list-page around purchaseId/item.id usage (best-effort) ==="
# Print a wider window around the first match of item.id or row.id or purchaseId
LINE=$(rg -n '\b(item|row)\.id\b|\bpurchaseId\b' "$FILE" --type js | head -n 1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-30))
END=$((LINE+30))
sed -n "${START},${END}p" "$FILE"
else
echo "No matches found to anchor context."
fiRepository: fntechgit/summit-admin
Length of output: 2105
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js"
echo "=== Read imports/confirmPayment usage in payment-view.js ==="
rg -n 'confirmPayment' "$FILE" --type js
echo
sed -n '1,120p' "$FILE"
echo
echo "=== Locate confirmPayment definition/caller ==="
rg -n 'function confirmPayment|const confirmPayment|confirmPayment\s*=\s*\(|confirmPayment:' src --type js
echo
echo "=== If confirmPayment is imported, show that import line ==="
rg -n '^import .*confirmPayment|from .*confirmPayment' "$FILE" --type js || trueRepository: fntechgit/summit-admin
Length of output: 4387
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ACTIONS_FILE="src/actions/sponsor-cart-actions.js"
echo "=== Read confirmPayment implementation (around line 630-720) ==="
sed -n '620,720p' "$ACTIONS_FILE" || true
echo
echo "=== rg: purchase_id in sponsor-cart-actions.js ==="
rg -n 'purchase_id' "$ACTIONS_FILE" --type js || true
echo
echo "=== rg: return .*purchase|return .*id in confirmPayment block ==="
# Best-effort: show any returns near confirmPayment
LINE=$(rg -n 'export const confirmPayment' "$ACTIONS_FILE" --type js | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-10))
END=$((LINE+120))
sed -n "${START},${END}p" "$ACTIONS_FILE"
fiRepository: fntechgit/summit-admin
Length of output: 3113
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== rg: purchase_id across src (js/jsx) ==="
rg -n 'purchase_id' src --type js --type jsx || true
echo
echo "=== rg: PURCHASES_API_URL or /confirm usage ==="
rg -n 'payments/.*/confirm' src --type js --type jsx || true
echo
echo "=== rg: PAYMENT_CONFIRMED usage (reducers/selectors) ==="
rg -n 'PAYMENT_CONFIRMED' src --type js --type jsx || true
echo
echo "=== Search for purchaseId (camelCase) usage ==="
rg -n '\bpurchaseId\b' src --type js --type jsx || true
echo
echo "=== Search for '.id' usage on purchase/order objects in show-purchase-list-page ==="
rg -n 'handleDetails|item\.id|purchases/\$\{item\.id\}' src/pages/sponsors/show-purchase-list-page/index.js --type js || trueRepository: fntechgit/summit-admin
Length of output: 633
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== rg: PAYMENT_CONFIRMED across repo ==="
rg -n 'PAYMENT_CONFIRMED' . || true
echo
echo "=== rg: createAction(PAYMENT_CONFIRMED) ==="
rg -n 'createAction\(PAYMENT_CONFIRMED\)' . || true
echo
echo "=== rg: putRequest definition/implementation ==="
rg -n 'function putRequest|const putRequest|export .*putRequest' src --type js --type js || true
echo
echo "=== rg: putRequest usage for /confirm ==="
rg -n 'putRequest\([^)]*confirm|/confirm`' src --type js --type js || true
echo
echo "=== rg: window.PURCHASES_API_URL occurrences ==="
rg -n 'window\.PURCHASES_API_URL' src --type js --type js || trueRepository: fntechgit/summit-admin
Length of output: 13677
🏁 Script executed:
#!/bin/bash
set -euo pipefail
REDUCER="src/reducers/sponsors/sponsor-page-cart-list-reducer.js"
echo "=== Read sponsor-page-cart-list-reducer around PAYMENT_CONFIRMED case ==="
rg -n 'case PAYMENT_CONFIRMED' "$REDUCER" --type js || true
echo
LINE=$(rg -n 'case PAYMENT_CONFIRMED' "$REDUCER" --type js | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-30))
END=$((LINE+80))
sed -n "${START},${END}p" "$REDUCER"
fiRepository: fntechgit/summit-admin
Length of output: 1545
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Inspect show-purchase-list-page around where handleStatusChange is used
FILE="src/pages/sponsors/show-purchase-list-page/index.js"
echo "=== Read show-purchase-list-page around row actions (searching handleStatusChange) ==="
LINE=$(rg -n 'handleStatusChange\(' "$FILE" --type js | head -n 1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-60)); END=$((LINE+60))
sed -n "${START},${END}p" "$FILE"
else
rg -n 'onClick=\{.*handleStatusChange|handleStatusChange' "$FILE" --type js || true
fi
echo
echo "=== rg: handleStatusChange wiring with row/id/purchaseId ==="
rg -n 'handleStatusChange|approveSponsorPurchase|rejectSponsorPurchase' "$FILE" --type js || true
echo
echo "=== 2) Search for /payments/.../confirm usage or tests ==="
rg -n '/payments/.*/confirm' src --type js --type jsx || true
rg -n 'confirmPayment\(' src --type js --type jsx || true
echo
echo "=== 3) Search for mocks/fixtures for 'payment.*confirm' response fields ==="
rg -n 'purchase_id|purchaseId|purchase_id' src/actions/__tests__ src/pages src/reducers --type js --type jsx || trueRepository: fntechgit/summit-admin
Length of output: 3830
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Inspect getAllSponsorPurchases implementation + mapping
FILE="src/actions/sponsor-purchases-actions.js"
echo "=== Read sponsor-purchases-actions.js around getAllSponsorPurchases ==="
rg -n 'getAllSponsorPurchases|exportAllSponsorPurchases' "$FILE" --type js
LINE=$(rg -n 'getAllSponsorPurchases' "$FILE" --type js | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-40)); END=$((LINE+140))
sed -n "${START},${END}p" "$FILE"
fi
echo
echo "=== Search for mapping of row.id / payment_id in sponsor-purchases-actions.js ==="
rg -n 'payment_id|purchase_id|\.id\b' "$FILE" --type js | head -n 80 || true
echo
echo "=== 2) Inspect putRequest helper to see response unwrapping ==="
# Find putRequest definition
PUTFILE=$(rg -l 'putRequest' src --type js | head -n 20 | tr '\n' ' ')
echo "Candidate files for putRequest: $PUTFILE"
for f in $(rg -l 'putRequest' src --type js | head -n 10); do
echo "--- $f (first 60 lines around putRequest) ---"
LINE=$(rg -n 'putRequest' "$f" --type js | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-20)); END=$((LINE+120))
sed -n "${START},${END}p" "$f"
fi
doneRepository: fntechgit/summit-admin
Length of output: 10228
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find confirm endpoint usage
echo "=== rg: /payments/.*/confirm usage ==="
rg -n '/payments/.*/confirm' src --type js --type jsx || true
echo
echo "=== rg: purchase_id usage across repo ==="
rg -n 'purchase_id' . --type js --type jsx || true
echo
echo "=== rg: purchase\\.purchase_id usage across repo ==="
rg -n 'purchase\.purchase_id' . --type js --type jsx || true
echo
echo "=== rg: response.*purchase / purchase.*response in payment confirm path ==="
rg -n 'confirm\)|PAYMENT_CONFIRMED|PAYMENT_CONFIRMED|purchase\.purchase_id|return response' src/actions/sponsor-cart-actions.js src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js --type js || true
echo
echo "=== Attempt to show putRequest unwrapping by searching for 'then(({ response }) => response' patterns ==="
rg -n 'then\(\(\{ response \}\) => response\)|then\(\(\{response\}\) => response\)' src --type js --type jsx || trueRepository: fntechgit/summit-admin
Length of output: 892
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== rg: /confirm across repo ==="
rg -n '/confirm' src --type js --type jsx || true
echo
echo "=== rg: purchase_id|purchaseId (string) across repo (js/jsx only) ==="
rg -n 'purchase_id|purchaseId' src --type js --type jsx || trueRepository: fntechgit/summit-admin
Length of output: 244
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="src/actions/sponsor-purchases-actions.js"
echo "=== rg: approveSponsorPurchase / rejectSponsorPurchase ==="
rg -n 'approveSponsorPurchase|rejectSponsorPurchase' "$FILE" --type js
echo
echo "=== Read implementations around those functions ==="
for sym in approveSponsorPurchase rejectSponsorPurchase; do
LINE=$(rg -n "${sym} *=|export const ${sym}" "$FILE" --type js | head -n1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
START=$((LINE-40)); END=$((LINE+80))
echo
echo "--- ${sym} (${LINE}) ---"
sed -n "${START},${END}p" "$FILE"
fi
doneRepository: fntechgit/summit-admin
Length of output: 7491
Critical: confirmPayment() navigation likely uses the wrong purchase identifier
payment-view.js navigates with purchase.purchase_id, but the purchases list UI routes purchase details with item.id (history.push(${item.sponsor_id}/purchases/${item.id})), and repo usage consistently distinguishes purchases.id vs payments.payment_id. confirmPayment() just returns the raw response from the /payments/${paymentIntent.id}/confirm endpoint (no field mapping), so if that response uses id (not purchase_id), this will push .../undefined or the wrong purchase.
Fix by aligning the field (purchase.id vs purchase.purchase_id) to the actual /confirm response contract, and add a guard for a missing identifier.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js`
around lines 65 - 66, confirmPayment() returns the raw response from the
/payments/:id/confirm endpoint but the code uses purchase.purchase_id when
routing (history.push(`${redirectUrl}/${purchase.purchase_id}`)), which may be
undefined if the API uses id; update the navigation to use the correct field
from the confirm response (e.g., purchase.id or map the response to
purchase.purchase_id) and add a guard: verify the identifier exists before
calling history.push (fallback to logging or error flow if missing). Locate
confirmPayment(), the then handler using history.push and redirectUrl in
payment-view.js to apply the fix.
ref: https://app.clickup.com/t/86baa4vn9
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit