Skip to content

fix(baileys): render the PIX button on Android/iOS, not only on WhatsApp Web - #2742

Open
thiagoluga wants to merge 1 commit into
evolution-foundation:developfrom
thiagoluga:fix/pix-button-mobile-rendering
Open

thiagoluga wants to merge 1 commit into
evolution-foundation:developfrom
thiagoluga:fix/pix-button-mobile-rendering

Conversation

@thiagoluga

@thiagoluga thiagoluga commented Sep 26, 2026 •

Copy link
Copy Markdown

📋 Description

Since 2.4.0 the PIX button (/message/sendButtons with type: "pix") renders on WhatsApp Web, but on Android/iOS the message is delivered and nothing shows up — no card, no "update WhatsApp" placeholder — on both the sender's and the recipient's phone.

Mobile clients only render the payment card when the message carries:

  • messageParamsJson: {"native_flow_name":"order_details","version":1} and messageVersion: 1;
  • messageContextInfo.messageSecret;
  • a <biz> node whose native_flow is named payment_info (the generic mixed node from buildInteractiveBizNode() is enough for Web only);
  • <bot biz_bot="1"/> in 1:1 chats (skipped for groups/newsletters/broadcast).

This is what evolution-go already sends, with one deliberate difference: evolution-go wraps the message in documentWithCaptionMessage. With that wrapper the card shows on phones but disappears on Web, so here it is sent unwrapped — the same way wa-js sends PIX from inside WhatsApp Web itself.

The button title, previously ignored for PIX, becomes the card body.

Scope: only the PIX branch of buttonMessage. CTA/reply buttons are untouched.

🔗 Related Issue

Refs #2467

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

🧪 Testing

Measured on a real number (Baileys connection), looking at WhatsApp Web and two phones (sender and recipient):

Payload Web Phones
2.4.0-rc2 as released ✅ ❌ nothing shown
evolution-go format (wrapped in documentWithCaptionMessage) ❌ nothing shown ✅
this PR (evolution-go format, unwrapped) ✅ ✅ card + copy key

The test ran on the 2.4.0-rc2 image with the equivalent change applied to the compiled bundle; this PR is the same change in the TypeScript source. tsc --noEmit and eslint pass on the changed files.

  • Manual testing completed
  • Functionality verified in development environment
  • No breaking changes introduced

✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have manually tested my changes thoroughly

📝 Additional Notes

The phone-side requirements were found by elimination; if WhatsApp changes what mobile clients require, the table above is the quickest way to re-check.

Summary by Sourcery

Make PIX button messages render consistently across WhatsApp Web, Android, and iOS.

Bug Fixes:

  • Fix PIX button messages so payment cards render on WhatsApp Android and iOS while preserving rendering on WhatsApp Web.

Enhancements:

  • Include the payment metadata, message context, and chat-specific business nodes required for cross-platform PIX card rendering.
  • Use the PIX button title as the payment card body text.

…App Web

Since 2.4.0 the PIX button (`payment_info`) shows on WhatsApp Web, but on
phones the message is delivered and nothing is displayed - neither the card
nor an error - on the sender's and on the recipient's device.

Mobile clients render the payment card only when the message carries:
- `messageParamsJson` `{"native_flow_name":"order_details","version":1}`
  and `messageVersion: 1`;
- `messageContextInfo.messageSecret`;
- a `<biz>` node whose native_flow is named `payment_info` (the generic
  `mixed` node is enough for Web only);
- `<bot biz_bot="1"/>` in 1:1 chats.

This matches what evolution-go already sends. One difference on purpose:
evolution-go wraps the message in `documentWithCaptionMessage`; with that
wrapper the card shows on phones but disappears on Web, so it is sent
unwrapped (as wa-js does from inside WhatsApp Web itself).

The button title, previously ignored for PIX, becomes the card body.

Refs evolution-foundation#2467
@sourcery-ai

sourcery-ai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Updates PIX button messages with the metadata, secret, title body, and payment_info business nodes required for Android/iOS rendering, while intentionally keeping the message unwrapped so WhatsApp Web continues to display it.

Sequence diagram for cross-platform PIX message rendering

sequenceDiagram
    participant API as BaileysStartupService
    participant Builder as buildPixBizNodes
    participant WA as WhatsApp
    participant Web as WhatsApp Web
    participant Mobile as Android/iOS

    API->>API: Build unwrapped interactiveMessage
    API->>API: Set body.text from title
    API->>API: Set messageParamsJson order_details/version
    API->>API: Set messageVersion and messageSecret
    API->>Builder: buildPixBizNodes(createJid(data.number))
    Builder-->>API: payment_info biz node and optional bot node
    API->>WA: sendMessageWithTyping(message, PIX biz nodes)
    WA-->>Web: Deliver PIX message
    WA-->>Mobile: Deliver PIX message
    Web->>Web: Render PIX card
    Mobile->>Mobile: Render PIX card and copy key
Loading

File-Level Changes

Change Details Files
Add mobile-compatible PIX message metadata and payload content while preserving the unwrapped message format required by WhatsApp Web.
  • Populate the PIX native-flow parameters and message version expected by Android/iOS.
  • Include a generated message secret and use the PIX title as the interactive card body.
  • Keep PIX messages unwrapped so both Web and mobile clients render them.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Generate PIX-specific business stanza nodes with chat-type-aware bot metadata.
  • Emit a payment_info native-flow business node for PIX messages.
  • Add biz_bot="1" only for 1:1 chats, excluding groups, newsletters, and broadcasts.
src/api/integrations/channel/whatsapp/helpers/interactiveMessage.helper.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. This changes externally delivered PIX messages so mobile recipients can see and act on a payment button, and incorrect payment metadata or rendering could mislead recipients or trigger an unintended payment flow. Reverting stops future messages but cannot retract messages already delivered outside the team.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
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