Skip to content

Conversation

@bc-yaroslav-zhmutskyi
Copy link
Contributor

@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi commented Nov 2, 2025

What/Why?

Implement AppSwitch functionality for button strategy

Rollout/Rollback

Revert

Testing

Manual

ScreenRecording_cart.mp4

@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi requested a review from a team as a code owner November 2, 2025 21:16
@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi marked this pull request as draft November 2, 2025 21:16
@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi marked this pull request as ready for review November 3, 2025 23:01
Comment on lines 99 to 105
containerId: string,
methodId: string,
bigcommerce_payments: BigCommercePaymentsButtonInitializeOptions,
isBuyNowFlow?: boolean,
): void {
const { buyNowInitializeOptions, style, onComplete, onEligibilityFailure } =
bigcommerce_payments;
Copy link

Choose a reason for hiding this comment

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

Bug: The renderButton call at line 96 omits isBuyNowFlow, incorrectly enabling appSwitchWhenAvailable in buy-now flows.
Severity: CRITICAL | Confidence: 0.95

🔍 Detailed Analysis

The renderButton method is invoked at line 96 without providing the isBuyNowFlow parameter. This results in isBuyNowFlow being undefined within the method's scope. Consequently, the condition !isBuyNowFlow evaluates to true, causing appSwitchWhenAvailable: true to be incorrectly included in the defaultCallbacks object (lines 115-118) when this.isPaypalCommerceAppSwitchEnabled(methodId) is true, even if the current flow is a buy-now flow. This behavior deviates from the intended logic of enabling app switch only when not in a buy-now flow.

💡 Suggested Fix

Pass the isBuyNowFlow parameter to the renderButton call at line 96. This ensures isBuyNowFlow is correctly evaluated within the method, preventing appSwitchWhenAvailable from being enabled in buy-now flows.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/bigcommerce-payments-integration/src/bigcommerce-payments/bigcommerce-payments-button-strategy.ts#L99-L105

Potential issue: The `renderButton` method is invoked at line 96 without providing the
`isBuyNowFlow` parameter. This results in `isBuyNowFlow` being `undefined` within the
method's scope. Consequently, the condition `!isBuyNowFlow` evaluates to `true`, causing
`appSwitchWhenAvailable: true` to be incorrectly included in the `defaultCallbacks`
object (lines 115-118) when `this.isPaypalCommerceAppSwitchEnabled(methodId)` is true,
even if the current flow is a buy-now flow. This behavior deviates from the intended
logic of enabling app switch only when not in a buy-now flow.

Did we get this right? 👍 / 👎 to inform future reviews.

@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi merged commit bc3e4d3 into master Nov 4, 2025
9 checks passed
@bc-yaroslav-zhmutskyi bc-yaroslav-zhmutskyi deleted the bcp-button-app-switch branch November 4, 2025 08:42
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.

3 participants