예제 #1
0
        private EzeResult login(LoginMode mode, string userName, string passkey)
        {
            Console.WriteLine("...Login User <" + mode + ":" + userName + ":" + passkey + ">");

            LoginInput loginInput = LoginInput.CreateBuilder()
                                    .SetLoginMode(MapLoginMode(mode))
                                    .SetUsername(userName)
                                    .SetPasskey(passkey).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.LOGIN)
                                .SetMsgData(loginInput.ToByteString()).Build();

            this.send(apiInput);

            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGIN)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == com.eze.ezecli.ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    throw new EzeException("Login failed. " + result.ToString());
                }
                break;
            }
            Console.WriteLine("2......" + result);
            return(result);
        }
예제 #2
0
        private EzeResult logout()
        {
            Console.WriteLine("...logging out");

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.LOGOUT)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGOUT)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    Console.WriteLine("Error logout");
                }
                else
                {
                    Console.WriteLine(" logout success");
                    break;
                }
            }
            return(result);
        }
예제 #3
0
        public EzeResult getTransaction(String txId)
        {
            Console.WriteLine("Fetching transaction details for " + txId);
            TxnDetailsInput txnInput = TxnDetailsInput.CreateBuilder().SetTxnId(txId).Build();
            ApiInput        input    = ApiInput.CreateBuilder().SetMsgType(ApiInput.Types.MessageType.TXN_DETAILS).SetMsgData(txnInput.ToByteString()).Build();

            this.send(input);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TRANSACTION_DETAILS)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Fetching Transaction Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Fetching Transaction Details Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }
예제 #4
0
        private EzeResult exit()
        {
            Console.WriteLine("...exiting");
            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.EXIT)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.EXIT)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    EzeEvent("Initialization succesful", new EventArgs());
                    return(result);;
                }
                break;
            }
            return(result);
        }
예제 #5
0
        /**
         * Method attaches a signature (captured) from the UI to a successfully executed transaction
         */
        public EzeResult attachSignature(string txnId, ImageType imageType, ByteString imageData, int height, int width, double tipAmount)
        {
            Console.Error.WriteLine("...attachSignature <" + txnId + ">");

            SignatureInput signatureInput = SignatureInput.CreateBuilder()
                                            .SetTxnId(txnId)
                                            .SetImageType(MapImageType(imageType))
                                            .SetImageBytes(imageData)
                                            .SetHeight(height)
                                            .SetWidth(width)
                                            .SetTipAmount(tipAmount)
                                            .Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.ATTACH_SIGNATURE)
                                .SetMsgData(signatureInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.ATTACH_SIGNATURE)
                {
                    break;
                }
            }
            return(result);
        }
