# Tilopay.Init()

> Starts a purchase: authenticates the checkout and returns the environment, the available payment methods and the customer's saved cards.

- kind: sdk-method
- status: stable
- sdk_version: 2.1.1
- last_verified: 2026-10-22
- url: https://tilopay.com/en/developers/sdk/reference/init

Starts a purchase. It authenticates the checkout with the SDK token and returns the payment
methods available to you.

To save a card without charging it, use
[`Tilopay.InitTokenize()`](/en/developers/sdk/reference/init-tokenize).

## Signature [#firma]

```js
await Tilopay.Init({ /* parameters */ })
```

## Parameters [#parametros]

<Param id="init-webhook" name="webhook" type="string">
URL where Tilopay notifies the outcome of SINPE Móvil and Yappy payments.
</Param>

<Param id="init-token" name="token" type="string" required>
SDK token, obtained by your backend with `POST /api/v1/loginSdk`. See
[SDK token](/en/developers/api/autenticacion/token-sdk).
</Param>

<Param id="init-currency" name="currency" type="string" required>
Purchase currency, ISO 4217.
</Param>

<Param id="init-language" name="language" type="string" required>
Checkout language: `es` or `en`.
</Param>

<Param id="init-amount" name="amount" type="decimal (12,2)" required>
Purchase amount.
</Param>

<Param id="init-billtoemail" name="billToEmail" type="string" required>
Customer email. Needed for the response to include saved cards.
</Param>

<Param id="init-ordernumber" name="orderNumber" type="string" required>
Order number. **It cannot be repeated.** See
[safe retries](/en/developers/reintentos-seguros).
</Param>

