# Viva Wallet

In this section, we will see how to use My Azur API to make a payment through a Viva Wallet terminal. This tutorial is aimed at Point of Sales developers who want to quickly integrate a Viva Wallet terminal with their software.

Prerequisities:&#x20;

* You created a  **My Azur account** and registered your company on My Azur platform;
* Your company profile has been **verified** by Sita Software;&#x20;
* You have a **verified** account on vivawallet.com;
* You have a physical Smart POS Viva Wallet terminal (Android based).

## Activate your  terminal on Viva Wallet.com

Go to <https://www.vivawallet.com/> and login with your Viva Wallet account.&#x20;

<figure><img src="/files/NG0vizYCnRfvOaKsciz8" alt=""><figcaption><p>Viva Wallet accounts</p></figcaption></figure>

Select the Blue Account (Merchant Account), the Purple one is the ISV account.&#x20;

Now navigate using the sidebar to the menu  `Sales -> Physical Payments -> Card Terminals`

<figure><img src="/files/aSzjFyl2F2KeE0nyuwiL" alt=""><figcaption><p>How to find the Terminal ID</p></figcaption></figure>

Now click the green button `New Card Terminal` on the top right. On the physical terminal launch the Viva Wallet app and click "Sign-in with activation code", the app will display a code that you'll put into the new card terminal form. After confirmation your new terminal will appear in the list above.  The mobile app is now ready to start a new payment session.&#x20;

{% hint style="warning" %}
Write down the Terminal ID (TID), we will need it in the next section.&#x20;
{% endhint %}

<figure><img src="/files/r8jo5k2xkYm4rtrASVSI" alt="" width="375"><figcaption><p>Viva Wallet Smart POS has been activated</p></figcaption></figure>

Now navigate using the sidebar to the menu  `Settings->API Access`&#x20;

<figure><img src="/files/t6ktiuUmrVZWuIBi5XKz" alt=""><figcaption><p>How to find the Merchant ID </p></figcaption></figure>

{% hint style="warning" %}
Write down the Merchant ID, we will need it in the next section.&#x20;
{% endhint %}

## Add the terminal to My Azur&#x20;

In My Azur, each Company can have a set of Stores, and for each Store, one or more Machines can be defined. Each Machine will be associated with one or more Payment Terminals.

Let's start by adding a Store to our Company. In this tutorial we assume our company id = 13.&#x20;

```bash
curl --location '{api_base_url}/stores' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Firebase Token>' \
--data '{
    "company_id" : 13,
    "name" : "My Store"
}'
```

<figure><img src="/files/qiqujipnNw0hsAQaevLK" alt=""><figcaption><p>Add a new store</p></figcaption></figure>

Let's add now a machine to our new store:&#x20;

```bash
curl --location '{api_base_url}/stores/3/machines' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Firebase Access Token>' \
--data '{
    "name": "My Machine"
}'
```

<figure><img src="/files/ZYFmy2X39P6S6cbFN5tu" alt=""><figcaption><p>Add a new machine</p></figcaption></figure>

We now have everything we need to register the Viva Wallet Payment terminal to My Azur:

```bash
curl --location '{api_base_url}/machines/3/payment_terminals' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Firebase Access Token> ' \ 
--data '{
    "payment_terminal_type_id": 1, 
    "name" : "Viva Wallet Android Tablet 1",
    "code" : "1600000",
    "merchant_code" : "7164123-842a-4b0e-456f-2makNskl",
    "fee" : "0.6"
}'
```

Let's break down the meaning of each fields passed  in the payload:

* payment\_terminal\_type\_id = 1  indicate this is a Viva Wallet terminal&#x20;
* code:  put here the Viva Wallet Terminal ID (TID) that you got on the previous section [#activate-your-terminal-on-viva-wallet.com](#activate-your-terminal-on-viva-wallet.com "mention")
* merchant\_code: put here the Viva Wallet Merchant ID that you got on the previous section [#activate-your-terminal-on-viva-wallet.com](#activate-your-terminal-on-viva-wallet.com "mention")
* fee: you can specify a percentage fee that Sita Software will receive as percentage for each transaction, in this example 0.6%.&#x20;

<figure><img src="/files/bg1mFjfqgF8RnBUPAoFs" alt=""><figcaption><p>Add a Viva Wallet payment terminal to My Azur API</p></figcaption></figure>

## Create a Payment Session

We can now create a new Payment session:&#x20;

```bash
curl --location '{api_base_url}/payment_terminals/2/payment_sessions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Firebase Access Token> 
--data '{
    "type_id" : 1,
    "merchant_reference" : "DOC1234",
    "amount" : "0.10"
}'
```

&#x20;Let's break down the meaning of each fields passed  in the payload:

* type\_id = 1 means this is a SALE, see [Payment Session](/models/payment-session.md) for more details about this field;
* merchant\_reference: this can be used to pass a reference, for example the internal document number used by your Point of Sale system;
* amount: transaction amount in euro.

<figure><img src="/files/fewodKgmB6mfhMlywkG9" alt=""><figcaption><p>Add a Viva Wallet Payment Session</p></figcaption></figure>

Viva Wallet terminal will wait for the payment:&#x20;

<figure><img src="/files/YTdiAR0XOF5oGXyX2111" alt="" width="375"><figcaption><p>Viva Wallet payment session initiated from My Azur API</p></figcaption></figure>

## Monitor the status of the Payment Session

It is recommended to wait about 4 seconds, after that you can start polling for the status of the payment session by sending a **refresh request** to My Azur API, that will fetch the status from the physical terminal and returns the current status as json:

```bash
curl --location --request POST '{api_base_url}/payment_sessions
/<payment_session_id>/refresh' \
--header 'Authorization: Bearer <Firebase Access Token> 
```

As response you will get:&#x20;

```json
{
    "amount": "0.10",
    "application_label": null,
    "authorization_code": "367371",
    "code": "e3282ea1-287b-4b49-8510-fb33a234424",
    "created_at": "2024-04-12T14:16:41.781768",
    "created_by": "XyWjp31BVWOTUazhK5VNKusI3lv1",
    "currency_code": "978",
    "fee_amount": "0.00",
    "id": 13,
    "merchant_reference": "DOC1234",
    "order_code": "4103167443454",
    "payment_session_type_id": 1,
    "preauth": false,
    "primary_account_number_masked": "455812******5663",
    "reference_number": 334123,
    "retrieval_reference_number": 41031324234,
    "short_order_code": "4103423426",
    "status_id": 3,
    "tip_amount": "0.00",
    "transaction_code": "e0cdac35b4-d9bf-4521-adf1-45c7b6fda2e3",
    "transaction_message": "Transaction successful",
    "updated_at": "2024-04-12T14:17:08.056230",
    "updated_by": "XyWjp31BVWOTUazhK5VNKusI3lv1",
    "verification_method": "CONTACTLESS - NO CVM"
}
```

status\_id = 3 means the transaction has been successful. To learn more about the meaning of each of the fields that you get in the response please refer to [Payment Session](/models/payment-session.md)

{% hint style="success" %}
Congratulations: you completed your first transaction with the Viva Wallet Smart POS.&#x20;
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://developer.myazur.app/payment-processors/viva-wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
