<mxfile host="app.diagrams.net" agent="ApiPay Hub docs-portal" type="device" version="24.7.17">
  <diagram id="apipay-inscripcion-medio-pago" name="Inscripcion de un medio de pago guardado">
    <mxGraphModel dx="1800" dy="1600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="826" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />

        <mxCell id="ll-ec" value="Backend del comercio&lt;br&gt;sk_test_" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;collapsible=0;recursiveResize=0;outlineConnect=0;size=50;fillColor=#FFF8E1;strokeColor=#F9A825;fontColor=#1A1A1A;fontSize=11" vertex="1" parent="1">
          <mxGeometry x="40" y="40" width="170" height="1100" as="geometry" />
        </mxCell>
        <mxCell id="ll-br" value="Navegador&lt;br&gt;del titular" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;collapsible=0;recursiveResize=0;outlineConnect=0;size=50;fillColor=#FFF8E1;strokeColor=#F9A825;fontColor=#1A1A1A;fontSize=11" vertex="1" parent="1">
          <mxGeometry x="240" y="40" width="170" height="1100" as="geometry" />
        </mxCell>
        <mxCell id="ll-pa" value="payment-api" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;collapsible=0;recursiveResize=0;outlineConnect=0;size=50;fillColor=#E3F2FD;strokeColor=#1565C0;fontColor=#1A1A1A;fontSize=11" vertex="1" parent="1">
          <mxGeometry x="440" y="40" width="170" height="1100" as="geometry" />
        </mxCell>
        <mxCell id="ll-tb" value="Transbank Oneclick" style="shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=0;collapsible=0;recursiveResize=0;outlineConnect=0;size=50;fillColor=#F3E5F5;strokeColor=#6A1B9A;fontColor=#1A1A1A;fontSize=11" vertex="1" parent="1">
          <mxGeometry x="640" y="40" width="170" height="1100" as="geometry" />
        </mxCell>

        <mxCell id="m01" value="1. RUTA 1 de 5 - POST /v1/payment-methods/inscriptions - sk_test_ e Idempotency-Key (gateway_id, customer_ref, email, return_url)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.075;exitDx=0;exitDy=0;entryX=0;entryY=0.075;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m02" value="2. abre la inscripcion en la pasarela" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;endArrow=block;endFill=1;exitX=1;exitY=0.12;exitDx=0;exitDy=0;entryX=0;entryY=0.12;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-tb">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m03" value="3. URL del formulario y token de un solo uso" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.165;exitDx=0;exitDy=0;entryX=1;entryY=0.165;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-tb" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m04" value="4. 201 ins_... en REQUIRES_ACTION, con redirect { method, url, field_name, token }" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.21;exitDx=0;exitDy=0;entryX=1;entryY=0.21;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m05" value="5. formulario auto-enviado: method POST, action url, campo field_name con valor token" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#C62828;fontColor=#B71C1C;fontSize=10;fontStyle=1;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=1;exitY=0.255;exitDx=0;exitDy=0;entryX=0;entryY=0.255;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-br">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m06" value="6. POST DE FORMULARIO al sitio de Transbank - NO es una redireccion GET (el campo es TBK_TOKEN)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#C62828;fontColor=#B71C1C;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.3;exitDx=0;exitDy=0;entryX=0;entryY=0.3;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-br" target="ll-tb">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m07" value="7. el titular teclea su tarjeta en Transbank y vuelve a la return_url con el token" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.345;exitDx=0;exitDy=0;entryX=1;entryY=0.345;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-tb" target="ll-br">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m08" value="8. retorno a la return_url del comercio" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;endArrow=block;endFill=1;exitX=0;exitY=0.39;exitDx=0;exitDy=0;entryX=1;entryY=0.39;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-br" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m09" value="9. RUTA 2 de 5 - POST /v1/payment-methods/inscriptions/ins_.../confirm - Idempotency-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.435;exitDx=0;exitDy=0;entryX=0;entryY=0.435;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m10" value="10. cierra la inscripcion y recoge la credencial" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;endArrow=block;endFill=1;exitX=1;exitY=0.48;exitDx=0;exitDy=0;entryX=0;entryY=0.48;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-tb">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m11" value="11. tbk_user y los datos no sensibles de la tarjeta" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.525;exitDx=0;exitDy=0;entryX=1;entryY=0.525;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-tb" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m12" value="12. 201 con el medio de pago pm_... (el tbk_user NO se publica)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.57;exitDx=0;exitDy=0;entryX=1;entryY=0.57;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m13" value="13. cobro - POST /v1/payment-intents con payment_method_id pm_... y SIN gateway_id" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#2E7D32;fontColor=#1B5E20;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.615;exitDx=0;exitDy=0;entryX=0;entryY=0.615;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m14" value="14. 201 - la pasarela se DERIVA del medio, no se elige" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#2E7D32;fontColor=#1B5E20;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.66;exitDx=0;exitDy=0;entryX=1;entryY=0.66;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m15" value="15. RUTA 3 de 5 - GET /v1/payment-methods - solo los VIGENTES, paginado por cursor" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.705;exitDx=0;exitDy=0;entryX=0;entryY=0.705;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m16" value="16. 200 con data, next_cursor y has_more" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=1;entryY=0.75;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m17" value="17. RUTA 4 de 5 - GET /v1/payment-methods/pm_... - lee uno, REVOCADOS INCLUIDOS" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.795;exitDx=0;exitDy=0;entryX=0;entryY=0.795;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m18" value="18. RUTA 5 de 5 - DELETE /v1/payment-methods/pm_..." style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#1565C0;fontColor=#0D47A1;fontSize=10;fontStyle=1;endArrow=block;endFill=1;exitX=1;exitY=0.84;exitDx=0;exitDy=0;entryX=0;entryY=0.84;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-ec" target="ll-pa">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m19" value="19. da de baja la credencial en la pasarela" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;endArrow=block;endFill=1;exitX=1;exitY=0.885;exitDx=0;exitDy=0;entryX=0;entryY=0.885;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-tb">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="m20" value="20. 200 con el recurso ya revocado, no un 204 vacio" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;verticalAlign=bottom;labelBackgroundColor=#FFFFFF;strokeColor=#455A64;fontColor=#1A1A1A;fontSize=10;dashed=1;endArrow=open;endFill=0;endSize=10;exitX=0;exitY=0.93;exitDx=0;exitDy=0;entryX=1;entryY=0.93;entryDx=0;entryDy=0" edge="1" parent="1" source="ll-pa" target="ll-ec">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>

        <mxCell id="nota-post-formulario" value="Pasos 5 y 6 - EL ERROR MAS FACIL DE COMETER. El objeto redirect NO es una URL para saltar con un GET: hay que hacer un POST DE FORMULARIO a redirect.url, con un campo cuyo nombre es redirect.field_name y cuyo valor es redirect.token. En Transbank ese campo se llama TBK_TOKEN. Por eso la respuesta lleva method y field_name, y no solo la URL: si viajara unicamente la URL, cada integrador tendria que averiguar por su cuenta como pasar el token." style="shape=note;size=16;whiteSpace=wrap;html=1;fillColor=#FDECEA;strokeColor=#C62828;fontColor=#1A1A1A;fontSize=10;align=left;verticalAlign=top;spacingLeft=8;spacingTop=4" vertex="1" parent="1">
          <mxGeometry x="40" y="1190" width="380" height="160" as="geometry" />
        </mxCell>
        <mxCell id="nota-cobro" value="Paso 13 - para cobrar basta payment_method_id al crear el intent. La pasarela se DERIVA del medio: una tarjeta inscrita en Oneclick solo se cobra en Oneclick, asi que mandar ademas un gateway_id distinto responde 400 en vez de adivinar cual gana. En Oneclick, la clave reservada installments de metadata fija el numero de cuotas. El medio se revalida en el confirm: entre crear y cobrar puede haber pasado un DELETE." style="shape=note;size=16;whiteSpace=wrap;html=1;fillColor=#E8F5E9;strokeColor=#2E7D32;fontColor=#1A1A1A;fontSize=10;align=left;verticalAlign=top;spacingLeft=8;spacingTop=4" vertex="1" parent="1">
          <mxGeometry x="440" y="1190" width="370" height="160" as="geometry" />
        </mxCell>
        <mxCell id="nota-cierre" value="Tres cosas que fija este ciclo. (1) Las DOS rutas POST exigen Idempotency-Key: sin ella un reintento abriria otra inscripcion en la pasarela y dejaria la anterior huerfana. Los cuatro SDKs la generan si el comercio no la pasa. (2) La asimetria entre listar y leer es deliberada: GET /v1/payment-methods devuelve solo los VIGENTES para no invitar a cobrar con uno dado de baja, mientras que GET /v1/payment-methods/pm_... devuelve tambien los REVOCADOS, porque los intents historicos los referencian; el estado se lee en el campo revoked. (3) DELETE conserva la fila y responde con el recurso ya revocado, no con un 204 vacio: borrarla perderia el rastro de con que se cobro. Es idempotente, asi que repetirla no es un error. En todo el ciclo el PAN solo existe en el paso 7, dentro del sitio de Transbank (PCI DSS SAQ A)." style="shape=note;size=16;whiteSpace=wrap;html=1;fillColor=#E8EAF6;strokeColor=#283593;fontColor=#1A1A1A;fontSize=11;align=left;verticalAlign=top;spacingLeft=8;spacingTop=4" vertex="1" parent="1">
          <mxGeometry x="40" y="1370" width="770" height="150" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
