# EMV Transaction Flow

### Flow Chart

<figure><img src="/files/5UlRPiyvMDhaagBoRDx8" alt=""><figcaption></figcaption></figure>

#### Sample Flow Code: C\#

{% tabs %}
{% tab title="Sample 1" %}

```
// #1
MTSCRA m_SCRA = new MTSCRA();

// Delegate the MTSCRA Events. m_SCRA.OnDisplayMessageRequest += OnDisplayMessageRequest;
.
// Assign parameters. 
byte timeLimit = 0x3C; 
byte cardType = 0x07; 
byte option = 0x00;
byte[] amount = new 
byte[] { 0x00, 0x00, 0x00, 0x00, 0x15, 0x00 }; 
byte transactionType = 0x00; // Purchase
byte[] cashBack = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
byte[] currencyCode = new byte[] { 0x08, 0x40 };
byte reportingOption = 0x02; // All Status Changes

// Start transaction.
long result = m_SCRA.startTransaction( 
timeLimit,
cardType, 
option, 
amount,
transactionType, 
cashBack, 
currentCode, 
reportingOption);
```

{% endtab %}

{% tab title="Sample 2" %}

```
// #2

protected void OnDisplayMessageRequest(obj sender, byte[] data)
{
    String message;

    // Get the message. 
    if (data != NULL)
    {
        message = System.Text.Encoding.UTF8.GetString(data);
    }


    // A data size of 0 is an instruction to clear the display. 
    if (data.Length == 0)
    {
        // Clear the display.
        }
}
```

{% endtab %}

{% tab title="Sample 3" %}

```
// #3

protected void OnUserSelectionRequest(object sender, byte[] data)
{
    /* data[0]	– selection type 
    data[1]	– timeout
    data[2..n] – remainder contains zero-terminated string items */
    
// display/retrieve user selection.
.
// set status and selection result. 
m_SCRA.setUserSelectionResult(status, selection);

}
```

{% endtab %}

{% tab title="Sample 4" %}

<pre><code>// #4

protected void OnARQCReceived(object sender, byte[] data)
{
<strong>    /* data[0..1] – ARQC length
</strong>    data[2..n] – remainder contains the ARQC TLV object */

    // #4a Forward ARQC to Processor.

    /* An application function to forward the ARQC 
        to a Processor for approval. */
    proccesorResponse = sendARQCToProcesor(data);

    /* No need to send ARQC Response if transaction option 
        had enabled Quick Chip mode. */
    if (isQuickChipEnabled())
    {
    return;
    }


    // #4b Set Acquirer Response.

    // An application function to build Acquirer Response. 
    byte[] response = buildAcquirerResponse(processorResponse);

    // Set Acquirer Response.
    m_SCRA.setAcquirerResponse(response);

}
</code></pre>

{% endtab %}

{% tab title="Sample 5" %}

```
// #5

protected void OnDisplayMessageRequest(obj sender, byte[] data)
{
    String message;
    
    // Get the message. 
    if (data != NULL)
    {
    message = System.Text.Encoding.UTF8.GetString(data);
    }

    // A data size of 0 is an instruction to clear the display. 
    if (data.Length == 0)
    {
        // Clear the display.
    }
}
```

{% endtab %}

{% tab title="Sample 6" %}

<pre><code>// #6

protected void OnTransactionResult(obj sender, byte[] data)
{
<strong>    /* data[0]	– Signature Required 
</strong><strong>    data[1..2] – Batch Data length
</strong>    data[3..n] – remainder contains the Batch Data TLV object */

    // Parse the TLV from data[].
    .
    // Abstract Approval status from TLV tag “DFDF1A”.
    .
    // Abstract Signature Required status from TLV tag data[0].
    .
}

</code></pre>

{% endtab %}
{% endtabs %}

#### Sample Flow Code: Android (Java)

{% tabs %}
{% tab title="Sample 1" %}

```
// #1
m_MTSCRA = new MTSCRA(this, m_scraHandler);

// Assign parameters. 
byte timeLimit = 0x3C; 
byte cardType = 0x07; 
byte option = 0x00;
byte[] amount = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x15, 0x00 }; 
byte transactionType = 0x00; // Purchase
byte[] cashBack = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
byte[] currencyCode = new byte[] { 0x08, 0x40 };
byte reportingOption = 0x02; // All Status Changes

// Start transaction. 
m_MTSCRA.startTransaction( 
timeLimit,
cardType, 
option, 
amount,
transactionType, 
cashBack, 
currencyCode, 
reportingOption);

int result = m_MTSCRA.getResultCode();
```

{% endtab %}

{% tab title="Sample 2" %}

```
// #2

protected void onDisplayMessageRequest(byte[] data)
{
    String message;
    
    // Get the message. 
    if (data != NULL)
    {
    message = TLVParser.getTextString(data, 0);
    }

    // A data size of 0 is an instruction to clear the UI display. 
    if (data.Length == 0)
    {
        // Clear the display.
    }
}
```

{% endtab %}

{% tab title="Sample 3" %}

```
// #3

protected void onUserSelectionRequest(byte[] data)
{
    /* data[0]	– selection type 
    data[1]	– timeout
    data[2..n] – remainder contains user selection strings delimited by “\0”.
    */
    
    // display/retrieve status and user selection. 
    byte status;
    byte selection;
    .
    .
    // set status and selection result. 
    m_MTSCRA.setUserSelectionResult(status, selection);

}
```

{% endtab %}

{% tab title="Sample 4" %}

