SkipDocumentación Skipdocs
AAPDWidget

Construir la URL del widget

Componer la URL del widget con order_token y public_key.

Después de que tu backend cree la orden y mintee el widget token, construye la URL que ve el paciente agregando el order token.

Lo que tienes

Después de las dos llamadas backend:

1. POST /orders                  →  { hash: "ord_abc123" }
2. POST /api/spot/widget         →  { widget_token, url: "https://spot.getskip.ai?widget_token=..." }

Lo que entregas al paciente

Agrega &order_token={order_hash} a la URL del widget:

https://spot.getskip.ai?widget_token=550e8400-...&public_key=pk_xxx&order_token=ord_abc123

La presencia de order_token es lo que activa el flujo AAPD dentro del widget. Sin él, el widget trata la sesión como un registro estándar de Spot.

Query paramObligatorioNotas
widget_tokenDevuelto por POST /api/spot/widget.
public_keyYa viene en la URL que retorna Skip; no la quites.
order_tokensí (para AAPD)El hash que retorna POST /orders.

Referencia: bootstrap del backend

async function startCnplSession(patient, totalAmountCLP) {
  // 1. Crear la orden SkipPay (server-side, credencial secreta)
  const orderRes = await fetch("https://pay.getskip.ai/orders", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.SKIPPAY_CLIENT_SECRET}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      reference: `MY-ORDER-${Date.now()}`,
      total_amount: String(totalAmountCLP),
      customer: {
        rut: patient.rut,
        first_name: patient.firstName,
        last_name: patient.lastName,
        email: patient.email,
        phone_number: patient.phoneNumber,
      },
    }),
  });
  const { hash: orderToken } = await orderRes.json();

  // 2. Mintear el widget token de Spot (server-side, public_key)
  const widgetRes = await fetch(
    `https://backend.getskip.ai/api/spot/widget?public_key=${process.env.SKIP_PUBLIC_KEY}`,
    {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        rut: patient.rut,
        user_data: {
          name: patient.firstName,
          surname: patient.lastName,
          email: patient.email,
          phone_number: patient.phoneNumber,
        },
        order_token: orderToken,
      }),
    },
  );
  const { url: widgetUrl } = await widgetRes.json();

  // 3. Agregar order_token para la URL que ve el paciente
  const iframeUrl = `${widgetUrl}&order_token=${orderToken}`;

  return { iframeUrl, orderToken };
}

Devuelve iframeUrl a tu frontend — eso es lo que consume el <iframe src="...">.

On this page