Skip to main content
The embed SDK mounts the Tapipay payment widget inside your site. Unlike a manual iframe, it resizes itself, shows a skeleton while loading, and tells you through events what the user is doing. It is the same SDK used by autopay management: a single option (view) decides which screen you mount.
Building a native Android or iOS app? Use the mobile apps SDK.

Installation

TypeScript types ship with the package. You do not need to install anything else.

Entrypoints

<TapipayWidget /> is the recommended path in React: it loads the SDK, mounts the widget and cleans it up on unmount. useTapipay() is the low level hook, for when you need to control initialize() and destroy() yourself. If you are not using a bundler, you do not need to install anything: load the script and work with window.tapipay.

Identify your company

Pass one of these two options, not both:
string
Your company’s slug or alias (for example, acme-corp). It matches the Alias field under Settings β†’ Organization in the dashboard. In data-attrs: data-organization.
string
The company code configured for your organization in Tapipay (for example, MX-S-12345). The format varies between integrations: if you do not know yours, confirm it with your Tapipay contact. In data-attrs: data-company-code.
If you manage many companies or sub-billers, use companyCode: you do not need to know or maintain each company’s slug. If you pass both, companyCode wins.
Every example on this page works the same if you replace organization: "acme-corp" with companyCode: "MX-S-12345".

Quick start

No bundler. The script makes window.tapipay available once loaded.

Options

initialize(options)

If container, identifier or both company identifiers are missing, the SDK mounts nothing and warns in the console.

Filter payment methods (beta)

By default, the widget shows every payment method your company has enabled. If you want your user to see only some of them, pass the paymentMethods option with the list of methods to show.
How it behaves:
  • It only restricts. The widget shows the methods you asked for that your company has enabled. It never enables a method your company does not have.
  • Tapipay defines the order, not the order of your list.
  • If no method is left, the widget shows a β€œNo payment methods available” message.
  • If you omit the option or pass an empty list, every enabled method is shown.
  • A single method: for example, with paymentMethods: ["CARD"] your user only sees card. This way you can have one button per payment method on your site and open the widget with the method they picked.
  • It only applies to the payments view, not to view: "autopay". It is independent from the paymentMethods field of subscriptions.
This option is in beta and applies when the widget mounts. If you want to change the methods with the widget already mounted and know whether the checkout applied the filter, use setPaymentMethods from the app ↔ SDK channel. Both options coexist: this one keeps working the same.

destroy(container)

Unmounts the widget: removes the iframe, the skeleton and the internal listeners.
Calling it matters in a SPA, when unmounting the component that holds the widget. <TapipayWidget /> already does it for you. If you call initialize() again on a container that already has a widget, the SDK destroys it and mounts it again.

loadTapipay(options)

It is idempotent per environment: calling it several times returns the same promise and never injects the script twice. It is compatible with React Strict Mode.

Events

paymentSubmitted means submitted, not confirmed. Its status is always "pending": the user completed the form, but the payment is not settled yet. Never mark a debt as paid based on this event. The real status arrives through the payment notification to your backend.

Payloads

CoDi events

With CoDi, your user enters the phone number linked to their mobile banking, Tapipay sends them a payment request and your user authorizes it from their bank’s app. Both events come from the payment methods view and never include the full phone number, only lastFour.
  • codiPhoneFilled: the phone number entered is valid (10 digits). It is only compared against the last number reported: if your user deletes a digit and types the same number again, it is not repeated, but the sequence A β†’ B β†’ A emits three times.
  • codiPaymentSubmitted: Tapipay accepted the request and sent it to your user’s bank. It does not fire on the button click: if sending fails or the result is uncertain, it does not arrive. amount is an integer, because CoDi rounds up.
codiPaymentSubmitted does not mean your user authorized the payment. The result arrives through the payment notification to your backend.
Both events are available since @npmtapi/embed 1.12.0. With an earlier version of the package they still arrive, because the checkout script is the same, but without the TypeScript types.

In React

Events are passed as props. Watch out for the third name: the event is called paymentCancelled, but the prop is onCancelled. <TapipayWidget /> also accepts every initialize() option (except container), plus environment, className and style for the container.

Channel with the checkout

Since @npmtapi/embed 1.10.0, tapipay.channel gives you a two-way channel with the mounted checkout: you prefill the direct debit CLABE and account holder, limit payment methods with the widget already mounted and receive payment.submitted, with a response (ack or an error with a code) for every piece of data you send.
The channel is optional and does not replace the events on this page, which keep arriving the same. The input capabilities are enabled per organization, on request, and on web you also need to declare the origins of the pages that embed the widget: without that, the channel does not open.

App ↔ SDK channel

Capabilities, how to enable it, responses and errors, and the full API.

Other frameworks

The widget is a client component: it needs "use client".

Staging environment

What the SDK mounts

Knowing which URL the SDK builds helps you debug: if the widget stays blank, open that URL directly in the browser and you will see the real error. externalRequestId and selectionStrategy are added as query params. For example, initialize() with organization: "acme-corp", identifier: "CLI-00042" and externalRequestId: "INV-2026-001" mounts: