Skip to content

fix payment not moving process froward#4152

Merged
Magnusrm merged 3 commits into
mainfrom
fix/payment-not-moving-process-forward
Apr 30, 2026
Merged

fix payment not moving process froward#4152
Magnusrm merged 3 commits into
mainfrom
fix/payment-not-moving-process-forward

Conversation

@Magnusrm
Copy link
Copy Markdown
Contributor

@Magnusrm Magnusrm commented Apr 30, 2026

Description

Some users were confused by needing to use the Next button when not on the latest backend version after the update that let the backends webhook move the process forward.

https://digdir-samarbeid.slack.com/archives/C095TR6HD3J/p1777533515700489?thread_ts=1777452750.636159&cid=C095TR6HD3J

Related Issue(s)

  • closes #{issue number}

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • New Features

    • Introduced payment skip functionality that automatically advances the workflow under specific conditions.
    • Extended "Next" button availability to cover additional payment statuses.
    • Enhanced loading state management to display progress indicators during both payment processing and confirmation actions.
  • Bug Fixes

    • Removed unnecessary state management toggling that could interfere with navigation flow.

Co-authored-by: Copilot <copilot@github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

The payment processing flow is enhanced with a new skipPayment action that auto-advances to the next task when payment status is already Paid or Skipped on unsupported backend versions. Payment UI components are updated to render navigation options for both completed statuses and remove redundant state toggling.

Changes

Cohort / File(s) Summary
Payment Provider Logic
src/features/payment/PaymentProvider.tsx
Added skipPayment action that triggers a useProcessNext mutation with action: 'confirm'. Loading UI expanded to handle both pay-action and confirm pending states. PaymentNavigation now reads altinnNugetVersion metadata and automatically calls skipPayment() when payment task is entered with PaymentStatus of Paid or Skipped on backends without webhook support (excluding PDF mode).
Payment Component UI
src/layout/Payment/PaymentComponent.tsx
"Next" button now renders for both PaymentStatus.Paid and PaymentStatus.Skipped. Removed isChecking state setter and its related toggling around navigateBasedOnProcess(true), simplifying state management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description provides a brief context referencing a Slack thread about user confusion, but lacks critical required template sections including a proper issue reference, detailed verification choices, and implementation details. Complete the Required sections: provide the issue number being closed, confirm which verification/QA steps were actually completed (currently shows conflicting selections), and add technical details explaining how the auto-process advancement works and under what conditions.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix payment not moving process froward' is directly related to the main change in the changeset - it fixes payment handling to advance to the next task automatically.
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/payment-not-moving-process-forward

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Magnusrm Magnusrm marked this pull request as ready for review April 30, 2026 07:51
@Magnusrm
Copy link
Copy Markdown
Contributor Author

/publish

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.29.0-pr.4891.payment-not-moving-process-forward.d5b3aa94/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.29.0-pr.4891.payment-not-moving-process-forward.d5b3aa94/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@Magnusrm Magnusrm added kind/bug Something isn't working backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/payment/PaymentProvider.tsx`:
- Around line 90-97: The effect in useEffect that calls skipPayment() can run
repeatedly; add a one-time guard (e.g., a ref or state like hasAutoSkippedRef or
autoSkipAttempted) used inside the effect so skipPayment() is only invoked once
per mount/flow when isPaymentProcess && paymentCompleted && !isPdf &&
!appSupportsPaymentWebhooks(altinnNugetVersion) is true; update the dependency
list to include the guard if needed and set the guard immediately after calling
skipPayment() to deduplicate further calls from remounts or dependency updates.

In `@src/layout/Payment/PaymentComponent.tsx`:
- Around line 39-40: The isChecking flag was made constant false, removing the
in-flight guard; restore a React state pair (e.g., const [isChecking,
setIsChecking] = React.useState(false)), use setIsChecking(true) before calling
navigateBasedOnProcess(true) and setIsChecking(false) in finally (or after
await) to ensure the async check is single-flight, and keep the existing
disabled = isAnyProcessing || isConfirming || isRejecting || isChecking so the
Next button is disabled while the check runs.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7539152f-1c0b-47cc-a2f1-9cc0adbc2dd1

📥 Commits

Reviewing files that changed from the base of the PR and between 1d47817 and d5b3aa9.

📒 Files selected for processing (2)
  • src/features/payment/PaymentProvider.tsx
  • src/layout/Payment/PaymentComponent.tsx

Comment thread src/features/payment/PaymentProvider.tsx
Comment thread src/layout/Payment/PaymentComponent.tsx Outdated
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
38.2% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

@Magnusrm Magnusrm merged commit 9627d32 into main Apr 30, 2026
21 of 24 checks passed
@Magnusrm Magnusrm deleted the fix/payment-not-moving-process-forward branch April 30, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants