Payment failed alert
A declined payment raises a modal alert with a Retry button that runs a local action in the app, without opening the chat.
Goal
App → track('payment_failed', {'method': 'Visa •••• 4242'}) → an alert “Payment did not go through. Your Visa •••• 4242 was declined…” with Retry payment → the app’s open_checkout handler runs with { retry: true }.
Pieces
- Rule “Payment failed alert” (sample): event
payment_failed, Notify the app with channelalert, tap does not open the chat, tap action Run a local actionopen_checkoutwith args{ "retry": true }, label “Retry payment”. - SDK:
registerAction('open_checkout', (args, ctx) async { … })navigates to checkout.KletsoNotificationHostshows the alert.
Steps
- Fire
payment_failedfrom your payment result handler with the method name in properties. - Register
open_checkoutin the app (the sample shows a snackbar; yours navigates).
Verify
- Simulate
payment_failed→app.notifywithchannel: alertand the local action in the payload. - App: the modal appears over the current screen; Retry payment runs your handler with
origin: notification; the transcript records the local action.
Notes
- Alerts stay until dismissed; use them for failures that need action, banners for information.
- The same rule can also tick Agent speaks first so the chat has context (“I saw the payment failed. Want to try another card?”) when the user opens it later.