Skip to content

fix: redirect cart payment to purchase details#964

Open
tomrndom wants to merge 1 commit into
masterfrom
fix/cart-redirect-purchase
Open

fix: redirect cart payment to purchase details#964
tomrndom wants to merge 1 commit into
masterfrom
fix/cart-redirect-purchase

Conversation

@tomrndom
Copy link
Copy Markdown

@tomrndom tomrndom commented Jun 5, 2026

ref: https://app.clickup.com/t/86baa4vn9

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • Bug Fixes
    • Fixed payment success redirection to display purchase details instead of returning to the cart page

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Payment Confirmation and Navigation

Layer / File(s) Summary
Payment confirmation response and detail navigation
src/actions/sponsor-cart-actions.js, src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js
confirmPayment now destructures { response } and returns it from the promise chain. PaymentView receives this purchase object and navigates to ${redirectUrl}/${purchase.purchase_id} instead of the base redirectUrl, allowing users to view the newly created purchase immediately after payment succeeds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • fntechgit/summit-admin#748: Introduced the sponsor cart actions module where confirmPayment is defined; this PR refines its promise handling and return value.

Suggested reviewers

  • smarcet
  • santipalenque

Poem

🐰 A rabbit hops through payment flows so bright,
Where responses once vanished in the night,
Now purchase IDs guide the way home,
To detail pages where confirmations roam,
Small changes, grand journeys—navigation's delight! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: redirect cart payment to purchase details' directly and clearly summarizes the main change across both modified files, which involves updating payment success behavior to redirect to a purchase details page instead of the cart page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cart-redirect-purchase

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8243964 and e52ced9.

📒 Files selected for processing (2)
  • src/actions/sponsor-cart-actions.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/payment-view.js

Comment on lines +65 to +66
confirmPayment().then((purchase) => {
history.push(`${redirectUrl}/${purchase.purchase_id}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 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:


🏁 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" || true

Repository: 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."
fi

Repository: 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 || true

Repository: 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"
fi

Repository: 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 || true

Repository: 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 || true

Repository: 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"
fi

Repository: 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 || true

Repository: 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
done

Repository: 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 || true

Repository: 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 || true

Repository: 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
done

Repository: 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.

@tomrndom tomrndom requested a review from smarcet June 5, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant