> 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/implement-apple-transit/card-based-ticketing-cbt/in-app-post-provisioning-fare-product-purchase.md).

# In-App Post Provisioning Fare Product Purchase

The In-App Post-Provisioning Fare Product Purchase workflow is initiated by the user directly through the transit operator's iOS app. The primary goal is for the user to purchase a fare product within the app and have it seamlessly applied to their transit card in Apple Wallet for immediate use.

### Workflow <a href="#workflow" id="workflow"></a>

The following high level steps outline the In-App Post-Provisioning Fare Product Purchase workflow:

1. **Fare Product Selection and Payment**: The user selects the fare product they wish to purchase from the transit operator's iOS app. It may include adding stored value to an existing balance or purchasing/renewing a fare product.
2. **Applet Update and Wallet Display Update**: In CBT context, there is a need to update the applet content. Upon receiving the updateBundle request with "applet update" intention, Apple device requests to get the commands to be executed in order to update applet content data.

For new product purchases, there is a need to update the Wallet display. Upon receiving the updateBundle request with "pass update" intention, Apple requests the provisioning bundle containing the card details from D1 Transit.

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

Before the workflow begins, the user must select an eligible fare product within the transit operator's iOS app to add to his transit card.

Once a fare product is selected, the app should display payment options for the user to complete the purchase. The user can then choose his preferred payment method from the available options.

**Error Scenarios**

**Purchase or renewal not allowed**

If the purchase or renewal of a fare product is prohibited due to business rules (e.g., expired card or ineligible fare product), the transit operator's iOS app shall indicate it to the user.

#### Applet Update and Wallet Display Update <a href="#applet-update-and-wallet-display-update" id="applet-update-and-wallet-display-update"></a>

After successfully purchasing or renewing a fare product, Transit Issuer shall send a request to D1 Transit indicating that the applet data are to be updated. D1 Transit, then, notifies Apple by making an updateBundle API request, with the intentionType parameter set to updateApplet.

Upon receiving the updateBundle request, Apple initiates "redirect" command towards the device. Device connects to D1 Transit in order to get the commands to be executed in order to update the applet data content. There can be several round trips for doing so.

Once the applet data are updated, D1 Transit notifies Transit Issuer that the bundle data was successfully updated.

For new products purchased, after receiving successful bundle data notification, Transit Issuer sends an handleEvent to D1 Transit platform for updating the wallet display.

D1 Transit notifies Apple by making an updateBundle API request, with the intentionType parameter set to updatePass.

Upon receiving the updateBundle request, Apple retrieves the provisioning bundle by making a getProvisioningBundle request to D1 Transit.

Once the bundle is returned to Apple, D1 Transit notifies Transit Issuer that the bundle was successfully updated.

**Error Scenarios**

**No request from Apple to get the provisioning bundle**

D1 Transit defines a timeout period between receiving the updateBundle response and the getProvisioningBundle request from Apple.

If the getProvisioningBundle request is not received by D1 Transit within this timeout period, D1 Transit will apply a configured retry policy.

If all retry attempts are exhausted and the getProvisioningBundle request is still not received, D1 Transit notifies the failure to the Transit Issuer.

<figure><img src="broken://spaces/SokLBgfEhZisVFcUdPiW/files/T9wOXwSk53oCrR0UcSBb" alt=""><figcaption></figcaption></figure>

<figure><img src="broken://spaces/SokLBgfEhZisVFcUdPiW/files/DkUhIEBzJDaLYNhqz0Uk" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/transit-digitization/implement-apple-transit/card-based-ticketing-cbt/in-app-post-provisioning-fare-product-purchase.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
