> ## Documentation Index
> Fetch the complete documentation index at: https://nayax-44d6e37b-docs-marshall-faq-redistribution.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-Session

The **Multi-Session** payment flow separates the consumer interaction into two distinct parts:

1. **Product selection.**
2. **Authorization and settlement** of the consumer’s card.

This differs from the Single-Session flow, in which settlement is performed immediately after product selection and authorization.

## Settlement timeout

<Note>
  Settlement should occur anywhere between **1 minute and 71 hours** (the exact value depends on a parameter called **"Session timeout"** in Nayax Core) after authorization process was completed.

  Note that in case of the machine not sending a settlement command within a timeframe set in **"Session timeout"** parameter in Nayax Core- the device would settle the transaction on its own and notify the peripheral about it via "Status" command.

  For VPOSM- it's possible to have the transaction be cancelled instead of settled in case of timeout- but that would be possible via additional configuration on Nayax Core (unrelated to the Marshall flow- meaning from Marshall's POV, the device would always try and settle the transaction at session timeout).
</Note>

<Danger>
  It's important that peripherals do not count on the Session Timeout mechanism as it's strictly a fallback mechanism from the device's end.\
  Meaning the peripheral should always send a settlement command, and in case of not wanting to charge the consumer he can change one of the settlements fields, called "status" (unrelated to the "Status" command) to a status of "Vend failure" for example- more on that in [Close a Session Without Charging the Consumer](/docs/integrate-pos-device/marshall/marshall-create-payments#close-a-session-without-charging-the-consumer)
</Danger>

## Why Use Multi-Session

The Multi-Session flow enables you to manage **multiple concurrent transactions** on a single device. It is ideal for peripherals with longer transaction times or those that serve several consumers simultaneously.

### Concurrent Transactions

This flow is applicable in environments such as **EV chargers**, where multiple consumers may use the same station simultaneously but require independent payment processing.

### Longer Transaction Times

Multi-Session is also helpful when the vending process is longer than the standard **4 minutes and 15 seconds**.

The flow allows the peripheral to notify the Nayax Device that vending can begin immediately after the card is authorized. The Nayax Device then waits for a later update from the peripheral regarding the final vend status or service stop, which enables settlement.

### Quicker Credit Release

The Multi-Session flow functions technically as a **Pre-Selection flow**. For some acquirers, this architecture can lead to a **quicker release of captured credit** than the Single-Session flow with Pre-Authorization.

If you use Single-Session with Pre-Authorization, the authorized credit amount may take days or weeks to be released, which can confuse consumers who may think they were charged the full Pre-Authorization amount. Multi-Session helps mitigate this issue.

### Transactions That Start and End at Different Locations

Because a Multi-Session transaction stays open, you can start it at one Nayax device and close it at another. Cart rental is the clearest example:

1. The consumer starts a transaction at the Nayax device on the first rail and takes a cart.
2. The consumer uses the cart.
3. The consumer returns the cart to any rail, not necessarily the first one. The Nayax device on that second rail recognizes the cart and sends its ID to a main server, which matches the cart ID to the device where the transaction started and closes the transaction there.

This pattern puts real requirements on your side:

* A server that tracks which sessions are open at which location.
* A way to tell the different cards apart.
* No more than 60 carts available for rent per rail at a time. Beyond that, consumers cannot rent.

## Payment Flow

The diagrams below illustrate the sequence of events within the Multi-Session payment flow.

<Note>
  In this flow there are two parts to the transaction process, therefore there are two separate diagrams, one for each step.
</Note>

<Frame>
  <img src="https://mintcdn.com/nayax-44d6e37b-docs-marshall-faq-redistribution/Hbgg7w3lQTggebWl/images/docs/marshall-multi-session/image1.jpg?fit=max&auto=format&n=Hbgg7w3lQTggebWl&q=85&s=187acd1c407cfe0b9f8181b5c06e96e5" width="738" height="570" data-path="images/docs/marshall-multi-session/image1.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/nayax-44d6e37b-docs-marshall-faq-redistribution/Hbgg7w3lQTggebWl/images/docs/marshall-multi-session/image2.jpg?fit=max&auto=format&n=Hbgg7w3lQTggebWl&q=85&s=a869de48e12fe92da68b8df73cc59882" width="802" height="35" data-path="images/docs/marshall-multi-session/image2.jpg" />
</Frame>

Below is a breakdown of the diagram:

1. The Nayax Device sends a message to the consumer: "Please Select a Product."

2. The consumer selects a product from the vending machine.

3. The peripheral's SDK sends a vending request to the Nayax Device:

   <CodeGroup>
     ```c C theme={null}
     vmc_vend_vend_request(vend_session_t *session)
     ```

     ```csharp C# theme={null}
     vmc_instance.vend.vend_request(session);
     ```

     ```java Java theme={null}
     m_vmc.vend.vend_request(m_sessions[m_active_session]);
     ```
   </CodeGroup>