예제 #6
0
        /*  public EzeResult takePayment(PaymentType type, double amount, PaymentOptions options)
         * {
         *            EzeResult result = null;
         *            Console.WriteLine("...Take Payment <"+type.ToString()+",amount="+amount+","+">");
         *            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CARD_PRE_AUTH;
         *
         *    switch(type)
         *    {
         *            case PaymentType.CARD:
         *        {
         *            txnType = TxnInput.Types.TxnType.CARD_AUTH;
         *                        break;
         *        }
         *                case PaymentType.CASH:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CASH;
         *                        break;
         *        }
         *                case PaymentType.CHEQUE:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CHEQUE;
         *                        break;
         *        }
         *                default:
         *        {
         *                        txnType = TxnInput.Types.TxnType.CARD_PRE_AUTH;
         *            break;
         *        }
         *            }
         *
         *    if (amount <= 0) throw new EzeException("Amount is 0 or negative");
         *            if (txnType == TxnInput.Types.TxnType.CHEQUE)
         *    {
         *                    if ((null == options) ||
         *                            (null == options.getChequeNo()) || (options.getChequeNo().Length == 0) ||
         *                            (null == options.getBankCode()) || (options.getBankCode().Length == 0) ||
         *                            (null == options.getChequeDate()))
         *        {
         *                throw new EzeException("Cheque details not passed for a Cheque transaction");
         *                    }
         *            }
         *
         *            TxnInput tInput = TxnInput.CreateBuilder()
         *
         *                            .SetTxnType(txnType)
         *                            .SetAmount(amount)
         *                            .Build();
         *
         *            if (null != options) {
         *                    if (null != options.getOrderId()) tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getOrderId()).Build();
         *                    if (null != options.getReceiptType()) tInput = TxnInput.CreateBuilder(tInput).SetReceiptType(options.getReceiptType()).Build();
         *                    if (null != options.getChequeNo()) tInput = TxnInput.CreateBuilder(tInput).SetChequeNumber(options.getChequeNo()).Build();
         *                    if (null != options.getBankCode()) tInput = TxnInput.CreateBuilder(tInput).SetBankCode(options.getBankCode()).Build();
         *                    if (null != options.getChequeDate()) tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(options.getChequeDate().ToString()).Build();
         *            }
         *
         *            ApiInput apiInput = ApiInput.CreateBuilder()
         *                            .SetMsgType(ApiInput.Types.MessageType.TXN)
         *                            .SetMsgData(tInput.ToByteString()).Build();
         *
         *            this.send(apiInput);
         *
         *            while (true)
         *    {
         *                    result = this.getResult(this.receive());
         *
         *        if (result.getEventName() == EventName.TAKE_PAYMENT)
         *        {
         *            if (result.getStatus() == Status.SUCCESS) EzeEvent("Payment Successful", new EventArgs());
         *            else EzeEvent("Payment Failed", new EventArgs());
         *            break;
         *        }
         *            }
         *
         *    return result;
         *    } */

        public EzeResult sendReceipt(string txnId, string mobileNo, String email)
        {
            Console.Error.WriteLine("...sendReceipt <" + txnId + ">");

            ForwardReceiptInput receiptInput = ForwardReceiptInput.CreateBuilder()
                                               .SetTxnId(txnId)
                                               .SetCustomerMobile(mobileNo)
                                               .SetCustomerEmail(email).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.FORWARD_RECEIPT)
                                .SetMsgData(receiptInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.SEND_RECEIPT)
                {
                    break;
                }
            }

            return(result);
        }
예제 #7
0
        public EzeResult voidTransaction(String txnId)
        {
            Console.WriteLine("Void....");
            VoidTxnInput voidTaxInput = VoidTxnInput.CreateBuilder().SetTxnId(txnId).Build();
            ApiInput     apiInput     = ApiInput.CreateBuilder().SetMsgType(ApiInput.Types.MessageType.VOID_TXN).SetMsgData(voidTaxInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.VOID_PAYMENT)
                {
                    Console.WriteLine(result);
                    break;
                }
            }
            return(result);
        }
예제 #8
0
        private void setServerType(ServerType type)
        {
            Console.WriteLine("...Setting server type to <" + type.ToString() + ">");

            ServerTypeInput serverTypeInput = ServerTypeInput.CreateBuilder()
                                              .SetServertype(MapServerType(type)).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.SERVER_TYPE)
                                .SetMsgData(serverTypeInput.ToByteString()).Build();

            this.send(apiInput);

            /*
             * EzeResult result = null;
             *
             * while (true)
             * {
             *  result = this.getResult(this.receive());
             *  if (result.getEventName() == EventName.SET_SERVER_TYPE) break;
             * }*/
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>EzeResult - instance </returns>
        public EzeResult prepareDevice()
        {
            Console.WriteLine("...Preparing Device");

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.PREPARE_DEVICE)
                                .Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.PREPARE_DEVICE)
                {
                    break;
                }
            }
            Console.WriteLine("99: " + result);
            return(result);
        }
예제 #10
0
        public EzeResult getTransactionHistory(string startDate, string endDate)
        {
            Console.Error.WriteLine("...Transaction History < >");

            TxnHistoryInput historyInput = TxnHistoryInput.CreateBuilder().SetStrtDate(startDate).SetEndDate(endDate)
                                           .Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN_HISTORY)
                                .SetMsgData(historyInput.ToByteString()).Build();

            this.send(apiInput);
            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() == EventName.HISTORY_RESULT)
                {
                    break;
                }
            }
            return(result);
        }
예제 #11
0
        public EzeResult chequeTransaction(double amount, Cheque cDetails, OptionalParams options)
        {
            EzeResult result = null;

            Console.WriteLine("...Take Payment By Cash <" + ",amount=" + amount + "," + ">");
            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CHEQUE;

            if (amount <= 0)
            {
                throw new EzeException("Amount is 0 or negative");
            }

            TxnInput tInput = TxnInput.CreateBuilder()
                              .SetTxnType(txnType)
                              .SetAmount(amount)
                              .Build();

            if ((null == cDetails) ||
                (null == cDetails.getChequeNumber()) || (cDetails.getChequeNumber().Length == 0) ||
                (null == cDetails.getChequeDate()) || (cDetails.getChequeDate().Length == 0) ||
                (null == cDetails.getBankName()))
            {
                throw new EzeException("Cheque details not passed for a Cheque transaction");
            }

            if (null != cDetails.getChequeNumber())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetChequeNumber(cDetails.getChequeNumber()).Build();
            }
            if (null != cDetails.getChequeDate())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(cDetails.getChequeDate()).Build();
            }
            if (null != cDetails.getBankCode())
            {
                tInput = TxnInput.CreateBuilder(tInput).SetBankCode(cDetails.getBankCode()).Build();
            }
            //  if (null != cDetails.getBankName()) tInput = TxnInput.CreateBuilder(tInput).SetBankName(cDetails.getBankName()).Build();
            //  if (null != options.getChequeDate()) tInput = TxnInput.CreateBuilder(tInput).SetChequeDate(options.getChequeDate().ToString()).Build();


            if (null != options)
            {
                if (null != options.getReference())
                {
                    if (null != options.getReference().getReference1())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getReference().getReference1()).Build();
                    }
                    if (null != options.getReference().getReference2())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference2(options.getReference().getReference2()).Build();
                    }
                    if (null != options.getReference().getReference3())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference3(options.getReference().getReference3()).Build();
                    }
                }

                if (null != options.getCustomer())
                {
                    String mobileNumber = options.getCustomer().getMobileNumber();
                    String emailId      = options.getCustomer().getEmailId();
                    if (null != mobileNumber)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerMobile(mobileNumber).Build();
                    }
                    if (null != emailId)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerEmail(emailId).Build();
                    }
                }
            }

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN)
                                .SetMsgData(tInput.ToByteString()).Build();

            this.send(apiInput);

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TAKE_PAYMENT)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Payment Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Payment Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }
예제 #12
0
        public EzeResult cardTransaction(double amount, PaymentMode mode, OptionalParams options)
        {
            EzeResult result = null;

            Console.WriteLine("...Take Payment <" + mode + ",amount=" + amount + "," + ">");
            TxnInput.Types.TxnType txnType = TxnInput.Types.TxnType.CARD_AUTH;

            if (amount <= 0)
            {
                throw new EzeException("Amount is 0 or negative");
            }

            TxnInput tInput = TxnInput.CreateBuilder()
                              .SetTxnType(txnType)
                              .SetAmount(amount)
                              .Build();

            if (null != options)
            {
                if (null != options.getReference())
                {
                    if (null != options.getReference().getReference1())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetOrderId(options.getReference().getReference1()).Build();
                    }
                    if (null != options.getReference().getReference2())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference2(options.getReference().getReference2()).Build();
                    }
                    if (null != options.getReference().getReference3())
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetExternalReference3(options.getReference().getReference3()).Build();
                    }
                }
                if (0 != options.getAmountCashback())
                {
                    tInput = TxnInput.CreateBuilder(tInput).SetAmountOther(options.getAmountCashback()).Build();
                }
                //  if (0 != options.getAamountTip()) tInput = TxnInput.CreateBuilder(tInput).Set(options.getBankCode()).Build();
                if (null != options.getCustomer())
                {
                    String mobileNumber = options.getCustomer().getMobileNumber();
                    String emailId      = options.getCustomer().getEmailId();
                    if (null != mobileNumber)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerMobile(mobileNumber).Build();
                    }
                    if (null != emailId)
                    {
                        tInput = TxnInput.CreateBuilder(tInput).SetCustomerEmail(emailId).Build();
                    }
                }
            }

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.TXN)
                                .SetMsgData(tInput.ToByteString()).Build();

            this.send(apiInput);

            while (true)
            {
                result = this.getResult(this.receive());

                if (result.getEventName() == EventName.TAKE_PAYMENT)
                {
                    if (result.getStatus() == Status.SUCCESS)
                    {
                        EzeEvent("Payment Successful", new EventArgs());
                    }
                    else
                    {
                        EzeEvent("Payment Failed", new EventArgs());
                    }
                    break;
                }
            }

            return(result);
        }