Example #1
0
 public TxCompletedEventArgs(TxResult txResult, InterFaceType interFaceType, Optional <TLV> emvData, Optional <QRDEList> qr_Data)
 {
     TxResult      = txResult;
     InterFaceType = interFaceType;
     EMV_Data      = emvData;
     QR_Data       = qr_Data;
 }
Example #2
0
        private EMVApproverResponse GoOnlineForContactEMV(InterFaceType interfaceType, TLV data, TLV discretionary)
        {
            try
            {
                #region Merge EMV Lists
                if (discretionary != null)
                {
                    data.Children.AddListToList(discretionary.Children);
                }
                #endregion

                EMVApproverResponse onlineResponse = (EMVApproverResponse)onlineContactEMVApprover.DoAuth(
                    new EMVApproverRequest()
                {
                    EMV_Data        = data,
                    TCPClientStream = tcpClientStream
                });
                return(onlineResponse);
            }
            catch (Exception ex)
            {
                Logger.Log("Unable to go online:" + ex.Message);
                return(null);
            }
        }
Example #3
0
 private void SetStatusLabel(UIMessageEventArgs message, InterFaceType interFaceType)
 {
     foreach (UIMessageEventArgs ui in statusMessages.ToArray())
     {
         if (ui.MessageIdentifiers == message.MessageIdentifiers)
         {
             return;
         }
     }
     Logger.Log("SetStatusLabel: " + interFaceType + " - " + message.MessageIdentifiers + " additional mesage:" + message.AdditionalMessage);
     if (message.MessageIdentifiers == MessageIdentifiersEnum.SeePhone)
     {
         SetTxFinalResultLabel("See Phone");
     }
     statusMessages.Enqueue(message);
 }
Example #4
0
        private void ProcessCompletion(TerminalProcessingOutcomeEventArgs e, InterFaceType interFaceType)
        {
            TLV      data = null;
            TLV      discretionaryData = null;
            QRDEList qrData            = null;

            try
            {
                long?amount = Convert.ToInt64(totalAmount.Total);

                TerminalProcessingOutcome tpo = e.TerminalProcessingOutcome;
                if (tpo == null)//error occurred, error displayed via Ta_ExceptionOccured
                {
                    return;
                }

                if (tpo is EMVTerminalProcessingOutcome)
                {
                    data = ((EMVTerminalProcessingOutcome)tpo).DataRecord;
                    discretionaryData = ((EMVTerminalProcessingOutcome)tpo).DiscretionaryData;
                    qrData            = ((EMVTerminalProcessingOutcome)tpo).QRData;

                    if (data != null) //error
                    {
                        SetStatusLabel(new UIMessageEventArgs(MessageIdentifiersEnum.RemoveCard, StatusEnum.EndProcessing), interFaceType);

                        //may be a contactless magstripe transaction
                        if (data.Children.Get(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN.Tag) == null)
                        {
                            txResult = TxResult.ContactlessMagOnline;
                        }
                        else
                        {
                            if (((data.Children.Get(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN.Tag).Value[0] & 0xC0) >> 6) == (byte)ACTypeEnum.ARQC)
                            {
                                if (interFaceType == InterFaceType.Contact)
                                {
                                    throw new EMVProtocolException("Invalid state for contact, gen ac 2 returned arqc?");
                                }

                                CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN cvmr = new CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN(data.Children.Get(EMVTagsEnum.CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN.Tag));
                                if (cvmr.Value.GetCVMPerformed() == CVMCode.EncipheredPINVerifiedOnline)
                                {
                                    ContactlessApp_PinRequest(data.Children);
                                }

                                txResult = TxResult.ContactlessOnline;
                            }
                            if (((data.Children.Get(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN.Tag).Value[0] & 0xC0) >> 6) == (byte)ACTypeEnum.TC)
                            {
                                txResult = TxResult.Approved;
                            }
                            if (((data.Children.Get(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN.Tag).Value[0] & 0xC0) >> 6) == (byte)ACTypeEnum.AAC)
                            {
                                txResult = TxResult.Declined;
                            }
                        }
                    }
                    else if (qrData != null)
                    {
                        if (interFaceType == InterFaceType.QRCodeScanned)
                        {
                            txResult = TxResult.QRCodeScanned;
                        }
                        else if (interFaceType == InterFaceType.QRCodeToPoll)
                        {
                            txResult = TxResult.QRCodeToPoll;
                        }
                    }
                    else
                    {
                        txResult = TxResult.Declined;
                    }

                    SetTxFinalResultLabel(txResult.ToString());
                }
                else
                {
                    SetStatusLabel(new UIMessageEventArgs(tpo.UserInterfaceRequest.MessageIdentifier, tpo.UserInterfaceRequest.Status), interFaceType);
                }
            }
            catch (Exception ex)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    UIMessageEventArgs ui = new UIMessageEventArgs(MessageIdentifiersEnum.TryAgain, StatusEnum.ProcessingError)
                    {
                        AdditionalMessage = ex.Message
                    };
                    SetStatusLabel(ui, interFaceType);
                });
            }
            finally
            {
                StopContactPaymentApp();
                StopContactlessPaymentApp();
                StopQRCodePollPaymentApp();

                #region Merge EMV Lists
                if (discretionaryData != null)
                {
                    if (data != null)
                    {
                        data.Children.AddListToList(discretionaryData.Children);
                    }
                }
                #endregion

                TxCompleted?.Invoke(this, new TxCompletedEventArgs(txResult, interFaceType, Optional <TLV> .Create(data), Optional <QRDEList> .Create(qrData)));
            }
        }