> For the complete documentation index, see [llms.txt](https://developer.magtek.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/android/appendices/appendix-c-emv-transaction-flow.md).

# Appendix C - EMV Transaction Flow

This section demonstrates transaction flow.

## Flow Chart - QuickChip

![](/files/fb6ac7083e93dd780e12be7c411f7c945354a802)

## Sample Code - QuickChip

The following breaks out the EMV flow chart into code. When enabling QuickChip mode, host does not send the ARPC to the device to complete the transaction. Events are shown separately and in the order received.

```csharp
// Assign parameters.
List<PaymentMethod> paymentMethod = new List<PaymentMethod>(); 
paymentMethod.Add(PaymentMethod.MSR); 
paymentMethod.Add(PaymentMethod.Contact); 
paymentMethod.Add(PaymentMethod.Contactless);

Transaction transaction = new Transaction(); 
transaction.setAmount(“1.00”); 
transaction.setCashBack(“0.00”); 
transaction.setEMVOnly(true); 
transaction.setPaymentMethods(paymentMethod); 
transaction.setQuickChip(true); // QuickChip mode enabled.

// Start transaction.
boolean result = device.startTransaction(transaction);
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message 
    switch (eventType);
        {
            case EventType.DisplayMessage:
                // Get the message.
                message = data.StringValue();
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.InputRequest:
            // Get the message.
            message = data.StringValue();

            // display/retrieve user selection.

            // set status and selection result.
            IData selectionData = new BaseData(new Byte[] {status, selection});
            device.sendSelection(selectionData);
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
byte[] ARQC = null; 
switch (eventType);
    {
        case EventType.AuthorizationRequest:
            // Forward ARQC to processor.
            /* data[0..1] – ARQC length
                data[2..n] – remainder contains the ARQC TLV object */
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
        
            case EventType.TransactionResult:
                /* 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].
        }
}
```

## Flow Chart – Signature Capture

![](/files/fd0c777fc22d0e9c619a6b6fe76a07bda1b5210f)

## Sample Code – Signature Capture

The following breaks out the EMV flow chart into code. Events are shown separately and in the order received.

```csharp
// Assign parameters.
List<PaymentMethod> paymentMethod = new List<PaymentMethod>(); 
paymentMethod.Add(PaymentMethod.MSR); 
paymentMethod.Add(PaymentMethod.Contact); 
paymentMethod.Add(PaymentMethod.Contactless);

Transaction transaction = new Transaction(); 
transaction.setAmount(“1.00”); 
transaction.setCashBack(“0.00”); 
transaction.setEMVOnly(true); 
transaction.setPaymentMethods(paymentMethod); 
transaction.setQuickChip(true);

// Start transaction.
boolean result = device.startTransaction(transaction);
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.DisplayMessage:

                // Get the message.
                message = data.StringValue();
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    byte[] ARQC = null; 
    switch (eventType);
        {
            case EventType.AuthorizationRequest:
                // #4a
                // Forward ARQC to processor.
                /* data[0..1] – ARQC length
                    data[2..n] – remainder contains the ARQC TLV object */
        }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.DisplayMessage:
                // Display approval message. 
                message = data.StringValue();

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

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.TransactionResult:
                /* 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].
        }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String signature; 
    switch (eventType);
        {
            case EventType.Signature: 
                signature = data.StringValue();
        }
}
```

## Flow Chart – With ARPC

![](/files/6063c54bcd835a4e3ff500bb0964718dc2e939f3)

## Sample Code – With ARPC

The following breaks out the EMV flow chart into code. When disabling QuickChip mode, host must send the ARPC to the device to complete the transaction. Events are shown separately and in the order received.

```csharp
// Assign parameters.
List<PaymentMethod> paymentMethod = new List<PaymentMethod>(); 
paymentMethod.Add(PaymentMethod.MSR); 
paymentMethod.Add(PaymentMethod.Contact); 
paymentMethod.Add(PaymentMethod.Contactless);

Transaction transaction = new Transaction(); 
transaction.setAmount(“1.00”); 
transaction.setCashBack(“0.00”); 
transaction.setEMVOnly(true); 
transaction.setPaymentMethods(paymentMethod); 
transaction.setQuickChip(false); //QuickChip mode disabled.

// Start transaction.
boolean result = device.startTransaction(transaction);
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    string message; 
    switch (eventType);
        {
            case EventType.DisplayMessage:

                // Get the message.
                message = data.StringValue;
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    string message; 
    switch (eventType);
        {
            case EventType.InputRequest:
                // Get the message.
                message = data.StringValue;

                // display/retrieve user selection.

                // set status and selection result.
                IData selectionData = new BaseData(new Byte[] {status, selection});
device.sendSelection(selectionData);
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    byte[] ARQC = null; 
    switch (eventType);
        {
            case EventType.AuthorizationRequest:
                // Forward the ARQC to the processor.
                /* data[0..1] – ARQC length
                data[2..n] – remainder contains the ARQC TLV object */

                ARQC.ByteArray = data.ByteArray;
                // App function to send the request to the processor. 
                ARPC = sendARQCToProcessorForApproval(ARQC.ByteArray());

        }
}
```

After the ARPC is returned from the processor, it is constructed into a TLV container and then sent to the device. The ARPC for approved (00) is set in ASCII 3030.

The optional tags 91, 71, and 72 (Issuer Authentication Data, Issuer Script Template 1, and Issuer Script Template 2) are not included in this example.

See the construction of the ARPCTLV in the table below.

```csharp
String ARPC = “8A3030”;
IData ARPCTLV = new BaseData(“FF7413DFDF250742363243413546FA067004” + ARPC);

device.sendAuthorization(ARPCTLV);
```

ARPC TLV object for `sendAuthorization()`.

| Tag     | Len | Value / Description                                                                                                                             | Typ | Req | Default                                                                                                                                                                                                                 |
| ------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FF74    | var | Container for non-MAC ARPC                                                                                                                      | T   | R   |                                                                                                                                                                                                                         |
| /DFDF25 | var | Device Serial Number (IFD Serial Number)                                                                                                        | B   | R   |                                                                                                                                                                                                                         |
| /FA     | var | Container for generic data                                                                                                                      | T   | R   |                                                                                                                                                                                                                         |
| //70    | var | Container for ARPC                                                                                                                              | T   | R   |                                                                                                                                                                                                                         |
| ///8A   | 02  | Authorization Response Code                                                                                                                     | AN  | R   |                                                                                                                                                                                                                         |
|         |     | <p>· 0x3030 = Approved<br>· 0x3031 = Issuer Referral<br>· 0x3035 = Declined<br>· 0x3132 = Switch Interface<br>· 0x3133 = Request Online PIN</p> |     |     |                                                                                                                                                                                                                         |
| ///91   | var | Issuer Authentication Data                                                                                                                      | B   | O   | As defined in *EMV Integrated Circuit Card Specifications for Payment Systems 4.3*                                                                                                                                      |
| ///71   | var | Issuer Script Template 1                                                                                                                        | B   | O   | As defined in *EMV Integrated Circuit Card Specifications for Payment Systems 4.3*. The host may include as many instances of this parameter as needed, up to a maximum length of 128 bytes including Tags and Lengths. |
| ///72   | var | Issuer Script Template 2                                                                                                                        | B   | O   | As defined in *EMV Integrated Circuit Card Specifications for Payment Systems 4.3*. The host may include as many instances of this parameter as needed, up to a maximum length of 128 bytes including Tags and Lengths. |

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.DisplayMessage:
                // Display approval message. 
                message = data.StringValue();

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

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String message; 
    switch (eventType);
        {
            case EventType.TransactionResult:
                /* 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].
    }
}
```

```csharp
public void OnEvent(EventType eventType, IData data)
{
    String signature; 
    switch (eventType);
        {
            case EventType.Signature: 
                signature = data.StringValue();
        }
}
```

## MSR Fallback Flow

The use case for an MSR fallback is when communication with the chip results in a terminated transaction and the TransactionStatus is reported as MSRFallback.

The host application will re-attempt the transaction. To invoke this use case, here are the following pre-requisites.

**Pre-requisites:**

* Device already configured for Device-Driven Fallback = Disabled.
* A card to cause the fallback. Example but not limited to a card with no applications programmed or a card with an application not configured on the device.

**Scheme:**

* \-->Host begins an initial transaction with PaymentMethod set to MSR+Chip+Contactless.
* <--Device responds with fail and with status of MSRFallback.
* \-->Host displays a message to use magstripe.
* \-->Host starts a transaction with PaymentMethod set to MSR.
* <--Device may respond with transaction cancelled card read error.
* \-->Host displays a message each time the transaction fails until successful or until Host decides to end the transaction.
* <--Device sends the transaction result.

**Begin initial transaction:**

![](/files/50e01546fa85602efc6ac4c8b3a651701a2c74f2)

**Continue with Fallback transaction:**

![](/files/51648520439c76f96ce440184424dea5eb07930e)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/android/appendices/appendix-c-emv-transaction-flow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
