在 WhatsApp 自動發送付款連結
要在 WhatsApp 自動發送付款連結,可以用付款服務商提供的固定連結回覆付款相關的查詢,並由「pay」或「pix」等字詞觸發;也可以把訊息交給您自己的系統,由系統為該客戶的訂單建立連結,並以回覆形式傳回。客戶在服務商的頁面付款,款項確認後,系統會在對話中作出確認。
easyCoexistence 透過 Coexistence,把您在應用程式中保留的 WhatsApp Business 號碼連接至 Meta 的 Cloud API,並在其上運行自動化:可以是附上您連結的關鍵字回覆、以您自己的金鑰運行的 AI,或是把請求轉往為每份訂單建立連結的系統的 webhook。
您的系統建立連結並於回覆欄位傳回的時限。
Stripe Checkout Session 的預設有效期,可設定為 30 分鐘至 24 小時。
Stripe 會把 Payment Link 的 metadata 複製到它建立的 Checkout Session,因此付款可追溯至對話。
沒有變數的按鈕範本,可由自動化流程的「Send a template」步驟發送。
Meta 為由用戶操作或請求觸發、且不含推廣意圖的範本所設的類別。
WhatsApp 有哪些方式可以自動發送付款連結?
共有 5 種模式,由完全不需寫程式到全自動都有。若一個價格或一個商店結帳頁已涵蓋您的銷售,先用固定連結;金額各異時,再改為逐單連結。在每種模式下,付款本身都在服務商的頁面或應用程式內完成,因此卡號、PIX 轉帳與收據都不會經過自動化流程或其運行記錄:
如何按關鍵字發送固定連結?
從「Start from an example」下的「Keyword reply」開始。觸發條件選「Has keyword」,比對方式選「Contains」,關鍵字填客戶想付款時會用的字詞。步驟選「Reply with text」,連結須獨立成一行,方便點擊或複製;如有需要,可加入 {{first_name}}。PIX 密鑰或銀行轉帳參考的做法相同。「Contains」會比對字詞內部,因此「pay」也會觸發 PayPal 和 repay,這通常是好事;但單獨一個「link」則會誤觸很多無關訊息。關鍵字自動化會先於您的 AI 助理回覆,因此連結準確無誤,絕不會被改寫。
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 能否發送連結?
可以,只要連結已寫入其指示。「Reply with AI」步驟會根據指示及對話內容撰寫回覆,因此請把連結放進指示,並附上發送的時機及須先確認的順序。模型會原樣複製所給的網址,而指示中加入的規則禁止它虛構價格,所以請列出金額,或說明價格來源。
另加兩條安全規則:模型絕不可索取卡號或密碼,任何有關退款或付款失敗的問題都須交由真人處理。開啟自動化前,請先用「Try it」測試這兩點,包括以另一種語言提問。
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 號碼放入連結的 metadata,以便日後把付款對回訂單。
請把整個流程控制在 20 秒以內:一次向服務商的呼叫通常只需 1 至 2 秒。若客戶就同一訂單再次索取,可重用仍然有效的連結。測試時把 dry_run 設為 true:只回傳一句示範文字,不建立任何連結。
// 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 事件,當中帶有您的 metadata。從事件中讀取 WhatsApp 號碼及訂單 ID,再透過 Meta 的 Cloud API 發送訊息,所用的發送端點與存取權杖由 get_api_credentials 回傳。客戶最後一次發來訊息的 24 小時內,可以發送純文字。之後,Meta 只接受已核准的範本;付款確認屬於客戶自己的購買行為,符合 utility 類別,但最終須由 Meta 審核決定。此訊息同時會出現在應用程式的對話串中,團隊因此可知訂單已付款。
// 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 的網址按鈕,或是「Pay now」及「Talk to us」等快速回覆按鈕。客戶點選後,回覆會以文字形式傳回,因此關鍵字自動化可再以連結回應。內文變數按位置填入,所以金額或訂單號碼應放入 {{1}} 及 {{2}}。
帶變數的網址按鈕(逐單連結所需的形式),以及複製驗證碼按鈕,目前都不能由自動化填入;此類範本須由您的系統透過 Cloud API 發送。Meta 按訊息逐則收費,並按類別及國家計算,費用記入您自己的 WhatsApp Business Account。
設定方法
- 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.
- 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.
- 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.
- 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.
- 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 在對話中收集卡資料。請在指示中加入一句,禁止索取卡號、PIN 碼及驗證碼,改為發送服務商的連結;對話訊息會在運行記錄中保留 30 天。
- 發送已過期的會話連結。Stripe Checkout Session 預設有效期為 24 小時,所以翌日回來的客戶點按時會遇到失效連結;應於客戶要求時重新建立。
- 數日後以自由格式訊息確認付款。客戶最後一次發來訊息後超過 24 小時,Meta 會拒絕自由格式訊息,因此確認訊息應保留一個已核准的 utility 範本。
- 在傳回連結的 webhook 之後再加入固定回覆。兩者都會發送,客戶便會收到連結,以及另一則內容籠統的通用訊息。
它不經手款項:客戶直接向您的服務商付款,Meta 則按實際費用直接向您自己的帳戶收取訊息費用,不加價。每個已連接號碼每月 US$ 9 起,號碼越多越便宜,最低降至 US$ 0.75,並附首 3 天免費試用。
常見問題
easyCoexistence 會處理付款嗎?
不會。它只發送承載連結的文字或範本,付款則在客戶與您的服務商之間完成,例如 Stripe、Mercado Pago 或您銀行的 PIX。手續費、撥款、退款及收據均保留在服務商的控制台內。
客戶可否不離開對話而付款?
不可以。自動化只發送文字及範本,客戶需要打開服務商的頁面。Meta 自家的對話內付款訊息僅在部分市場提供,並由商家的系統透過 Cloud API 發送;請查閱 Meta 付款文件,確認您所在國家的情況。
我的系統如何知道付款屬於哪個對話?
在建立連結時,把 contact.wa_id 及訂單 ID 放入連結的 metadata。服務商回報付款後,讀取這兩項資料,即可更新訂單,並把確認訊息發送到正確的號碼。
對於數日沒有回覆的人,我可以發送付款提醒嗎?
可以,由您的系統或您的 AI 透過 send_template 發送已核准的範本即可,因為客戶最後一次發來訊息的 24 小時後,自由格式訊息會被拒絕。提醒只應發給同意接收的客戶,並且不要把推廣內容放進 utility 範本。
繼續閱讀
準備開始嗎?
幾分鐘內設定 WhatsApp Coexistence,而非幾個月。應用程式在手機上仍可繼續運作。
開始免費試用驗證日期