All pages
Powered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

Appendix A - Status Codes

Enum

Description

SUCCESS

The operation completed successfully.

TIMEOUT

The operation timed out.

ERROR

Error attempting the operation.

UNAVAILABLE

Status currently unavailable.

Library Status Codes

Appendix C - EMV Transaction Flow

Flow Chart

Sample Flow Code

The following breaks out the EMV flow chart into code.

// #1

// Assign parameters.
List<PaymentMethod> paymentMethod = new ArrayList<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);

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

@Override
public void OnEvent(EventType eventType, IData data)
{
        String message;
        
        switch (eventType);
                {
                        case EventType.DisplayMessage:
                        
                                // Get the message. 
                                if (data != NULL)
                                {
                                        message = data.StringValue();
                                }

                                break;
        }
}
// #3

@Override
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 
                                IData; selectionData[0] = status; 
                                selectionData[1] = selection; 
                                device.sendSelection(data);

                                break;
                }
}
// #4

@Override
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 */

                                IData processorARPC;
                                procARPC.byteArray = sendForAuthorization(data.ByteArray());

                                // #4b
                                // Send authorization to device when not in QuickChip mode. 
                                if (transaction.QuickChip == false)
                                {
                                        device.sendAuthorization(procARPC.ByteArray());
                                }

                                break;
                }
}
// #1

// Assign parameters.
List<PaymentMethod> paymentMethod = new ArrayList<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);

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

@Override
public void OnEvent(EventType eventType, IData data)
{
        String message;

        switch (eventType);
                {
                        case EventType.DisplayMessage:

                                // Get the message. 
                                if (data != NULL)
                                {
                                        message = data.StringValue();
                                }

                                break;
        }
}
 // #3

@Override
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 IData; 
                                selectionData[0] = status; 
                                selectionData[1] = selection; 
                                device.sendSelection(data);

                                break;
                }
}
 // #4

@Override
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 */

                IData processorARPC;
                procARPC.byteArray = sendForAuthorization(data.ByteArray());

                // #4b
                // Send authorization to device when not in QuickChip mode. 
                if (transaction.QuickChip == false)
                {
                    device.sendAuthorization(procARPC.ByteArray());
                }
                
                break;
        }
}
 // #5

@Override
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.
                                }

                                break;
                }
}
// #6