<pre><code>// #4
protected void onARQCReceived(byte[] data)
{
    /* data[0..1] – ARQC length
    data[2..n] – remainder contains the ARQC TLV object */

    // #4a Forward ARQC to Processor.

    /* An application function to forward the ARQC 
        to a Processor for approval. */
    proccesorResponse = sendARQCToProcesor(data);

    /* No need to send ARQC Response if transaction option had enabled Quick Chip mode. */
    if (isQuickChipEnabled())
    {
    return;
    }



    // #4b Set Acquirer Response.
    // An application function to build Acquirer Response. 
    byte[] response = buildAcquirerResponse(processorResponse);
<strong>    // Set Acquirer Response.
</strong><strong>     m_MTSCRA.setAcquirerResponse(response);
</strong>
}
</code></pre>

{% endtab %}

{% tab title="Sampel 5" %}

<pre><code>// #5

protected void onDisplayMessageRequest(byte[] data)
{
<strong>    String message;
</strong>
    // Get the message. 
    if (data != NULL)
    {
        message = TLVParser.getTextString(data, 0);
    }

    // A data size of 0 is an instruction to clear the UI display. 
    if (data.Length == 0)
    {
        // Clear the display.
    }
}
</code></pre>

{% endtab %}

{% tab title="Sample 6" %}

```
// #6

protected void onTransactionResult(byte[] data)
{
    /* data[0]	– Signature Required 
    data[1..2] – Batch Data length
    data[3..n] – remainder contains the Batch Data TLV object */

    // Parse the TLV from data.
    .
    // Abstract Approval status from TLV tag “DFDF1A”.
    .
    // Abstract Signature Required status from TLV tag data[0].
    .
}
```

{% endtab %}
{% endtabs %}

#### Sample Flow Code: iOS

{% tabs %}
{% tab title="Sample 1" %}

```
// #1
self.mtSCRALib = [[MTSCRA new];

// Delegate the MTSCRA Events.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDisplayMessageRequest:) name:@" onDisplayMessageRequest" withObject:obj];
.
.

// Assign parameters. 
Byte timeLimit = 0x3C; 
Byte cardType = 0x07; 
Byte option = 0x00;
Byte amount[6] = { 0x00, 0x00, 0x00, 0x00, 0x15, 0x00 }; 
Byte transactionType = 0x00; // Purchase
Byte cashBack[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
Byte currencyCode[2] = { 0x08, 0x40 };
Byte reportingOption = 0x02; // All Status Changes

// Start transaction.
[self.mtSCRALib startTransaction:timeLimit cardType:cardType 
option:option amount:amount transactionType:transactionType 
cashBack:cashBack currencyCode:currencyCode 
reportingOption:reportingOption];
```

{% endtab %}

{% tab title="Sample 2" %}

```
// #2

-(void)OnDisplayMessageRequest:(NSData *)data
{
    // Get the message.
    NSString* message = [HexUtil stringFromHexString:[self 
    getHexString:data]];

    // A data size of 0 is an instruction to clear the display. 
    if (message.Length == 0)
    {
        // Clear the display.
    }
}
```

{% endtab %}

{% tab title="Sample 3" %}

```
// #3
-(void)OnUserSelectionRequest:(NSData *)data
{
    /* data[0]	– selection type 
    data[1]	– timeout
    data[2..n] – remainder contains zero-terminated string items */

    // display/retrieve user selection.
    .
    // set status and selection result. 
    [self.mtSCRALib.setUserSelectionResult:(Byte)status
selection(Byte)userSelection];

}
```

{% endtab %}

{% tab title="Sample 4" %}

```
// #4
-(void)OnARQCReceived:(NSData *)data
{    
    /* data[0..1] – ARQC length
    data[2..n] – remainder contains the ARQC TLV object */

    // #4a Forward ARQC to Processor.

    /* An application function to forward the ARQC 
    to a Processor for approval. */
    proccesorResponse = sendARQCToProcesor(data);

    /* No need to send ARQC Response if transaction option 
    had enabled Quick Chip mode. */
    if (isQuickChipEnabled())
    {
        return;
    }

    // #4b Set Acquirer Response.

    // An application function to build Acquirer Response. 
    NSData* response = buildAcquirerResponse(processorResponse);

    // Set Acquirer Response. 
    [self.mtSCRALib.setAcquirerResponse:(unsigned char *)response
    length:(int)response.length];

}
```

{% endtab %}

{% tab title="Sample 5" %}

```
// #5

-(void)OnDisplayMessageRequest:(NSData *)data
{

    // Get the message.
    NSString* message = [HexUtil stringFromHexString:[self 
getHexString:data]];

    // A data size of 0 is an instruction to clear the display. 
    if (message.Length == 0)
    {
        // Clear the display.
    }
}
```

{% endtab %}

{% tab title="Sample 6" %}

```
// #6

-(void)OnTransactionResult:(NSData *)data
{
    /* data[0]	– Signature Required 
    data[1..2] – Batch Data length
    data[3..n] – remainder contains the Batch Data TLV object */

    // Parse the TLV from data[].
    .
    // Abstract Approval status from TLV tag “DFDF1A”.
    .
    // Abstract Signature Required status from TLV tag data[0].
    .
}
```

{% endtab %}
{% endtabs %}


---

# 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.magtek.com/hardware/oem-readers-and-components/oem-readers/odynamo/documentation/programmers-manuals/reader-emv-flowchart/emv-transaction-flow.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.
