> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/transit-digitization/es/implementar-apple-transit/ticketing-basado-en-cuenta-abt/compra-de-producto-tarifario-posterior-al-aprovisionamiento-en-la-billetera.md).

# Compra de producto tarifario posterior al aprovisionamiento en la billetera

El flujo de trabajo de Compra de Producto Tarifario en cartera después de la provisión (Wallet Post-Provisioning Fare Product Purchase) es iniciado por el usuario a través de la aplicación Wallet. El objetivo principal es que el usuario compre o renueve un producto tarifario y que este se aplique de forma fluida a su tarjeta de transporte en Apple Wallet para su uso inmediato.

### Flujo de trabajo <a href="#workflow" id="workflow"></a>

Los siguientes pasos a alto nivel describen el flujo de trabajo de Compra de Producto Tarifario en cartera después de la provisión:

**Selección del producto tarifario**: El usuario selecciona el producto tarifario que desea comprar. Las opciones pueden incluir añadir saldo almacenado a un balance existente o comprar/renovar un plan de desplazamiento.

**Pago**: Una vez que el usuario autoriza la compra del producto tarifario seleccionado, el Administrador de Pagos procesa el pago.

**Recuperación del paquete actualizado y actualización de la visualización en Wallet**: Al recibir la solicitud updateBundle, Apple solicita el paquete de provisión que contiene los datos de la tarjeta a D1 Transit. Este paso solo es necesario si se está comprando o renovando un producto tarifario.\
D1 Transit utiliza el servicio de notificaciones push de Apple (APNs) para actualizar Apple Wallet con los nuevos detalles del producto tarifario.

Para la actualización del saldo, el emisor de transporte envía handleEvent a D1 Transit para activar una notificación a través de APNs con el fin de actualizar Apple Wallet con el nuevo valor del saldo.

#### Fare Product Selection <a href="#fare-product-selection" id="fare-product-selection"></a>

**Error Scenarios**

**Renewal not permitted**

Apple Wallet includes a "renew" button for fare products, which becomes available based on the Transit Issuer's business rules. For instance, a monthly pass might be eligible for renewal only within a window that starts 3 days before its expiration and ends 3 days after expiration.

When the user selects the "renew" button, if the cohabitation rule engine determines that renewal options are not allowed due to business rules, D1 Transit must notify Apple by returning a response with an empty cardActions array. This indicates that no renewal actions are available for the selected card.

**Purchase not permitted**

If the cohabitation rule engine determines that no products are available to purchase due to business rules, D1 Transit must notify Apple by returning a response with an empty cardActions array. This indicates that no purchase actions are available for the selected card.

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/mNDjzXrG3lVKAOcqEIts" alt=""><figcaption></figcaption></figure>

#### Payment <a href="#payment" id="payment"></a>

Upon the user authorizing the payment, a performPayment API call is triggered and sent to D1 Transit platform, which sends a purchaseProducts request to Transit Issuer. Transit Issuer is responsible for ensuring the payment request is processed by the PSP.

After processing, the outcome of the transaction is communicated back to the Apple. If the payment is successfully processed, D1 Transit returns a Purchase object with its state set to complete.

**Error scenarios**

When a payment failure or timeout occurs, Apple Wallet displays a red exclamation mark to the user. The user can retry the payment using the same or a different payment sheet, with either the same or a different payment credential.

**retry with same payment sheet**

In this case, the same orderId will be used. Transit issuer needs to check the status of the payment linked to that orderId. It's possible that the existing payment was successfully processed by the PSP, but due to a delay, the previous attempt timed out.

**retry with a different payment sheet**

Here, a new orderId is generated for this new payment request.

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/NgzIZEhIsIVYGP2U1U75" alt=""><figcaption></figcaption></figure>

#### Recuperación del paquete y actualización de la visualización en Wallet <a href="#bundle-retrieval-and-wallet-display-update" id="bundle-retrieval-and-wallet-display-update"></a>

Después de comprar o renovar con éxito un producto tarifario, el emisor de transporte envía handleEvent a D1 Transit, que entonces notifica a Apple realizando una solicitud API updateBundle, con el parámetro intentionType establecido en updatePass.

Sin embargo, si el usuario ha recargado su saldo almacenado, no es necesario proporcionar un paquete actualizado.

Al recibir la solicitud updateBundle, Apple recupera el paquete de provisión realizando una solicitud getProvisioningBundle a D1 Transit.

Una vez que el paquete es devuelto a Apple, D1 Transit notifica al emisor de transporte que el paquete se actualizó correctamente.

Para las actualizaciones de saldo, el emisor de transporte notifica a D1 Transit usando handleEvent. Se utiliza el servicio de notificaciones push de Apple (APNs) para garantizar que Apple Wallet refleje la información más reciente.

**Escenarios de error**

**No hay solicitud por parte de Apple para obtener el paquete de provisión**

D1 Transit define un período de tiempo de espera entre la recepción de la respuesta updateBundle y la solicitud getProvisioningBundle por parte de Apple.

Si la solicitud getProvisioningBundle no es recibida por D1 Transit dentro de este período de tiempo de espera, D1 Transit aplicará una política de reintentos configurada.

Si se agotan todos los intentos de reintento y la solicitud getProvisioningBundle aún no se recibe, Thales escala el problema contactando a Apple para una investigación y resolución adicionales.

Dado que esta integración utiliza ABT, los productos tarifarios vinculados a la tarjeta se almacenan en el servidor, lo que significa que no debería ser necesario reembolsar al cliente si la actualización del paquete falla.

**Solicitud de paquete de provisión recibida después del tiempo de espera**

En los casos en que la solicitud getProvisioningBundle se reciba después del tiempo de espera, D1 Transit primero verifica si el triggeringRequestIdentifier está vinculado a un requestIdentifier updateBundle que previamente superó el tiempo de espera. Si la solicitud está asociada con un updateBundle que expiró, D1 Transit devuelve un estado HTTP 200 a Apple, estableciendo el statusCode en HTTP 500. Esta respuesta informa a Apple que no son necesarias más actualizaciones para la tarjeta.

**Token de autenticación no autorizado**

Cuando la tarjeta se provisiona, Apple registra el dispositivo para transacciones con D1 Transit llamando al endpoint transactionNotifications/register de D1 Transit. En respuesta, D1 Transit devuelve un authenticationToken, que se almacena en el dispositivo. Si el dispositivo hace una solicitud con un authenticationToken expirado, D1 Transit devuelve un estado HTTP 401, lo que obliga al dispositivo a volver a registrarse para las transacciones.

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/ZRTsZ7ZhHSndMJayYwds" alt=""><figcaption></figcaption></figure>

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/JttO5svCFHBDPLUGUzxH" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/transit-digitization/es/implementar-apple-transit/ticketing-basado-en-cuenta-abt/compra-de-producto-tarifario-posterior-al-aprovisionamiento-en-la-billetera.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
