登录开始免费试用
Meta Tech Provider

在 WhatsApp 上自动发送付款链接

要在 WhatsApp 上自动发送付款链接,可以用付款服务商提供的固定链接回复付款相关问题,并通过“pay”或“pix”等词触发;也可以把消息交给您自己的系统,由它为该客户的订单生成链接,并作为回复返回。客户在服务商的页面上付款,付款到账后,您的系统会在聊天中确认。

easyCoexistence 通过 Coexistence 将您在应用中保留的 WhatsApp Business 号码连接到 Meta 的 Cloud API,并在其上运行自动化:用您的链接做关键词回复,用您自己的密钥接入您自己的 AI,或通过 webhook 连接到为每笔订单生成链接的系统。

20 s

您的系统生成链接并在回复字段中返回所需的时间。

24 hours

Stripe Checkout Session 的默认有效期,可设置为 30 分钟至 24 小时。

metadata

Stripe 会将 Payment Link 的元数据复制到其创建的 Checkout Session 中,因此付款可以追溯到对应的聊天。

Static URL button

按钮不带变量的模板,可以通过自动化中的 Send a template 步骤发送。

Utility

Meta 为由用户操作或请求触发的模板划分的类别,不带推广意图。

WhatsApp 有哪些方式可以自动发送付款链接?

共有五种模式,从无需代码到完全自动化。如果一个价格或一个商店结账页面就能覆盖您的销售,先用固定链接;金额各不相同时,再改用每笔订单单独生成的链接。在每种模式中,付款都在您的服务商页面或应用中完成,因此银行卡号、PIX 转账和收据都不会经过自动化及其运行日志:

Fixed link by keywordHas keyword + Reply with text holding your Payment Link, PIX key or checkout page
Link in the AI's InstructionsReply with AI sends it, copied exactly, when the customer is ready to pay
A link per orderCall my webhook: your system creates the link and returns it as the reply
Template with a link buttonSend a template with a static URL button, inside or outside the 24 hours
Paid confirmationYour system sends it through the Cloud API when the provider reports payment

如何通过关键词发送固定链接?

从 Start from an example 下的 Keyword reply 开始。触发条件为 Has keyword,匹配方式选择 Contains,关键词填写客户想付款时常用的词。步骤选择 Reply with text,链接单独占一行,便于点击或复制;如果需要,也可加入 {{first_name}}。PIX 密钥或银行转账参考号的做法相同。Contains 会匹配单词内部的字符,因此“pay”也会触发 PayPal 和 repay,通常这是可以接受的;而单独的“link”会触发很多无关消息。关键词自动化会先于您的 AI 助手回复,因此链接准确无误,不会被改写。

Keyword reply: words and message (example)
Keywords (Contains): pay, payment, pagar, pagamento, pix, pago, link de pago, checkout

Reply with text:
Hi {{first_name}}! You can pay securely here:
https://buy.stripe.com/test_cN25nr0iZ7bUa7meUY

Prefer PIX? Key: payments@bloomcafe.example
Send the receipt here when you are done and we will confirm.

客户准备付款时,您的 AI 能发送链接吗?

可以,前提是链接写在它的 Instructions 中。Reply with AI 步骤会根据 Instructions 和聊天内容撰写回复,因此请把链接放在那里,并附上发送链接的规则,以及需先确认的顺序。模型会原样复制给定的网址,而 Instructions 中的规则禁止编造价格,所以请列出金额,或说明金额来自何处。

再加两条安全规则:模型绝不能索取卡号或密码,退款或付款失败的问题一律转交人工处理。在打开自动化之前,用 Try it 测试这两点,包括一条其他语言的提问。

Lines to add to the Instructions of a Reply with AI step
Payments
- When the customer confirms the order and wants to pay, send this link on its own line:
  https://buy.stripe.com/test_cN25nr0iZ7bUa7meUY
- Before sending it, repeat the items and the total from the price list above.
- Never ask for card numbers, PINs, passwords or one-time codes. The customer pays on the link.
- Refunds, double charges or failed payments: say someone from our team will reply here shortly.

您的系统如何为每笔订单生成链接?

通过 Call my webhook 步骤实现。您的端点需验证 X-EC-Signature,通过 contact.wa_id 查找客户未完成的订单,或根据 message.text 中的订单号查找;然后向付款服务商请求金额准确的链接,并在回复字段中返回。请把订单 ID 和 WhatsApp 号码放入链接的元数据,以便之后将付款与订单对应。

整个过程请控制在 20 秒以内:一次向服务商的请求通常只需一两秒。如果客户就同一订单再次询问,可以复用仍然有效的链接。测试时将 dry_run 设为 true:只返回一句示例文字,不创建任何内容。

Express handler: a Stripe Checkout Session per order, returned as the reply
// signed(req) is the X-EC-Signature check from the live-data page, with this automation's secret.
app.post("/whatsapp/pay", express.text({ type: "application/json" }), async (req, res) => {
  if (!signed(req)) return res.status(401).end();
  const { dry_run, contact } = JSON.parse(req.body);

  const order = await openOrderFor(contact.wa_id); // your system: this customer's unpaid order
  if (!order) return res.json({ reply: "I could not find an open order for this number. Send the order number and I will check." });
  if (dry_run) return res.json({ reply: "Test: the payment link for order " + order.id + " would go here." });

  const form = new URLSearchParams({
    mode: "payment",
    success_url: "https://shop.example/thanks",
    "line_items[0][quantity]": "1",
    "line_items[0][price_data][currency]": order.currency,               // e.g. "usd" or "brl"
    "line_items[0][price_data][unit_amount]": String(order.amountCents),
    "line_items[0][price_data][product_data][name]": "Order " + order.id,
    "metadata[order_id]": order.id,
    "metadata[wa_id]": contact.wa_id,
  });
  const r = await fetch("https://api.stripe.com/v1/checkout/sessions", {
    method: "POST",
    headers: { Authorization: "Bearer " + process.env.STRIPE_SECRET_KEY },
    body: form,
  });
  const session = await r.json();
  if (!session.url) return res.json({ reply: "The payment link is not ready yet. Someone from our team will send it here shortly." });
  res.json({ reply: "Order " + order.id + ", total " + order.total + ". Pay here:\n" + session.url + "\nThe link stays open for 24 hours." });
});

