fix(baileys): render the PIX button on Android/iOS, not only on WhatsApp Web - #2742
Open
thiagoluga wants to merge 1 commit into
Open
thiagoluga wants to merge 1 commit into
thiagoluga wants to merge 1 commit into
Conversation
…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
Contributor
Reviewer's GuideUpdates PIX button messages with the metadata, secret, title body, and Sequence diagram for cross-platform PIX message renderingsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
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.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📋 Description
Since 2.4.0 the PIX button (
/message/sendButtonswithtype: "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}andmessageVersion: 1;messageContextInfo.messageSecret;<biz>node whosenative_flowis namedpayment_info(the genericmixednode frombuildInteractiveBizNode()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 waywa-jssends 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
🧪 Testing
Measured on a real number (Baileys connection), looking at WhatsApp Web and two phones (sender and recipient):
documentWithCaptionMessage)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 --noEmitandeslintpass on the changed files.✅ Checklist
📝 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:
Enhancements: