Пример #1
0
        private EzeResult getResult(ApiOutput apiOutput)
        {
            EzeResult result = new EzeResult();

            if (null == apiOutput) throw new EzeException("Invalid response from EPIC. ApiOutput is null");

            result.setEventName(MapEventName(apiOutput.EventType));
            if (apiOutput.HasStatus) result.setStatus(MapStatus(apiOutput.Status));
            if (apiOutput.HasMsgText) result.setMessage(apiOutput.MsgText);

            if (apiOutput.HasOutData)
            {
            try
            {
                StatusInfo statusInfo = StatusInfo.ParseFrom(apiOutput.OutData);

                if (null != statusInfo)
                {
                    if (statusInfo.HasCode) result.setCode(statusInfo.Code);
                    if (statusInfo.HasMessage) result.setMessage(statusInfo.Message);
                }
            }
            catch (InvalidProtocolBufferException e)
            {
                Console.WriteLine(e.Message);
            }

            if ((apiOutput.Status == ApiOutput.Types.ResultStatus.SUCCESS) && (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_RESULT)))
            {
                PaymentResult paymentResult = new PaymentResult();
                Txn txnOutput;
                try
                {
                    txnOutput = Txn.ParseFrom(apiOutput.OutData);

                    paymentResult.setPmtType(txnOutput.TxnType.ToString());
                    paymentResult.setStatus(txnOutput.Status);
                    paymentResult.setTxnId(txnOutput.TransactionId);
                    paymentResult.setAmount(txnOutput.Amount);
                    paymentResult.setSettlementStatus(txnOutput.SettlementStatus);
                    paymentResult.setVoidable(txnOutput.Voidable);
                    paymentResult.setChequeNo(txnOutput.ChequeNumber);
                    paymentResult.setChequeDate(txnOutput.ChequeDate);
                    paymentResult.setAuthCode(txnOutput.AuthCode);
                    paymentResult.setCardType(txnOutput.CardBrand);
                    paymentResult.setOrderId(txnOutput.OrderId);
                    paymentResult.setTid(txnOutput.Tid);
                    paymentResult.setMerchantId(txnOutput.Mid);

                }
                catch (InvalidProtocolBufferException e)
                {
                    throw new EzeException("Error reading payment result. ex=" + e.Message);
                }
                result.setPaymentResult(paymentResult);
            }
            }

            //Console.Write("ApiOutput: " + apiOutput.ToString());

            if ((result.getEventName() == EventName.NOTIFICATION) && (null != EzeEvent))
            {
            EzeEvent(result.getMessage(), new EventArgs());
            }

            return result;
        }