<Param id="init-typedni" name="typeDni" type="integer">
Customer identification type. Required for SINPE Móvil. See the
[type table](/en/developers/sdk/reference/update-options#tipos-de-identificacion).
</Param>

<Param id="init-dni" name="dni" type="string">
Customer identification number. Required for SINPE Móvil.
</Param>

<Param id="init-billtofirstname" name="billToFirstName" type="string">
Customer first name.
</Param>

<Param id="init-billtolastname" name="billToLastName" type="string">
Customer last name.
</Param>

<Param id="init-billtoaddress" name="billToAddress" type="string">
Customer address line 1.
</Param>

<Param id="init-billtoaddress2" name="billToAddress2" type="string">
Customer address line 2.
</Param>

<Param id="init-billtocity" name="billToCity" type="string">
City.
</Param>

<Param id="init-billtostate" name="billToState" type="string">
State or province.
</Param>

<Param id="init-billtozippostcode" name="billToZipPostCode" type="string">
Postal code.
</Param>

<Param id="init-billtocountry" name="billToCountry" type="string">
Country, ISO 3166-1 alpha-2.
</Param>

<Param id="init-billtotelephone" name="billToTelephone" type="string">
Customer phone.
</Param>

<Param id="init-shiptofirstname" name="shipToFirstName" type="string">
Shipping recipient first name.
</Param>

<Param id="init-shiptolastname" name="shipToLastName" type="string">
Shipping recipient last name.
</Param>

<Param id="init-shiptoaddress" name="shipToAddress" type="string">
Shipping address line 1.
</Param>

<Param id="init-shiptoaddress2" name="shipToAddress2" type="string">
Shipping address line 2.
</Param>

<Param id="init-shiptocity" name="shipToCity" type="string">
Shipping city.
</Param>

<Param id="init-shiptostate" name="shipToState" type="string">
Shipping state or province.
</Param>

<Param id="init-shiptozippostcode" name="shipToZipPostCode" type="string">
Shipping postal code.
</Param>

<Param id="init-shiptocountry" name="shipToCountry" type="string">
Shipping country, ISO 3166-1 alpha-2.
</Param>

<Param id="init-shiptotelephone" name="shipToTelephone" type="string">
Shipping phone.
</Param>

<Param id="init-capture" name="capture" type="integer">
`0` authorizes; `1` authorizes and captures.
</Param>

<Param id="init-redirect" name="redirect" type="string (URL)">
URL where the SDK renders the final purchase response.
</Param>

<Param id="init-subscription" name="subscription" type="integer">
`1` saves the customer card in Tilopay; `0` does not save it.
</Param>

<Param id="init-hashversion" name="hashVersion" type="string">
Values `"V1"` or `"V2"`. If omitted, the final response hash is built with **V2**. It is
sent in this first call.
</Param>

<Param id="init-returndata" name="returnData" type="string">
Returned as-is in the final payment response and recovered on the transaction
response URL. Supports up to **65,535 characters**, although a very long value can affect
the response URL. You can send a base64-serialized array so it satisfies the string format.
</Param>

<Param id="init-phoneyappy" name="phoneYappy" type="string">
Yappy phone. Required when paying with Yappy. It is not read from the DOM.
</Param>

## Call [#llamada]

```js
const init = await Tilopay.Init({
  token: "<token_del_sdk>",
  currency: "CRC",
  language: "es",
  amount: 100.0,
  billToEmail: "cliente@ejemplo.com",
  orderNumber: "ORD-2026-000123",
  billToFirstName: "Ana",
  billToLastName: "Rojas",
  billToCountry: "CR",
  capture: 1,
  redirect: "https://ejemplo.com/respuesta",
  subscription: 0,
});
```

## Response [#respuesta]

```json
{
  "message": "Success",
  "environment": "PROD",
  "sinpemovil": { "code": "TB095", "amount": "100.00" },
  "methods": [
    { "id": "<id_del_metodo_tarjeta>", "name": "Tarjeta", "type": "card", "apple_pay": 0 },
    { "id": "<id_del_metodo_sinpe>", "name": "SINPE Móvil", "type": "sinpemovil", "apple_pay": 0 }
  ],
  "cards": [
    { "id": "411112555451111:Ref", "name": "4111********1111", "brand": "visa" }
  ],
  "applePaySupported": false
}
```

<Param id="init-res-message" name="message" type="string">
`Success`, or the error description.
</Param>

<Param id="init-res-test" name="environment" type="string">
`"PROD"` production, `"TEST"` testing. See [environments](/en/developers/entornos).
</Param>

<Param id="init-res-sinpemovil" name="sinpemovil" type="object">
Object with `code` and `amount`, present when you have SINPE Móvil. The full data,
including the destination phone, is obtained with
[`getSinpeMovil()`](/en/developers/sdk/reference/get-sinpe-movil).
</Param>

<Param id="init-res-methods" name="methods" type="array">
Array of `{id, name, type, apple_pay}` with available methods. `type` is `card`, `sinpemovil` or `yappy`; every method includes `apple_pay` (`0` or `1`).
</Param>

<Param id="init-res-cards" name="cards" type="array">
Array of `{id, name, brand}` with the customer's saved cards.
</Param>

<Param id="init-res-applepaysupported" name="applePaySupported" type="boolean">
`true` when the [Apple Pay](/en/developers/sdk/apple-pay) requirements are met for that domain
and browser.
</Param>

### On error [#respuesta-de-error]

On error:

```json
{
  "message": "<error description>",
  "methods": [],
  "cards": []
}
```

## Payment method id format [#formato-id-metodo]

Do not interpret the id: store it as-is as the select value and use each method's `type` field
(`card`, `sinpemovil` or `yappy`) to decide which fields to show.

## Yappy [#yappy]

The method has `type: "yappy"`; its id has the form `<configId>:18:<merchantId>:…`.

The form needs the required `Init()` fields plus `phoneYappy`. Calling `startPayment()` redirects to a Tilopay page that opens Yappy; the customer approves in their app. When finished, Tilopay notifies `webhook` (if provided) and redirects to your `redirect` with `code`, `auth`, `order` and `OrderHash`. Cancellation rejects the order; without a response within **7 minutes**, it becomes “Transaction expired”.

## Saved cards [#tarjetas-guardadas]

- For the response to include `cards`, **`billToEmail` is required**.
- Once the cards are obtained, **the email can no longer be changed** with
  [`updateOptions()`](/en/developers/sdk/reference/update-options).
- The customer can pick a saved card or type a new one.
- When a saved card is picked, **enable `tlpy_cvv`** so the customer can type the code.
