public string AuthTransactionToIssuer(string json)
        {
            ContactCardOnlineAuthRequest  request  = ContactCardOnlineAuthRequest.FromJsonString(json);
            ContactCardOnlineAuthResponse response = new ContactCardOnlineAuthResponse();

            try
            {
                EMVApproverResponse onlineResponse = GoOnline(
                    new EMVApproverRequest()
                {
                    EMV_Data = TLVasJSON.Convert(request.EMV_Data),
                });

                response.AuthCode_8A       = TLVasJSON.Convert(onlineResponse.AuthCode_8A);
                response.IssuerAuthData_91 = TLVasJSON.Convert(onlineResponse.IssuerAuthData_91);
                response.ResponseMessage   = onlineResponse.ResponseMessage;
                if (onlineResponse.IsApproved)
                {
                    response.Response = ContactCardOnlineAuthResponseEnum.Approved;
                }
                else
                {
                    response.Response = ContactCardOnlineAuthResponseEnum.Declined;
                }

                return(JsonConvert.ToString(response.ToJsonString()));
            }
            catch (Exception ex)
            {
                response.Response = ContactCardOnlineAuthResponseEnum.UnableToGoOnline;
                Logger.Log("Unable to go online:" + ex.Message);
                return(JsonConvert.ToString(response.ToJsonString()));
            }
        }
Example #2
0
        private ApproverResponseBase DoEMVAuth(ApproverRequestBase requestIn)
        {
            try
            {
                EMVApproverRequest request = ((EMVApproverRequest)requestIn);

                DCEMVDemoServerClient client = SessionSingleton.GenDCEMVServerApiClient();
                using (SessionSingleton.HttpClient)
                {
                    ContactCardOnlineAuthRequest tx = new ContactCardOnlineAuthRequest()
                    {
                        EMV_Data = TLVasJSON.Convert(request.EMV_Data),
                    };
                    string responseJson = "";
                    Task.Run(async() => {
                        responseJson = await client.TransactionAuthtransactiontoissuerPostAsync(tx.ToJsonString());
                    }).Wait();
                    ContactCardOnlineAuthResponse response = ContactCardOnlineAuthResponse.FromJsonString(responseJson);

                    EMVApproverResponse approverResponse = null;
                    switch (response.Response)
                    {
                    case ContactCardOnlineAuthResponseEnum.Approved:
                    case ContactCardOnlineAuthResponseEnum.Declined:
                        approverResponse                   = new EMVApproverResponse();
                        approverResponse.AuthCode_8A       = TLVasJSON.Convert(response.AuthCode_8A);
                        approverResponse.IssuerAuthData_91 = TLVasJSON.Convert(response.IssuerAuthData_91);
                        approverResponse.IsApproved        = response.Response == ContactCardOnlineAuthResponseEnum.Approved ? true : false;
                        approverResponse.ResponseMessage   = response.ResponseMessage;
                        break;

                    case ContactCardOnlineAuthResponseEnum.UnableToGoOnline:
                        break;
                    }

                    return(approverResponse);
                }
            }
            catch
            {
                return(null);
            }
        }