4. The Nayax Device sends a message to the consumer: "Please Present Card."

5. The consumer presents their payment card.

6. The Nayax Device sends an authorization request to the Nayax Server.

7. The Nayax Server forwards the authorization request to the Billing Provider.

8. The Billing Provider sends an authorization response (approved) to the Nayax Server.

9. The Nayax Server sends the authorization response (approved) back to the Nayax Device.

10. The peripheral's SDK handles transaction data received from the Nayax Device via Transfer Data (said data includes information about the Nayax transaction ID and the consumer's card details):

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_event_handler_cb(vm_vend_event_on_transaction_info)
      ```

      ```csharp C# theme={null}
      vend_callbacks(onTransactionInfo(data))
      ```

      ```java Java theme={null}
      vmc_vend_events()
      (via onTransactionInfo(data))
      ```
    </CodeGroup>

11. The SDK triggers "Vend Approved" events:

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_event_handler_cb(vm_vend_event_on_vend_approved)
      ```

      ```csharp C# theme={null}
      vend_callbacks()
      (via onVendApproved(session))
      ```

      ```java Java theme={null}
      vmc_vend_events()
      (via onVendApproved(session))
      ```
    </CodeGroup>

12. The peripheral starts dispensing the product/ providing the service to the consumer.

13. The SDK reports "vend success":

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_vend_status(&session, __true)
      ```

      ```csharp C# theme={null}
      vmc_vend_events()
      (via onVendApproved(session) -which would return "true")
      ```

      ```java Java theme={null}
      vmc_vend_events()
      (via onVendApproved(session) -which would return "true")
      ```
    </CodeGroup>

    and completes the vend session:

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_vend_session_complete_lowlevel()
      ```

      ```csharp C# theme={null}
      no such function in C# or Java due to the nature of the languages
      ```

      ```java Java theme={null}
      no such function in C# or Java due to the nature of the languages
      ```
    </CodeGroup>

14. The first part of the transaction **ends**.

<Frame>
  <img src="https://mintcdn.com/nayax-44d6e37b-docs-marshall-faq-redistribution/Hbgg7w3lQTggebWl/images/docs/marshall-multi-session/image3.png?fit=max&auto=format&n=Hbgg7w3lQTggebWl&q=85&s=499a139a770fd5dbcae783468e8f1761" width="1706" height="1234" data-path="images/docs/marshall-multi-session/image3.png" />
</Frame>

15. The machine finishes dispensing the product/providing the service.

16. Vending machine SDK settles the transaction (session):

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_session_close(session)
      ```

      ```csharp C# theme={null}
      vmc_instance.vend.session_close(session)
      ```

      ```java Java theme={null}
      m_vmc.vend.session_close(session)
      ```
    </CodeGroup>

17. The Nayax Server forwards the settlement request to the Billing Provider.

18. The Billing Provider sends a settlement response (OK) to the Nayax Server.

19. Nayax Server returns the settlement response (OK) to the Nayax Device.

20. The peripheral's SDK receives a status command regarding the settlement (whether the device was able to settle it or not) and triggers a "settlement" event:

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_event_handler_cb(vm_vend_event_on_settlement)
      ```

      ```csharp C# theme={null}
      vmc_vend_events()
      (via onSettlement(success) -which would return "true")
      ```

      ```java Java theme={null}
      vmc_vend_events()
      (via onSettlement(success) -which would return "true")
      ```
    </CodeGroup>

21. Vending machine SDK transfers data and triggers a "transaction info" event:

    <CodeGroup>
      ```c C theme={null}
      vmc_vend_event_handler_cb(vm_vend_event_on_transaction_info)
      ```

      ```csharp C# theme={null}
      vmc_vend_events()
      (via onTransactionInfo(data))
      ```

      ```java Java theme={null}
      vmc_vend_events()
      (via onTransactionInfo(data))
      ```
    </CodeGroup>

22. Message to the consumer: "Thank you & Goodbye."

## See also

<CardGroup cols={3}>
  <Card icon="diagram-project" title="Payment Flows" href="/docs/integrate-pos-device/marshall/payment-flows/marshall-payment-flows">
    Explore the full range of payment flows available in the Marshall SDK.
  </Card>

  <Card icon="rocket" title="Get Started" href="/docs/integrate-pos-device/marshall/get-started/marshall-get-started">
    Get up and running with the Marshall SDK integration.
  </Card>

  <Card icon="code" title="Methods & Functions" href="/docs/integrate-pos-device/marshall/methods-functions/marshall-methods-and-functions">
    Find reference documentation for all methods and functions in the Marshall SDK.
  </Card>
</CardGroup>

<br />
