> ## 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.

# Single Session with Pre-Authorization

This guide explains the **Pre-Authorization** vending flow. This process is key to minimizing risk because it approves payment before the customer selects a product.

## Payment Flow

Visualize the Pre-Authorization process with the diagram below, which illustrates each step of the single vending session flow, from product selection to payment authorization and dispensing.

<Frame>
  <img src="https://mintcdn.com/nayax-44d6e37b-docs-marshall-faq-redistribution/sBwRUCoASdSz1DKZ/images/docs/marshall-single-session-with-pre-auth/image1.png?fit=max&auto=format&n=sBwRUCoASdSz1DKZ&q=85&s=4a1fcde397a333c488f40f9ba6a1c911" width="1706" height="1700" data-path="images/docs/marshall-single-session-with-pre-auth/image1.png" />
</Frame>

Below is a breakdown of the diagram:

1. The consumer presents the card to the Nayax Device.
2. The Nayax Device sends an authorization request to the Nayax Server.
3. The Nayax Server forwards the authorization request to the Billing Provider.
4. The Billing Provider sends an authorization response (approved) to the Nayax Server.
5. Nayax Server sends the authorization response (approved) back to the Nayax Device.
6. The peripheral's SDK begins the session and triggers the "session begin" event:

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

  ```csharp C# theme={null}
  vend_callbacks(onBeginSession(funds_avail))
  ```

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

7. Message to the consumer: "Please Select a Product."
8. The consumer selects a product.
9. The peripheral's SDK sends a "vend request" to the Nayax Device:
10. The peripheral's SDK handles transaction data received from the Nayax Device via Transfer Data command (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 peripheral's SDK triggers the "vend approved" event:

<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 dispenses the product/ provides 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. Message to the consumer: "Please Take Product."
15. Nayax Device sends a settlement request to the Nayax Server.
16. Nayax Server forwards the settlement request to the Billing Provider.
17. The Billing Provider sends a settlement response (OK) to the Nayax Server.
18. Nayax Server sends the settlement response (OK) back to the Nayax Device.

## 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 />
