You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Payments admin JS: keep other gateways' Capture row hidden, show Refunded status without reload - #3616
Closes Strategy11/formidable-pro#6899 (the add-on copy of the refund fix is Strategy11/formidable-payments#178).
What was broken
Collect a Payment with PayPal or Square selected: switching Payment Type to Recurring and back to One-time showed the Stripe-only Capture Payment row.
On a payment's page, Refund → Confirm left Status on "Completed" until reload.
The Capture Payment row compared 'stripe' !== $selected_gateway, but $selected_gateway is an array, so the row was hidden on load even with Stripe selected.
What changed
frmtrans_admin.js: after switching back to One-time, rows for another gateway are hidden again.
Payment page: Status cell gets frm-payment-status; frm_trans_vars.refunded carries the label; runAjaxLink() sets it after a successful refund response.
Two PHPUnit cases in test_FrmTransLiteActionsController.php.
The add-on's bundled copy (formidable-payments) has the same refund-status gap and is not changed here.
How it was verified
PHPUnit: both new tests fail on master and pass on the branch (red shows as the masked SERIALIZATION_FORMAT error, one failure each). All tests/phpunit/stripe files pass.
Live on Lite + Pro preview env, PayPal selected, Recurring → One-time: master row visible, branch none. Stripe selected: row stays visible on both.
Refund status: ran the script in the browser with the refund request stubbed to Lite's success response. Master leaves "Completed", branch shows "Refunded". Not run against a real Stripe refund.
We reviewed changes in a0b9742...6b906e3 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
Live repro (preview env, Lite on master vs this branch, Collect a Payment action, PayPal selected, Payment Type Recurring then One-time): on master the Stripe-only Capture Payment row comes back (display: block); on the PR it stays hidden (display: none). With Stripe selected the row is visible on the branch. The master checkout has identical copies of the four touched source files, so this is the PR's diff, not drift.
Before (master):
After (PR):
Capture row:(array) plus in_array(..., true) is right for the array post_content['gateway'] the only caller passes. The new PHPUnit case covers paypal, square and stripe.
Refunded status: source-verified, not exercised live. refund_payment() answers with frm_updated_message only on success, actions_js() is already called on the payment page so frm_trans_vars exists, and a failed refund (frm_error_style) leaves the status alone.
CI: PHPUnit green on 7.4/8.0/8.2/8.4, including both new tests. Psalm is red on 912 MissingPureAnnotation errors across the repo, none from code this diff adds. I did not open the DeepSource PHP failure.
Not exercised: the Refund click on a real or stubbed payment (no payment record reachable in the sandbox without a connected gateway), and the Square gateway path.
Notes (non-blocking):
hideOtherGatewayRows() repeats the "hide show_<other gateway> rows unless they carry show_<selected>" loop that toggleGateway() already runs a few lines below. The root cause is that toggleOpts( this, ! show, '.frm_gateway_no_recur' ) reveals every gateway's rows on the way back to One-time. Extending that call to skip rows of unselected gateways, or sharing one helper between both places, would avoid a second copy that can drift.
Neither fix has a JS test. The PHP test pins the markup and the second new test only checks that refunded is localized, which would pass even if runAjaxLink() never set the status. If the repo has a JS unit harness for frmtrans_admin.js, one case each for the One-time switch and the refund success branch would cover the actual behaviour.
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: this duplicates the hide-other-gateway-rows loop in toggleGateway() (the toggleOff.forEach block). Consider one shared helper, or scoping the toggleOpts( this, ! show, '.frm_gateway_no_recur' ) call in toggleSub() so it never reveals rows that belong to an unselected gateway.
The reason will be displayed to describe this comment to others. Learn more.
Keeping this as is. The two loops don't select the same set: toggleGateway() hides every .show_<other gateway> element in the action unless it carries the selected gateway's class, while hideOtherGatewayRows() only touches .frm_gateway_no_recur rows, the ones toggleOpts() just revealed. Sharing one helper means changing what toggleGateway() hides, and that handler has no JS test. Scoping the toggleOpts() call instead means a third selector form in a function that is also used for the frm_trans_sub_opts slide. I would rather do either as its own change with a way to test it. Happy to open a follow-up.
On note 2 (no JS test): Lite has no JS unit harness. package.json only carries Cypress E2E, and those specs need a saved Collect a Payment action and a payment record, neither reachable without a connected gateway. The two PHPUnit cases pin the markup and the localized label; the One-time switch and the refund success branch were run in a browser with the AJAX response stubbed (see the PR body). Leaving the JS side without a spec for now.
The reason will be displayed to describe this comment to others. Learn more.
Approve at 6b906e3 (re-review after Vivi's reply; head is unchanged since my last review, so the live before/after and CI findings above still hold).
Note 2 (no JS test): accepted. Lite has only Cypress E2E, and those specs need a gateway-backed payment record, so a spec isn't practical here. The stubbed-AJAX browser run described in the PR body covers the One-time switch and the refund success branch.
Note 1 (duplicate hide loop): still open, optional. Fine to land as is; worth a follow-up if the two loops start to diverge.
Still not exercised: a Refund click on a real payment, and the Square path.
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
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.
Closes Strategy11/formidable-pro#6899 (the add-on copy of the refund fix is Strategy11/formidable-payments#178).
What was broken
'stripe' !== $selected_gateway, but$selected_gatewayis an array, so the row was hidden on load even with Stripe selected.What changed
frmtrans_admin.js: after switching back to One-time, rows for another gateway are hidden again.capture-payments-upsell.php: usesin_array( 'stripe', (array) $selected_gateway, true ).frm-payment-status;frm_trans_vars.refundedcarries the label;runAjaxLink()sets it after a successful refund response.test_FrmTransLiteActionsController.php.The add-on's bundled copy (formidable-payments) has the same refund-status gap and is not changed here.
How it was verified
SERIALIZATION_FORMATerror, one failure each). Alltests/phpunit/stripefiles pass.visible, branchnone. Stripe selected: row stays visible on both.Before (master):

After:

🤖 Generated with Claude Code