Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=#0000FF]using[/color] System;
[COLOR=#0000FF]using[/color] System.Globalization;
[COLOR=#0000FF]using[/color] MO = Micros.Ops;
[COLOR=#0000FF]using[/color] MX = Micros.PosCore.Extensibility;
[COLOR=#0000FF]using[/color] MCC = Micros.PosCore.Common.Classes;
[COLOR=#0000FF]using[/color] MDS = Micros.PosCore.DataStore;
[COLOR=#0000FF]using[/color] Micros.XProcessor.SVC;
[COLOR=#0000FF]using[/color] Micros.XProcessor.SVC.Message;
[COLOR=#0000FF]using[/color] System.Threading;
[COLOR=#0000FF]using[/color] System.Text.RegularExpressions;
[COLOR=#0000FF]using[/color] System.Collections;
[COLOR=#0000FF]namespace[/color] Micros.XProcessor.SVS
{
[COLOR=#0000FF]public[/color] [COLOR=#0000FF]class[/color] [COLOR=#2B91AF]SvsWebServiceCommChannel[/color] : [COLOR=#2B91AF]ICommChannel[/color]
{
[COLOR=#808080]#region[/color] Constructors
[COLOR=#0000FF]internal[/color] SvsWebServiceCommChannel([COLOR=#2B91AF]XProcessorApp[/color] xprocessorApp, [COLOR=#2B91AF]SVSSettings[/color] settings)
{
App = xprocessorApp;
Settings = settings;
}
[COLOR=#808080]#endregion[/color]
[COLOR=#808080]#region[/color] Public
[COLOR=#0000FF]public[/color] [COLOR=#0000FF]override[/color] [COLOR=#0000FF]string[/color] ToString()
{
[COLOR=#0000FF]return[/color] [COLOR=#A31515]"Web Service"[/color];
}
[COLOR=#808080]#endregion[/color]
[COLOR=#808080]#region[/color] Private
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]SVSSettings[/color] Settings { [COLOR=#0000FF]get[/color]; [COLOR=#0000FF]set[/color]; }
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]XProcessorApp[/color] App { [COLOR=#0000FF]get[/color]; [COLOR=#0000FF]set[/color]; }
[COLOR=#0000FF]private[/color] [COLOR=#0000FF]const[/color] [COLOR=#0000FF]string[/color] SVS_APPROVAL_RETURN_CODE = [COLOR=#A31515]"01"[/color];
[COLOR=#0000FF]private[/color] [COLOR=#0000FF]const[/color] [COLOR=#0000FF]string[/color] SVS_HOST_UNAVAILABLE_RETURN_CODE = [COLOR=#A31515]"15"[/color];
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessPreAuthorization([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]PreAuthRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreatePreAuthRequest(svcSession);
SVSWS.[COLOR=#2B91AF]PreAuthResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).preAuth(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessCancel([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]CancelRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateCancelRequest(svcSession);
SVSWS.[COLOR=#2B91AF]CancelResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).cancel(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessIssueGiftCard([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]IssueGiftCardRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateIssueGiftCardRequest(svcSession);
SVSWS.[COLOR=#2B91AF]IssueGiftCardResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).issueGiftCard(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessCardActivation([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]CardActivationRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateCardActivationRequest(svcSession);
SVSWS.[COLOR=#2B91AF]CardActivationResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).cardActivation(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessCardRecharge([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]CardRechargeRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateCardRechargeRequest(svcSession);
SVSWS.[COLOR=#2B91AF]CardRechargeResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).cardRecharge(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessCashBack([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]CashBackRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateCashBackRequest(svcSession);
SVSWS.[COLOR=#2B91AF]CashBackResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).cashBack(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessBalanceInquire([COLOR=#2B91AF]SvcSession[/color] svcSession, [COLOR=#0000FF]bool[/color] is_auth)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
[COLOR=#2B91AF]SVCMessage[/color] svc_response = svcSession.Response;
SVSWS.[COLOR=#2B91AF]BalanceInquiryRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateBalanceInquireRequest(svcSession);
SVSWS.[COLOR=#2B91AF]BalanceInquiryResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).balanceInquiry(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#2B91AF]CommChannelError[/color] comm_error = SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
[COLOR=#0000FF]null[/color],
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
[COLOR=#0000FF]if[/color] (is_auth)
{
[COLOR=#0000FF]decimal[/color] tranAmount = [COLOR=#2B91AF]Convert[/color].ToDecimal(svc_request.Amount);
[COLOR=#0000FF]decimal[/color] balAmount = [COLOR=#2B91AF]Convert[/color].ToDecimal(svc_response.AccountBalance);
[COLOR=#0000FF]if[/color] (tranAmount > balAmount)
svc_response.Amount = svc_response.AccountBalance;
[COLOR=#0000FF]else[/color]
svc_response.Amount = svc_request.Amount;
}
[COLOR=#0000FF]return[/color] comm_error;
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessRedemption([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]RedemptionRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateRedemptionRequest(svcSession);
SVSWS.[COLOR=#2B91AF]RedemptionResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).redemption(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] ProcessReversal([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#2B91AF]SVCMessage[/color] svc_request = svcSession.Request;
SVSWS.[COLOR=#2B91AF]ReversalRequest[/color] ws_request = [COLOR=#2B91AF]SVSWSFactory[/color].CreateReversalRequest(svcSession);
SVSWS.[COLOR=#2B91AF]ReversalResponse[/color] ws_response = [COLOR=#2B91AF]SVSWSFactory[/color].GetGiftCardService(Settings).reversal(ws_request);
[COLOR=#0000FF]if[/color] (ws_response.returnCode.returnCode == SVS_APPROVAL_RETURN_CODE)
{
[COLOR=#0000FF]return[/color] SetSvcSuccessResponse(
svcSession,
ws_response.stan,
ws_response.card,
ws_response.approvedAmount,
ws_response.balanceAmount,
ws_response.conversionRate,
ws_response.returnCode);
}
[COLOR=#0000FF]else[/color]
{
[COLOR=#0000FF]return[/color] SetSvcHostErrorResponse(svcSession, ws_response.returnCode);
}
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] SetSvcSuccessResponse(
[COLOR=#2B91AF]SvcSession[/color] svcSession,
[COLOR=#0000FF]string[/color] stan,
SVSWS.[COLOR=#2B91AF]Card[/color] card,
SVSWS.[COLOR=#2B91AF]Amount[/color] approval_amount,
SVSWS.[COLOR=#2B91AF]Amount[/color] balance_amount,
[COLOR=#0000FF]string[/color] conversion_rate,
SVSWS.[COLOR=#2B91AF]ReturnCode[/color] returnCode)
{
[COLOR=#2B91AF]SVCMessage[/color] svcResponse = svcSession.Response;
svcResponse.SVAN = card.cardNumber;
svcResponse.AuthorizationCode = stan;
svcResponse.ResponseCode.Value = [COLOR=#2B91AF]ResponseCodeEnum[/color].A;
[COLOR=#808080]///[/color]
[COLOR=#808080]///[/color][COLOR=#008000] SVS does not return the balance in the account currency. All amounts are always in [/color]
[COLOR=#808080]///[/color][COLOR=#008000] the local currency of the site. Since we do not want to do a calculation to get [/color]
[COLOR=#808080]///[/color][COLOR=#008000] account balance in the account currency, we simply don't report the account balance [/color]
[COLOR=#808080]///[/color][COLOR=#008000] any differently (i.e., only show local currency information). Given that this [/color]
[COLOR=#808080]///[/color][COLOR=#008000] is where the customer is, this is the amount that matters.[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
svcResponse.ExchangeRate = [COLOR=#A31515]"1.0"[/color];
svcResponse.AccountBalance = balance_amount.amount.ToString();
svcResponse.AccountCurrency = balance_amount.currency;
svcResponse.ResponseCode.hostCode = returnCode.returnDescription;
[COLOR=#0000FF]if[/color] (approval_amount != [COLOR=#0000FF]null[/color])
{
[COLOR=#008000]//[/color]
[COLOR=#008000]// See documentation of Field 04 in "ISO 8583 Message Specifications v3_7.pdf" for details [/color]
[COLOR=#008000]// on why activation are handled differently. It is not spelled out specifically, but[/color]
[COLOR=#008000]// if the activate message sends a value that is different from the pre-valued card amount,[/color]
[COLOR=#008000]// the transaction amount (field 04) is the requested amount and the balance is what was[/color]
[COLOR=#008000]// actually approved. To be sure we get it right, we always use the balance amount for [/color]
[COLOR=#008000]// activate.[/color]
[COLOR=#008000]//[/color]
[COLOR=#0000FF]if[/color] (svcResponse.RequestCode.ToLower() == [COLOR=#A31515]"SVActivat"[/color].ToLower())
svcResponse.Amount = DecimalAsString(balance_amount.amount);
[COLOR=#0000FF]else[/color]
svcResponse.Amount = DecimalAsString(approval_amount.amount);
}
[COLOR=#0000FF]return[/color] [COLOR=#2B91AF]CommChannelError[/color].Success;
}
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] Helper function for setting up a SVC error response[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]svc_request[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]svc_response[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]rc[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns></returns>[/color]
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]CommChannelError[/color] SetSvcHostErrorResponse([COLOR=#2B91AF]SvcSession[/color] svcSession, SVSWS.[COLOR=#2B91AF]ReturnCode[/color] rc)
{
[COLOR=#0000FF]if[/color] (svcSession.Response.ResponseCode == [COLOR=#0000FF]null[/color])
svcSession.Response.ResponseCode = [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]ResponseCode[/color]();
svcSession.Response.ResponseCode.Value = [COLOR=#2B91AF]ResponseCodeEnum[/color].D;
svcSession.Response.DisplayMessage = rc.returnDescription;
[COLOR=#0000FF]return[/color] (rc.returnCode == SVS_HOST_UNAVAILABLE_RETURN_CODE && RequiresTimeoutReversal(svcSession))
? [COLOR=#2B91AF]CommChannelError[/color].TimeoutReversalRequired
: [COLOR=#2B91AF]CommChannelError[/color].Success;
}
[COLOR=#0000FF]public[/color] [COLOR=#0000FF]bool[/color] RequiresTimeoutReversal([COLOR=#2B91AF]SvcSession[/color] svcSession)
{
[COLOR=#008000]// The HostRecoveryReqquired setting is also use by the SVCProcessor to send a reversal if [/color]
[COLOR=#008000]// there is a failure processing a successful response on the POS client. This is different [/color]
[COLOR=#008000]// from the SVS TOR, but transactions than need a reversal on client errors also need a TOR[/color]
[COLOR=#008000]// if there is a communication failure. [/color]
[COLOR=#0000FF]if[/color] (svcSession.OperationSettings != [COLOR=#0000FF]null[/color])
[COLOR=#0000FF]return[/color] svcSession.OperationSettings.HostErrorRecoveryRequired;
[COLOR=#0000FF]else[/color]
[COLOR=#0000FF]return[/color] [COLOR=#0000FF]true[/color];
}
[COLOR=#808080]#endregion[/color]
[COLOR=#808080]#region[/color] ICommChannel Members
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] Indicates if the comm channel is supported in the current environment.[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<remarks>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] The SVS WebService communication channel does not work when running the service on [/color]
[COLOR=#808080]///[/color][COLOR=#008000] a WS/4. The problem is cause by a bug in .NET CF 2.0 SP 1 and results in [/color]
[COLOR=#808080]///[/color][COLOR=#008000] transactions to SVS to fail while waiting for a response. We have verified the [/color]
[COLOR=#808080]///[/color][COLOR=#008000] problem and is fixed by upgrading to .NET CF 2.0 SP 2. This was done by reproducing [/color]
[COLOR=#808080]///[/color][COLOR=#008000] the problem on my WS/4 using SP 1, and then upgrading to SP 2 and attempting [/color]
[COLOR=#808080]///[/color][COLOR=#008000] the same transaction. Additionally, a WS/4LX and a WS/5 that have [/color]
[COLOR=#808080]///[/color][COLOR=#008000] SP 2 installed and do not exhibit the same problems.[/color]
[COLOR=#808080]///[/color]
[COLOR=#808080]///[/color][COLOR=#008000] This problem only impacts WS running .NET CF 2.0 SP 1 (and perhaps earlier, but [/color]
[COLOR=#808080]///[/color][COLOR=#008000] that has not been verified). This seems to be limited to WS/4s, but there could [/color]
[COLOR=#808080]///[/color][COLOR=#008000] be other WS that have platforms w/ the same version of .NET CF.[/color]
[COLOR=#808080]///[/color]
[COLOR=#808080]///[/color][COLOR=#008000] As of Apr-2009 [/color]
[COLOR=#808080]///[/color][COLOR=#008000] - there is not a WS/4 platform that includes .NET CF 2.0 SP 2. [/color]
[COLOR=#808080]///[/color][COLOR=#008000] - there is not a simple workarounds to this problem available to the client[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] Web Reference:[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] [URL unfurl="true"]http://blogs.msdn.com/andrewarnottms/archive/2007/11/19/why-net-compact-framework-fails-to-call-some-https-web-servers.aspx[/URL][/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] Because of this issue, we are only supporting the WebService communication channel[/color]
[COLOR=#808080]///[/color][COLOR=#008000] on WinCE if the CF version is 2.0 SP 2 or later.[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</remarks>[/color]
[COLOR=#0000FF]public[/color] [COLOR=#0000FF]bool[/color] IsSupported
{
[COLOR=#0000FF]get[/color]
{
[COLOR=#0000FF]if[/color] ([COLOR=#2B91AF]DotNet[/color].IsWinCE)
[COLOR=#0000FF]return[/color] [COLOR=#2B91AF]DotNet[/color].IsVersion([COLOR=#2B91AF]DotNet[/color].[COLOR=#2B91AF]DotNetVersion[/color].NetCF_20_SP2_RTM, [COLOR=#0000FF]true[/color]);
[COLOR=#0000FF]else[/color]
[COLOR=#0000FF]return[/color] [COLOR=#0000FF]true[/color];
}
}
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]</summary>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]svc_request[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]svc_response[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<param name="[/color]is_timeout_reversal[COLOR=#808080]"></param>[/color]
[COLOR=#808080]///[/color][COLOR=#008000] [/color][COLOR=#808080]<returns></returns>[/color]
[COLOR=#0000FF]public[/color] [COLOR=#2B91AF]CommChannelError[/color] Process([COLOR=#2B91AF]SvcSession[/color] svcSession, [COLOR=#0000FF]bool[/color] is_timeout_reversal)
{
[COLOR=#2B91AF]CommChannelError[/color] cc_status = [COLOR=#2B91AF]CommChannelError[/color].Success;
[COLOR=#0000FF]try[/color]
{
App.Log.Info([COLOR=#A31515]"**** Processing SVS operation ****"[/color]);
[COLOR=#0000FF]if[/color] (is_timeout_reversal)
{
[COLOR=#0000FF]return[/color] ProcessReversal(svcSession);
}
Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color] tid = (Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color])[COLOR=#2B91AF]Enum[/color].Parse([COLOR=#0000FF]typeof[/color](Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color]), svcSession.Request.RequestCode, [COLOR=#0000FF]true[/color]); [COLOR=#008000]//svc_request.Transaction.TID;[/color]
svcSession.Response = Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]SVCMessage[/color].CreateResponseFromRequest(svcSession.Request);
[COLOR=#0000FF]if[/color] (svcSession.Request.IsReversal)
{
[COLOR=#808080]///[/color][COLOR=#008000] NOTE: void of a authorization is handled further up the stack[/color]
[COLOR=#0000FF]return[/color] ProcessCancel(svcSession);
}
App.Log.InfoFormat([COLOR=#A31515]"**** Processing SVS operation [{0}] ****"[/color], tid.ToString());
[COLOR=#0000FF]switch[/color](tid)
{
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_ISSUE:
cc_status = ProcessIssueGiftCard(svcSession);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_ACTIVATE:
cc_status = ProcessCardActivation(svcSession);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_RELOAD:
cc_status = ProcessCardRecharge(svcSession);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_CASHOUT:
cc_status = ProcessCashBack(svcSession);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_BALANCE_INQUIRY:
cc_status = ProcessBalanceInquire(svcSession, [COLOR=#0000FF]false[/color]);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_REDEMPTION:
cc_status = ProcessRedemption(svcSession);
[COLOR=#0000FF]break[/color];
[COLOR=#0000FF]case[/color] Micros.XProcessor.SVC.Message.[COLOR=#2B91AF]RequestCode[/color].SV_REDEMPTION_AUTH:
[COLOR=#808080]///[/color][COLOR=#008000] need to make sure if this is the preauth and the preauthcompletion [/color]
[COLOR=#808080]///[/color][COLOR=#008000] request code we will get in terms of authorization.[/color]
[COLOR=#008000]//case Micros.Svc.Message.Pos.TransactionID.SVAuthorization:[/color]
[COLOR=#808080]///[/color]
[COLOR=#808080]///[/color][COLOR=#008000] SVS has a PreAuthorization and PreAuthorizationCompletion however[/color]
[COLOR=#808080]///[/color][COLOR=#008000] we handle this using inquire and redeem (as did the legacy [/color]
[COLOR=#808080]///[/color][COLOR=#008000] implementation). One problem with trying to use these transactions is [/color]
[COLOR=#808080]///[/color][COLOR=#008000] that the PreAuthorizationCompletion transaction needs information from [/color]
[COLOR=#808080]///[/color][COLOR=#008000] the original PreAuthorization transaction that is not otherwise available.[/color]
[COLOR=#808080]///[/color]
cc_status = ProcessBalanceInquire(svcSession, [COLOR=#0000FF]true[/color]);
[COLOR=#0000FF]break[/color];
}
}
[COLOR=#0000FF]catch[/color]([COLOR=#2B91AF]SvsRequestFormatException[/color] ex)
{
[COLOR=#808080]///[/color][COLOR=#008000] This happens before a request is sent, so no need for a reversal.[/color]
cc_status = [COLOR=#2B91AF]CommChannelError[/color].RequestFormatFailure;
App.Log.ErrorFormat([COLOR=#A31515]"SvsRequestFormatException: {0}"[/color], ex.Message);
}
[COLOR=#0000FF]catch[/color](System.Net.[COLOR=#2B91AF]WebException[/color] ex)
{
App.Log.ErrorFormat([COLOR=#A31515]"WebException: {0} [{1}]"[/color], ex.Message, ex.Status);
[COLOR=#0000FF]if[/color] (ex.Status == System.Net.[COLOR=#2B91AF]WebExceptionStatus[/color].ReceiveFailure)
{
cc_status = [COLOR=#2B91AF]CommChannelError[/color].TimeoutReversalRequired;
}
[COLOR=#0000FF]else[/color]
{
cc_status = [COLOR=#2B91AF]CommChannelError[/color].ConnectFailed;
}
}
[COLOR=#0000FF]catch[/color]([COLOR=#2B91AF]Exception[/color] ex)
{
App.Log.Error([COLOR=#A31515]"Caught Exception"[/color]);
[COLOR=#808080]///[/color][COLOR=#008000] At this point we are not a 100% sure what failed, so we'll require[/color]
[COLOR=#808080]///[/color][COLOR=#008000] a TOR just in case.[/color]
cc_status = [COLOR=#2B91AF]CommChannelError[/color].TimeoutReversalRequired;
App.Log.ErrorFormat([COLOR=#A31515]"Unexpected exception: {0}"[/color], ex.Message);
[COLOR=#008000]// The error message here does not really matter, it'll get updated[/color]
[COLOR=#008000]// as part of the TOR processing. [/color]
}
[COLOR=#0000FF]return[/color] cc_status;
}
[COLOR=#0000FF]public[/color] [COLOR=#0000FF]string[/color] DecimalAsString([COLOR=#0000FF]double[/color] value)
{
[COLOR=#0000FF]if[/color] ([COLOR=#0000FF]this[/color].DecimalPlaces == 0)
[COLOR=#0000FF]return[/color] value.ToString([COLOR=#A31515]"0"[/color]);
[COLOR=#0000FF]else[/color] [COLOR=#0000FF]if[/color] ([COLOR=#0000FF]this[/color].DecimalPlaces == 3)
[COLOR=#0000FF]return[/color] value.ToString([COLOR=#A31515]"0.000"[/color]);
[COLOR=#0000FF]else[/color]
[COLOR=#0000FF]return[/color] value.ToString([COLOR=#A31515]"0.00"[/color]);
}
[COLOR=#808080]#endregion[/color]
[COLOR=#0000FF]private[/color] [COLOR=#0000FF]double[/color] DecimalPlaces = 2;
}
}