Skip to main content
The app ↔ SDK channel is two-way communication between your app (or your page) and the Tapipay checkout that the SDKs mount:
  • 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.
It works the same in the web SDK and in the Android and iOS SDKs: the same keys, the same responses and the same error codes. Only each platform’s syntax changes.

Web

tapipay.channel in @npmtapi/embed.

Android

Tapipay.presentWithChannel() in Kotlin.

iOS

Tapipay.channel in Swift.

How it works

  1. You open the checkout as usual: initialize() on web or present() in the native SDKs.
  2. When the checkout loads, it greets the SDK with a hello message that carries the capabilities enabled for your organization. The SDK answers with its own hello and the channel is open.
  3. Your app writes input keys with set. The checkout validates each one and answers ack if it applied it, or error with a code if it did not.
  4. The checkout emits output keys (for example, payment.submitted) and the SDK delivers them to the handlers you registered with on.
You do not need to wait for the checkout to finish loading: whatever you send before the 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_value and 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 ack but 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_value and 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.submitted means submitted, not settled. Never mark a debt as paid with this event: the real status reaches your backend through the payment notification.

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 / .paymentCancelled event 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") returns false even 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.
The native SDKs do not need to declare origins: the channel is bound to the checkout the SDK itself opens.

Responses and errors

Every set 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.
Treat any code not in this table as a generic error: new versions may add codes. A channel error never interrupts the checkout flow: the user can still pay or type their CLABE by hand.

Lifecycle

  • One channel per opening. Queued set calls and on handlers belong to the checkout being opened. If that checkout closes or never opens, whatever was queued fails with channel_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 set that was waiting for an answer may end in timeout: send it again if you need to.
  • The usual events keep arriving. The channel does not replace the paymentSubmitted, PaymentSubmitted or .paymentSubmitted events: 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.
The channel is 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. set calls go to that checkout and only that one delivers events. To initialize again, call tapipay.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 set fails with invalid_value.
  • The channel is not available in a hand-built iframe: it needs the SDK. The postMessage messages are still emitted as before.

Android

Available from la.tapipay.ui:button:0.2.0.
build.gradle.kts
Open the checkout with 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.channel returns the channel of the checkout open right now, or null if there is none. Prefer the one presentWithChannel() 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 set only stops waiting for the answer.
  • The channel API is for Kotlin: from Java you can only use on, supports and state.
On devices whose WebView does not support WEB_MESSAGE_LISTENER (very outdated versions of Android System WebView), the channel does not open: set calls fail with CHANNEL_UNAVAILABLE and only the usual events arrive. The checkout keeps working.

iOS

Available from version 0.2.0 of the Tapipay package, installed with Swift Package Manager as in the mobile apps SDK.
Package.swift
The channel is 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().
  • TapipayChannel is @MainActor: handlers are called on the main thread.
  • When the checkout starts closing (Close button, swiping the sheet or Tapipay.dismiss()), Tapipay.channel becomes 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 Task of a set, the set leaves the queue or stops waiting for the answer and throws CancellationError.
  • Include default in your switch statements over TapipayChannelError.Code and TapipayChannelPaymentMethods.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 set calls fail, with channel_unavailable or unsupported_key.
  • The opening prefill and filter keep working. The domiciliationPrefill option (in initialize() on web and in TapipayConfig on Android and iOS) prefills the CLABE and the account holder when the checkout opens, without depending on the channel. The same goes for the paymentMethods option.
  • The SDK never reloads the checkout to switch from one path to the other: if setDomiciliationPrefill fails, there is no automatic retry through the opening option.
Do not send the same prefill through both paths: the checkout could apply both. Pick one per organization, or check supports("domiciliation.prefill") after the handshake to decide.