- From your app to the checkout: you pass it data, for example the CLABE to prefill direct debit or the payment methods to show, and the checkout answers whether it accepted it.
- From the checkout to your app: it tells you what happened, for example that the user submitted the payment or closed the checkout without paying.
Web
tapipay.channel in @npmtapi/embed.Android
Tapipay.presentWithChannel() in Kotlin.iOS
Tapipay.channel in Swift.How it works
- You open the checkout as usual:
initialize()on web orpresent()in the native SDKs. - When the checkout loads, it greets the SDK with a
hellomessage that carries the capabilities enabled for your organization. The SDK answers with its ownhelloand the channel is open. - Your app writes input keys with
set. The checkout validates each one and answersackif it applied it, orerrorwith a code if it did not. - The checkout emits output keys (for example,
payment.submitted) and the SDK delivers them to the handlers you registered withon.
hello is queued and goes out in order as soon as the channel opens.
Data sent through the channel stays on the user’s device: it goes from your app to the checkout without passing through the URL or your server. On web, the SDK uses a private channel with the iframe that no other script on your page can read.
Capabilities
Each key has a version (@1). Your organization can only use the capabilities it has enabled, and the checkout only announces those in the hello.
To find out whether a key is available, call
supports("payment.methods") (the key without its version) after the handshake. Before the hello, or if the channel did not open, it always returns false.
domiciliation.prefill
Prefills the CLABE and the account holder’s name in the direct debit form. It applies to both screens where that form appears: the “direct debit” payment method in the payments view and the direct debit enrollment in autopay management.
- It is a prefill: the user sees the data and can edit it before confirming.
- If a value fails validation, the checkout answers
invalid_valueand shows the form empty. - With the checkout open, the prefill only applies to the fields the user has not changed yet. If the user already submitted their account details, the checkout answers
ackbut the prefill has no effect: the CLABE the user submitted is the one that counts. - It is a sensitive key: the SDKs never write it to logs. Do not log it on your side either.
payment.methods
Limits the payment methods your user sees in the payments view. The value is { allowed: [...] }, with at least one method and no duplicates.
- It only restricts. The checkout shows the methods you asked for and that your organization has enabled. If none is left, it answers
invalid_valueand does not change what it shows. - Tapipay defines the order, not the order of your list.
- With the checkout open, the change applies right away, but it does not take your user out of the method they are using: if they already picked it or started entering data, that method stays available until they pick another one.
The channel values are not the same as the ones of the
paymentMethods opening option (CARD, BANK_TRANSFER, etc.). Each SDK gives you a type with the right values for each path.payment.submitted
Arrives when the user submits the payment. The value is { status: "pending", data }: status is always "pending" and data carries the parameters returned by the payment provider, which may be empty.
payment.cancelled
Arrives when the user closes the whole checkout without having submitted a payment. The value is an empty object.
- Native SDKs only. The SDK generates it when the user closes the checkout from the app: the Close button, the back gesture on Android or swiping the sheet down on iOS, also in the middle of 3DS authentication or a redirect.
- It arrives at most once per opening, and never after a
payment.submitted. - It does not arrive when your app closes the checkout with
Tapipay.dismiss(): that is not a user cancellation. - It does not arrive when the user closes the card payment window: they can still pay with another method. For that case, the usual
PaymentCancelled/.paymentCancelledevent keeps arriving. - It never arrives on web. The checkout lives inside your page and has no close of its own, and
tapipay.destroy()is not a cancellation. That is why, on web,supports("payment.cancelled")returnsfalseeven if your organization has it.
payment.submitted@1 and payment.cancelled@1 are on by default and coupled: if your organization turns one off, the checkout announces neither. That way you never receive a “cancelled” without being able to receive the “submitted”.
How to enable it
1
Request the input capabilities
domiciliation.prefill@1 and payment.methods@1 are enabled per organization, on request. Ask your Tapipay contact for them. The output ones are already on.2
Web only: declare your origins
Send Tapipay the list of exact origins of the pages that embed the widget (scheme, domain and port, for example
https://app.acme.com). https: is accepted and, for development, http://localhost. Without that list, the web channel does not open: the widget still works, but without a channel.3
Update the SDK
Use
@npmtapi/embed 1.10.0 or later on web, and version 0.2.0 or later of the Android and iOS SDKs.Responses and errors
Everyset ends in one of two ways: the checkout answers ack (on web the promise resolves; on Android and iOS the function returns without error) or the SDK hands you an error with its code.
Lifecycle
- One channel per opening. Queued
setcalls andonhandlers belong to the checkout being opened. If that checkout closes or never opens, whatever was queued fails withchannel_unavailable: it never moves to another checkout. - Register your handlers again on every opening. When the checkout closes (or, on web, when the last widget is destroyed with
tapipay.destroy()), the SDK removes the handlers. On the next opening, register them again. - If the checkout reloads (for example, because the system recreated the screen), the checkout greets again and the channel reopens with the new capabilities. A
setthat was waiting for an answer may end intimeout: send it again if you need to. - The usual events keep arriving. The channel does not replace the
paymentSubmitted,PaymentSubmittedor.paymentSubmittedevents: they arrive as before, with or without a channel.
Web
Available from@npmtapi/embed 1.10.0, with the embed.js script served by Tapipay.
tapipay.channel. You can use it before or after initialize(): whatever you send before the checkout opens the channel is queued.
The types (
TapipayChannel, TapipayChannelError, TapipayChannelPaymentMethod, etc.) are exported from @npmtapi/embed. In React, get the instance with useTapipay() and use tapipay.channel the same way.
tapipay.channel is exposed by the embed.js served by Tapipay. If you load an older version of the script, tapipay.channel is undefined: use tapipay.channel?. if your code can run against a cached script.- Several widgets on the same page: the channel belongs to the last widget mounted.
setcalls go to that checkout and only that one delivers events. To initialize again, calltapipay.destroy(container)first. - The value travels as a JSON copy. You can pass Vue or MobX reactive objects. If the value cannot be serialized, the
setfails withinvalid_value. - The channel is not available in a hand-built iframe: it needs the SDK. The
postMessagemessages are still emitted as before.
Android
Available fromla.tapipay.ui:button:0.2.0.
build.gradle.kts
Tapipay.presentWithChannel(): it does the same as present() and also returns the channel of that opening. It returns null if the call was ignored because a checkout was already open.
Tapipay.channelreturns the channel of the checkout open right now, ornullif there is none. Prefer the onepresentWithChannel()returns: it belongs to your opening even if another checkout opens later.- Handlers are called on the main thread. A handler that throws does not break the channel.
- Cancelling the coroutine of a
setonly stops waiting for the answer. - The channel API is for Kotlin: from Java you can only use
on,supportsandstate.
iOS
Available from version0.2.0 of the Tapipay package, installed with Swift Package Manager as in the mobile apps SDK.
Package.swift
Tapipay.channel: it belongs to the open checkout or, if there is none, to the next one you open. That is why you can register handlers before calling present().
TapipayChannelis@MainActor: handlers are called on the main thread.- When the checkout starts closing (Close button, swiping the sheet or
Tapipay.dismiss()),Tapipay.channelbecomes a new channel for the next checkout. Whatever you do from then on does not reach the one that is closing. - If you cancel the
Taskof aset, thesetleaves the queue or stops waiting for the answer and throwsCancellationError. - Include
defaultin yourswitchstatements overTapipayChannelError.CodeandTapipayChannelPaymentMethods.Method: new versions may add cases.
Compatibility
The channel is optional and does not change anything you already have integrated.- Without a channel, everything works as before. If you use an older SDK, if your organization does not have a capability or if the channel does not open, the checkout works the same and the usual events keep arriving. Only the channel
setcalls fail, withchannel_unavailableorunsupported_key. - The opening prefill and filter keep working. The
domiciliationPrefilloption (ininitialize()on web and inTapipayConfigon Android and iOS) prefills the CLABE and the account holder when the checkout opens, without depending on the channel. The same goes for thepaymentMethodsoption. - The SDK never reloads the checkout to switch from one path to the other: if
setDomiciliationPrefillfails, there is no automatic retry through the opening option.

