listen(...), input(...), and waitPay(...) block the current plugin run until a matching event arrives, the wait times out, or the user sends the exit code. Payment plugins should handle timeout, cancellation, and amount mismatch explicitly.
listen(waitTime, recallTime?, scope?)
Wait for the next user input in the same chat and account. Timeout returns an empty string "".
Wait time in milliseconds. The runtime normalizes it: default
60000 ms, minimum 1000 ms, and usually maximum 900000 ms.Milliseconds to delay before recalling the user’s message after input is received. If the second parameter is directly
'group', the SDK treats it as scope and sets recallTime to 0.Pass
'group' to allow any member in the same group to answer. If omitted, only the current user is waited for.input(waitTime, recallTime?, scope?)
input(...) is an alias of listen(...) with the same parameters and return value.
input(...) returns the text content. Read media from sender.getMediaItems().
waitPay(exitcode, timeout, amount?)
Wait for a payment event or exit code. It uses the IM, account, chat, and user from the current runtime context to register the payment wait. If payment configuration is unavailable, it falls back to legacy payment-event waiting.
Exit code. During the wait, if the user sends exactly the same text, the method returns that string and ends the wait. Pass an empty string to disable the user exit code.
Wait time in milliseconds. The runtime normalizes it by the input wait limit, usually up to
900000 ms.Expected payment amount. The SDK sends it to the runtime as
expected_amount. undefined, null, or an empty string does not send this field.What amount changes
After you pass a valid amount, the runtime:
- Writes the amount to payment wait metadata
ExpectedAmount. - Writes the amount to payment record
expected_amountwhen payment storage is enabled. - Adds
expected_amountandamount_matchedto the success object. - Sets the transfer link amount to the expected amount for forced Alipay transfer link scenarios. If no amount is passed, the default is
0.01.
What amount does not change
- Timeout still returns the string
"timeout". - Concurrency conflicts still return the string
"busy". - If the user sends
exitcode, the method still returns that exit code string. - Without a successful payment object, it will not invent
expected_amountoramount_matched.
Return values
- Timeout
- Busy
- Exit code
- Payment success
Received payment amount. The runtime also fills compatible
Money. If an event only has received_amount, it uses that to fill money / Money.Uppercase amount field kept for legacy plugins. It is usually the same as
money.Actual received amount in the payment event. Not all channels return this field.
Returned only when the normalized
amount is greater than 0. It is the expected amount for this wait.Whether the received amount matches the expected amount. The runtime compares
money and expected_amount; a difference smaller than 0.001 is treated as matched. If either amount is missing or less than or equal to 0, this is false.Order number generated by the payment wait flow or returned by the channel. When payment configuration is enabled, it usually looks like
pay_<hex>.Payment channel transaction number. Its presence depends on the channel event.
Safe handling template
FAQ
Will the return body always change after I pass amount?
Will the return body always change after I pass amount?
You only see
expected_amount and amount_matched after a successful payment returns an object. If the method returns "timeout", "busy", or the exit code string, the return body is unchanged.Can amount be a string?
Can amount be a string?
Yes. The runtime normalizes numbers, numeric strings, amounts prefixed with
¥ / ¥, and comma-separated amounts into numbers. The JS helper sends expected_amount whenever amount is not undefined, null, or an empty string. If the runtime cannot parse it or the parsed value is less than or equal to 0, it will not add a valid expected_amount to the success object.Does amount automatically reject mismatched payments?
Does amount automatically reject mismatched payments?
Do not assume that. It records the expected amount and returns
amount_matched on success. Some channels or order flows may use the expected amount to help match payment events, but your plugin should still check amount_matched before delivery.atWaitPay()
Check whether the current runtime has a payment wait flow.
| Method | Parameters | Returns |
|---|---|---|
atWaitPay() | None | Promise<boolean> |
Next steps
Events and media items
Learn how to read user-uploaded files after waiting for input.
Payment plugin permissions and config
See manifest headers and parameter declarations.