客户付款后如何收到确认?

由您的系统在服务商通知付款时发出,例如 Stripe 的 checkout.session.completed 事件,其中包含您的元数据。从事件中读取 WhatsApp 号码和订单 ID,然后通过 Meta 的 Cloud API 发送消息,所用的发送端点和访问令牌由 get_api_credentials 返回。在客户最后一条消息发出的 24 小时内,纯文本即可发送。之后,Meta 只接受已获批准的模板;付款确认属于客户自己购买后的通知,符合 utility 类别,不过最终由 Meta 在审核时决定。该消息也会出现在应用的聊天记录中,团队因此能看到订单已付款。

Send the confirmation: text inside the window, template after it
// send_endpoint and access_token come from get_api_credentials for this number.
const insideWindow = Date.now() - lastCustomerMessageAt(waId) < 24 * 3600 * 1000;
await fetch(SEND_ENDPOINT, {
  method: "POST",
  headers: { Authorization: "Bearer " + ACCESS_TOKEN, "Content-Type": "application/json" },
  body: JSON.stringify(insideWindow
    ? { messaging_product: "whatsapp", to: waId, type: "text",
        text: { body: "Payment received for order " + orderId + ". Thank you! We will let you know when it ships." } }
    : { messaging_product: "whatsapp", to: waId, type: "template",
        template: { name: "payment_received", language: { code: "en" },
          components: [{ type: "body", parameters: [{ type: "text", text: orderId }] }] } }),
});

模板能否附带付款按钮?

可以,使用固定网址即可。Send a template 步骤可以发送已获批准的模板,其按钮不含变量:例如指向您结账页面或固定 Payment Link 的 URL 按钮,或 Pay now、Talk to us 等快速回复按钮。客户点击快速回复后,内容会以文本形式返回,关键词自动化即可据此回复链接。正文变量按位置填充,因此金额或订单号应分别放在 {{1}} 和 {{2}}。

带变量的 URL 按钮(例如每笔订单链接所需的那种)以及复制代码按钮,目前自动化无法填充;这类模板需由您的系统通过 Cloud API 发送。Meta 按消息数量、类别和国家或地区对模板消息计费,费用计入您自己的 WhatsApp Business Account。

设置方法

  1. Create the link at your providerMake a Payment Link or a checkout page for the product, or note your PIX key. Open it once on a phone to check the amount and the page.
  2. Start a keyword automationIn Automations, click New automation and pick Keyword reply under Start from an example. Choose Contains and enter your payment words, one per line.
  3. Write the replyIn Reply with text, put a short greeting with {{first_name}} and the link on its own line. Save with the switch Off.
  4. Test the wordsClick Test and run "how do I pay?", "quero pagar" and an unrelated message with Run test, to see which ones match and what the customer would receive.
  5. Switch it OnSet the switch to On and save. Write "pay" from another phone and tap the link to check it opens the payment page.

常见错误

  • 让 AI 在聊天中收集银行卡信息。请在 Instructions 中添加一行,禁止索取卡号、PIN 码和验证码,改为发送服务商的链接;聊天消息会在运行日志中保留 30 天。
  • 发送已过期的会话链接。Stripe Checkout Session 默认 24 小时后失效,客户次日回来时点击的就是已失效的链接;请在客户要求时重新生成。
  • 事后用自由文本确认付款。客户最后一条消息发出 24 小时后,Meta 会拒绝自由格式文本,因此付款确认请保留一个已获批准的 utility 模板。
  • 在返回链接的 webhook 之后又添加固定回复。两者都会发送,客户会收到链接以及第二条通用消息。
使用 EasyCoexistence 完成这些操作

它不接触资金:客户直接向您的付款服务商付款,Meta 按原价向您自己的账户计费消息,不加价。每个号码每月 US$ 9 起,号码越多越便宜,最低降至 US$ 0.75,前 3 天免费。

常见问题

easyCoexistence 会处理付款吗?

不会。它只发送承载链接的文本或模板,付款发生在客户与您的服务商之间,例如 Stripe、Mercado Pago 或您银行的 PIX。手续费、结算、退款和收据都保留在您服务商的控制台中。

客户能否不离开聊天完成付款?

自动化无法做到,因为它只发送文本和模板,客户需要打开服务商的页面。Meta 自有的聊天内付款消息仅在部分市场提供,由企业系统通过 Cloud API 发送;请在 Meta 付款文档中查看您所在国家或地区的情况。

我的系统如何知道付款属于哪个聊天?

创建链接时,请把 contact.wa_id 和订单 ID 放入链接的元数据。服务商通知付款后,读取这两项信息来更新订单,并将确认消息发送到正确的号码。

能否向几天没有回复的客户发送付款提醒?

可以,使用已获批准的模板,由您的系统或您的 AI 通过 send_template 发送,因为客户最后一条消息 24 小时之后,Meta 会拒绝自由文本。提醒只发送给同意接收的客户,并且不要在 utility 模板中加入推广内容。

继续阅读

准备开始了吗?

几分钟即可设置 WhatsApp Coexistence,而不是几个月。应用会继续在手机上运行。

开始免费试用

验证时间