@Override
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].
                                .
                                break;
        }
}

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 canceled 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:

    Continue with Fallback transaction:

    Appendix B - API Walk Through

    CoreAPI Walk Trough

    The following walks through how to create instances of a device.

    • CoreAPI.createDevice Γ  IDevice

    • CoreAPI.getDeviceList Γ  List<IDevice>

    These examples demonstrate methods for creating an IDevice to be used in the MagTek Universal SDK. This also shows how to establish a device specific API, which is not used with the MagTek Universal SDK.

    Here, a single IDevice is established.

    // Access MMS with Universal SDK using createDevice()
    
    IDevice mtmms = CoreAPI.getDevice( 
            DeviceType.MMS, 
            ConnectionType.USB,
            "",);
    mtmms.requestSignature();

    Here, a list of IDevice is established. The first device is accessed at index 0.

    // Acess MMS with Universal SDK using getDeviceList()
    
    List<IDevice> mtmms = CoreAPI.getDeviceList(DeviceType.MMS); mtmms.get(0).requestSignature();

    IDevice Walk Through

    The following walks through how to make use of IDeviceError! Reference source not found..

    • Implement device events within the class to receive events.

    • CoreAPI --> IDevice.

    • IDevice --> subscribeAll().

    • IDevice --> other functions.

    • IDevice --> startTransaction().

    Example

    Application Main window may extent the Error! Reference source not found. or can be extended by a eparate class. This example uses a separate class and demonstrates how to parse for the various event types.

    Example

    Various events are separately shown below.

    The following walks through how to make use of IDeviceControl.

    • IDevice --> IDeviceControl.

    • IDeviceControl --> open().

    • IDeviceControl --> other functions.

    • IDeviceControl --> close().

    Example

    The following walks through how to make use of ConnectionInfo.

    • IDevice --> ConnectionInfo.

    • ConnectionInfo --> getAddress()

    • ConnectionInfo --> getConnectionType()

    • ConnectionInfo --> getDeviceType() Example

    The following walks through how to make use of Error! Reference source not found..

    • IDevice --> IDeviceCapabilities.

    • IDeviceCapabilities --> BatteryBackedClock() to check if date/time should be set.

    • IDeviceCapabilities --> PaymentMethods() to check card types supported.

    • IDeviceCapabilities --> other functions.

    The following walks through how to make use of IDeviceConfiguration.

    • IDevice --> getDeviceConfiguration().

    • IDeviceConfiguration --> updateFirmware().

    • IDeviceConfiguration --> getConfiguration().

    • IDeviceConfiguration --> setConfiguration().

    • IDeviceConfiguration --> other functions.

    Example

    Application Main window may extent the IConfigurationCallback Delegates or can be extended by a separate class. This example uses a separate class and demonstrates how to parse for the various events.

    Example

    Handling Events

    IDeviceControl Walk Through

    ConnectionInfo Walk Through

    IDeviceCapabilities Walk Through

    IDeviceConfiguration Walk Through

    Handling Events

    import comp.magtek.mtusdk;
    .
    
    // Extend the main window to receive events.
    public class MainWindow implements IEventSubscriber, 
    IConfigurationCallback
    {
    
    /* For a list of a single device type. 
    DeviceType deviceType = DeviceType.MMS;
    List<IDevice> deviceList = CoreAPI.getDeviceList(deviceType); 
    IDevice device = deviceList.get(0);
    */
    
    /* For a list of multiple device types. 
    List<DeviceType> deviceTypes = null; 
    deviceTypes.Add(DeviceType.MMS); 
    deviceTypes.Add(DeviceType.CMS);
    List<IDevice> deviceList = CoreAPI.getDeviceList(deviceTypes); 
    IDevice device = deviceList.get(0);
    */
    
    /* Suscribe to events sent from the device.
        These would be but not limited to: card inserted, card removed, connection state...
        
        Set MainWindow to receive the events. */ 
    boolean return = device.unsubscribeAll(this); 
    boolean return = device.subscribeAll(this);
    
    /* To handle events from some other class. 
    EventsVector eventsVector = new EventsVector() 
    boolean return = device.unsubscribeAll(eventsVector); 
    boolean return = device.subscribeAll(eventsVector);
    */
    
    // Assign parameters for the transaction.
    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);
    
    // Start transaction.
    boolean result = device.startTransaction(transaction);
    // A class to handle events.
    public class EventsVector implements IEventSubscriber
    {
            @Override
            public void OnEvent(EventType eventType, IData data)
            {
                    switch (eventType)
                    {
    case EventType.ConnectionState:
    // Parse for the ConnectionState ConnectionState value =
    ConnectionStateBuilder.GetValue(data.StringValue);
    
    break;
    case EventType.DeviceResponse:
    
    break;
    case EventType.DeviceExtendedResponse:
    
    break;
    case EventType.DeviceNotification:
    
    break;
    case EventType.CardData:
    
    break;
    case EventType.TransactionStatus:
    // Parse for the transaction status code and detail. 
    TransactionStatus status = 
    TransactionStatusBuilder.GetStatusCode(data.StringValue);
    
    String statusDetail = 
    TransactionStatusBuilder.GetStatusDetail(data.StringValue);
    
    break;
    case EventType.DisplayMessage:
    
    String message;
    
    // Get the message. 
    if (data != NULL)
    {
        message = 
    TransactionStatusBuilder.GetStatusDetail(data.StringValue);
    }
    
    break;
    case EventType.InputRequest:
    
    break;
    case EventType.AuthorizationRequest:
    
    // Forward ARQC to processor.
    /* data[0..1] – ARQC length
        data[2..n] – remainder contains the ARQC TLV object
    */
    
    IData processorARPC;
    procARPC.byteArray = sendForAuthorization(data.ByteArray);
    
    // Send authorization to device when not in QuickChip mode. 
    if (transaction.QuickChip == false)
    {
        device.sendAuthorization(procARPC.ByteArray);
    }
    
    break; 
    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 at data[0].
    .
    
    break;
    case EventType.PINBlock:
    
    break;
    case EventType.Signature:
    
    break;
    // Establish a device from CoreAPI.
    List<IDevice> deviceList = CoreAPI.getDeviceList(); IDevice device = deviceList.get(0);
    
    // Establish a deviceControl from device.
    IDeviceControl deviceControl = device.getDeviceControl();
    
    // Open the device, then use the IDeviceControl functions. 
    deviceControl.open();
    
    . . .
    
    // Close the device. deviceControl.close();
    // Establish a device from CoreAPI.
    List<IDevice> deviceList = CoreAPI.getDeviceList(); 
    IDevice device = deviceList.get(0);
    
    // Establish a ConnectionInfo from device.
    ConnectionInfo connectionInfo = device.getConnectionInfo();
    
    // Retrieve address, connectionType, and deviceType. 
    String address = connectionInfo.getAddress();
    ConnectionType connectionType = connectionInfo.getConnectionType(); 
    DeviceType deviceType = connectionInfo.getDeviceType();
    // Establish a device from CoreAPI.
    List<IDevice> deviceList = CoreAPI.getDeviceList(); 
    IDevice device = deviceList.get(0);
    
    // Establish a IDeviceCapabilities from device. 
    IDeviceCapabilities capabilities = device.getCapabilities();
    
    
    // Retrieve device capabilities.
    boolean batteryBackedClock = capabilities.BatteryBackedClock(); 
    if (batteryBackedClock)
    {
            // Call IDeviceControl.setDateTime().
    }
    
    // Retrieve supported card payment methods.
    List<PaymentMethod> paymentMethods = capabilities.PaymentMethods();
    
    . . .
    // Establish a device from CoreAPI.
    List<IDevice> deviceList = CoreAPI.getDeviceList(); 
    IDevice device = deviceList.get(0);
    
    IDeviceConfiguration devConfig = device.getDeviceConfiguration();
    
    IDeviceControl devControl = device.getDeviceControl(); devControl.open();
    
    /* To handle events from some other class.
    ConfigCallBacks configCallBacks = new ConfigCallBacks();
    */
    
    // Update firmware.
    byte[] data = File.ReadAllBytes(β€œfilepath”);
    int return = devConfig.updateFirmware(0x01, data, this);
    
    /* Get configuration.
            Device-Driven Fallback OID = 1.2.1.1.1.1
                    contructed OID = E2 08 E1 06 E1 04 E1 02 C1 00
            Note: first digit of OID is ommited in the custruction and instead is passed as the configType.
    */ 
    data = new byte[] {0xE2,0x08,0xE1,0x06,0xE1,0x04,0xE1,0x02,0xC1,0x00
    };
    byte[] response = devConfig.getConfigInfo(0x01, data);
    
    /* Set configuation.
            Device-Driven Fallback OID is 1.2.1.1.1.1
                    Disabled contructed OID = E2 09 E1 07 E1 05 E1 03 C1 01 00
                            Enabled contructed OID = E2 09 E1 07 E1 05 E1 03 C1 01 01 
            Note: first digit of OID is ommited in the custruction and instead is passed as the configType.
            
    */
    data = new byte[]
    {0xE2,0x09,0xE1,0x07,0xE1,0x05,0xE1,0x03,0xC1,0x01,0x00 };
    result = devConfig.getConfigInfo(0x01, data);
    // A class to handle configuration callback events.
    public class ConfigCallbacks : MTUSDK.IConfigurationCallback
    {
    
        public void OnProgress(int progress)
        {
            /* Handle progress.
            Progress is complete when progress = 100 */
        }
    public void OnResult(StatusCode status, byte[] data)
    {
            /* Handle result.
            A configuration process is complete when 
            status = StatusCode.Success */
    }
    public IResult OnCalculateMAC(byte macType, byte[] data)
    {
            IResult result;
            byte[] macBytes = null;
    
            DeviceType deviceType = 
            device.getConnectionInfo().getDeviceType();
    
            switch (deviceType)
            {
                    case DeviceType.MMS:
                            macBytes = getDynaFlexMAC(macType, data); 
                            break;
            }
    
            if (macBytes != null)
            {
            result = new Result(StatusCode.SUCCESS, new BaseData(macBytes));
            }
    
            return result;
            }
    
    }

    Appendices

    Supplementary reference material for the Java edition of the MagTek Universal SDK. Appendix A lists the status codes your application can use to interpret results and handle errors. Appendix B walks through the API calls in a typical integration sequence. Appendix C outlines the EMV transaction flow and where the host application interacts with it.

    Reference Section

    Information Available

    A: Status Codes

    Status codes returned by the SDK, with their meanings, for use in interpreting results and handling errors.

    B: API Walk Through

    Step-by-step example of the API calls in a typical integration, from connecting to a device through completing a transaction.

    C: EMV Transaction Flow

    Sequence of steps in an EMV chip transaction and the points where your host application provides input or receives data.

    Appendices

    In This Section

    Need More Help

    Need Help?

    For additional support, please contact MagTek Support:

    Technical Support:

    • πŸ“§ Email: support@magtek.com

    • πŸ“ž Phone: 1-562-546-6800 (US)

    • πŸ• Hours: Monday-Friday, 5:30 AM - 5:00 PM Pacific

    Online Resources:

    • 🌐 Support Portal: developer.magtek.com

    • 🌐 Official Site:

    Documentation Feedback:

    Help us improve this documentation!

    https://www.magtek.com
    feedback@magtek.com