Example #1
0
        private EzeResult getResult(ApiOutput apiOutput)
        {
            EzeResult result = new EzeResult();
            Result paymentResult = new Result();
            paymentResult.setMessage("Ezeeeeeeeeeeeeeeeee");
            if (null == apiOutput) throw new EzeException("Invalid response from EPIC. ApiOutput is null");
            Console.WriteLine("1.."+apiOutput.EventType);

            Console.WriteLine("2. "+ MapEventName(apiOutput.EventType));
            result.setEventName(MapEventName(apiOutput.EventType));
            if (apiOutput.HasStatus) result.setStatus(MapStatus(apiOutput.Status));
            if (apiOutput.HasMsgText)
            {

                paymentResult.setMessage(apiOutput.MsgText);
                result.setResult(paymentResult);
            }
            Console.WriteLine("3.."+apiOutput.MsgText);
            Console.WriteLine("4.." + result);
            if (apiOutput.HasOutData)
            {
                 try
                 {
                     StatusInfo statusInfo = StatusInfo.ParseFrom(apiOutput.OutData);
                     if (apiOutput.HasStatus)
                     {

                         if (result.getStatus() == Status.FAILURE)
                         {
                             Console.WriteLine("Failure");
                             if (null != statusInfo)
                             {
                                 Error error = new Error();
                             error.setCode(statusInfo.Code);
                             error.setMessage(statusInfo.Message);
                             result.setError(error);
                             }
                         }

                     }

                 }
                 catch (InvalidProtocolBufferException e)
                 {
                     Console.WriteLine(e.Message);
                 }

                if ((apiOutput.Status == ApiOutput.Types.ResultStatus.SUCCESS) && (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_HISTORY_RESULT)))
                {
                    try
                    {
                        Console.WriteLine("history parsing begins... ");
                        TxnHistory txHistory = TxnHistory.ParseFrom(apiOutput.OutData);
                        Console.WriteLine("Null history "+txHistory);

                        if (null != txHistory)
                        {

                            Console.WriteLine(txHistory.TotalCount);
                          //  IList<Txn> list = txHistory.

                        }
                        else
                        {
                            Console.WriteLine("Null histpry");
                        }
                    }
                    catch (InvalidProtocolBufferException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                if ((apiOutput.Status == ApiOutput.Types.ResultStatus.SUCCESS) && (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_RESULT) || (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_DETAILS_RESULT))))
                {

                    TransactionDetails tDetails = new TransactionDetails();
                    Card card = new Card();
                    Merchant merchant = new Merchant();
                    Customer cust = new Customer();
                    Receipt receipt = new Receipt();
                    Cheque cheque = new Cheque();
                    Txn txnOutput;
                    try
                    {
                        txnOutput = Txn.ParseFrom(apiOutput.OutData);
                        tDetails.setPmtType(txnOutput.TxnType.ToString());
                        tDetails.setStatus(txnOutput.Status);
                        tDetails.setTxnId(txnOutput.TransactionId);
                        tDetails.setAmount(txnOutput.Amount);
                        tDetails.setSettlementStatus(txnOutput.SettlementStatus);
                        tDetails.setVoidable(txnOutput.Voidable);
                        tDetails.setAuthCode(txnOutput.AuthCode);
                        tDetails.setCardType(txnOutput.CardBrand);
                        tDetails.setOrderId(txnOutput.OrderId);
                        tDetails.setTid(txnOutput.Tid);
                        paymentResult.setTransactionDetails(tDetails);
                       merchant.setMerchantCode(txnOutput.Mid);
                        // merchant.setMerchantName(txnOutput.m);
                        paymentResult.setMerchant(merchant);
                        cust.setMobileNumber(txnOutput.CustomerMobileNumber);
                        // cust.setemailId(txnOutput.);
                        paymentResult.setCustomer(cust);
                        receipt.setReceiptUrl(txnOutput.ReceiptUrl);
                        receipt.setReceiptDate(txnOutput.Timestamp);
                        paymentResult.setReceipt(receipt);
                        cheque.setChequeNumber(txnOutput.ChequeNumber);
                        cheque.setChequeDate(txnOutput.ChequeDate);
                        cheque.setBankCode(txnOutput.BankCode);
                        // cheque.setBankName(txnOutput.b);
                        paymentResult.setCheque(cheque);
                        card.setCardBrand(txnOutput.CardBrand);
                        //  card.setMaskedCardNumber(txnOutput.LastFoundDigits);
                        paymentResult.setCard(card);
                    }
                    catch (InvalidProtocolBufferException e)
                    {
                        throw new EzeException("Error reading payment result. ex=" + e.Message);
                    }
                   // PaymentResult list = new List<PaymentResult>();
                    result.setResult(paymentResult);
                }
            }

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

            if ((result.getEventName() == EventName.NOTIFICATION) && (null != EzeEvent))
            {
                Result res = result.getResult();
                Console.WriteLine("5.."+res);
                if (res!=null)
                EzeEvent(result.getResult().getMessage(), new EventArgs());
            }

            return result;
        }
Example #2
0
 public void setReceipt(Receipt receipt)
 {
     this.receipt = receipt;
 }
Example #3
0
 public void setReceipt(Receipt receipt)
 {
     this.receipt = receipt;
 }
