Saltar al contenido principal

Customer & Payment Events

These events handle customer data changes and payment method updates.

customer:update

Dispatched by store when the customer data changes.

eventPayload

Storefront only. When triggered by a login or logout action, this event includes state.eventPayload with context about the action:

PropertyTypeDescription
actionstringThe action that triggered the update: "customer:login" or "customer:logout".
dataobjectThe customer data at the time of the action (matches state.customer). For logout, this is the customer data before the logout.
pathstringAlways "customer".
nota

In checkout, this event may not include eventPayload (it will be null). Always check before accessing.

Example
import type { NubeSDK } from "@tiendanube/nube-sdk-types";

export function App(nube: NubeSDK) {
nube.on("customer:update", ({ customer, eventPayload }) => {
if (eventPayload?.action === "customer:login") {
console.log("Customer logged in:", customer?.contact?.email);
} else if (eventPayload?.action === "customer:logout") {
console.log("Customer logged out");
} else {
console.log("Customer data updated", customer?.contact?.email);
}
});
}

account:register

Storefront only. Dispatched by app to pre-fill (autocomplete) the storefront signup form. Send it with a modifier that returns the customer data to populate; the store merges the provided fields into state.customer.

FieldTypeDescription
namestringCustomer's full name.
emailstringCustomer's email address.
phonestringCustomer's phone number.
cpf_cnpjstringCustomer's identification document (CPF / CNPJ).

All fields are optional — send only the ones you want to pre-fill.

Example
import type { NubeSDK } from "@tiendanube/nube-sdk-types";

export function App(nube: NubeSDK) {
nube.send("account:register", () => ({
customer: {
name: "John Doe",
email: "john@example.com",
phone: "+5511999999999",
cpf_cnpj: "12345678900",
},
}));
}

payment:update

Checkout only. Dispatched by checkout when the payment method changes.

Example
import type { NubeSDK } from "@tiendanube/nube-sdk-types";

export function App(nube: NubeSDK) {
nube.on("payment:update", ({ payment }) => {
console.log("Payment method has changed to:", payment?.selected);
});
}

Help us improve NubeSDK

Found an issue or have a suggestion? Let us know on GitHub.