Example #4
0
        private EzeResult getResult(ApiOutput apiOutput)
        {
            EzeResult result        = new EzeResult();
            Result    paymentResult = new Result();

            paymentResult.setMessage("Ezeeeeeeeeeeeeeeeee");
            if (null == apiOutput)
            {
                throw new EzeException("Invalid response from EPIC. ApiOutput is null");
            }
            Console.WriteLine("1.." + apiOutput.EventType);

            Console.WriteLine("2. " + MapEventName(apiOutput.EventType));
            result.setEventName(MapEventName(apiOutput.EventType));
            if (apiOutput.HasStatus)
            {
                result.setStatus(MapStatus(apiOutput.Status));
            }
            if (apiOutput.HasMsgText)
            {
                paymentResult.setMessage(apiOutput.MsgText);
                result.setResult(paymentResult);
            }
            Console.WriteLine("3.." + apiOutput.MsgText);
            Console.WriteLine("4.." + result);
            if (apiOutput.HasOutData)
            {
                try
                {
                    StatusInfo statusInfo = StatusInfo.ParseFrom(apiOutput.OutData);
                    if (apiOutput.HasStatus)
                    {
                        if (result.getStatus() == Status.FAILURE)
                        {
                            Console.WriteLine("Failure");
                            if (null != statusInfo)
                            {
                                Error error = new Error();
                                error.setCode(statusInfo.Code);
                                error.setMessage(statusInfo.Message);
                                result.setError(error);
                            }
                        }
                    }
                }
                catch (InvalidProtocolBufferException e)
                {
                    Console.WriteLine(e.Message);
                }

                if ((apiOutput.Status == ApiOutput.Types.ResultStatus.SUCCESS) && (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_HISTORY_RESULT)))
                {
                    try
                    {
                        Console.WriteLine("history parsing begins... ");
                        TxnHistory txHistory = TxnHistory.ParseFrom(apiOutput.OutData);
                        Console.WriteLine("Null history " + txHistory);

                        if (null != txHistory)
                        {
                            Console.WriteLine(txHistory.TotalCount);
                            //  IList<Txn> list = txHistory.
                        }
                        else
                        {
                            Console.WriteLine("Null histpry");
                        }
                    }
                    catch (InvalidProtocolBufferException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                if ((apiOutput.Status == ApiOutput.Types.ResultStatus.SUCCESS) && (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_RESULT) || (apiOutput.EventType.Equals(ApiOutput.Types.EventType.TXN_DETAILS_RESULT))))
                {
                    TransactionDetails tDetails = new TransactionDetails();
                    Card     card     = new Card();
                    Merchant merchant = new Merchant();
                    Customer cust     = new Customer();
                    Receipt  receipt  = new Receipt();
                    Cheque   cheque   = new Cheque();
                    Txn      txnOutput;
                    try
                    {
                        txnOutput = Txn.ParseFrom(apiOutput.OutData);
                        tDetails.setPmtType(txnOutput.TxnType.ToString());
                        tDetails.setStatus(txnOutput.Status);
                        tDetails.setTxnId(txnOutput.TransactionId);
                        tDetails.setAmount(txnOutput.Amount);
                        tDetails.setSettlementStatus(txnOutput.SettlementStatus);
                        tDetails.setVoidable(txnOutput.Voidable);
                        tDetails.setAuthCode(txnOutput.AuthCode);
                        tDetails.setCardType(txnOutput.CardBrand);
                        tDetails.setOrderId(txnOutput.OrderId);
                        tDetails.setTid(txnOutput.Tid);
                        paymentResult.setTransactionDetails(tDetails);
                        merchant.setMerchantCode(txnOutput.Mid);
                        // merchant.setMerchantName(txnOutput.m);
                        paymentResult.setMerchant(merchant);
                        cust.setMobileNumber(txnOutput.CustomerMobileNumber);
                        // cust.setemailId(txnOutput.);
                        paymentResult.setCustomer(cust);
                        receipt.setReceiptUrl(txnOutput.ReceiptUrl);
                        receipt.setReceiptDate(txnOutput.Timestamp);
                        paymentResult.setReceipt(receipt);
                        cheque.setChequeNumber(txnOutput.ChequeNumber);
                        cheque.setChequeDate(txnOutput.ChequeDate);
                        cheque.setBankCode(txnOutput.BankCode);
                        // cheque.setBankName(txnOutput.b);
                        paymentResult.setCheque(cheque);
                        card.setCardBrand(txnOutput.CardBrand);
                        //  card.setMaskedCardNumber(txnOutput.LastFoundDigits);
                        paymentResult.setCard(card);
                    }
                    catch (InvalidProtocolBufferException e)
                    {
                        throw new EzeException("Error reading payment result. ex=" + e.Message);
                    }
                    // PaymentResult list = new List<PaymentResult>();
                    result.setResult(paymentResult);
                }
            }

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

            if ((result.getEventName() == EventName.NOTIFICATION) && (null != EzeEvent))
            {
                Result res = result.getResult();
                Console.WriteLine("5.." + res);
                if (res != null)
                {
                    EzeEvent(result.getResult().getMessage(), new EventArgs());
                }
            }

            return(result);
        }