Пример #1
0
 private void SendAbortIfPending()
 {
     if (IsAbortPending(true, false))
     {
         posi.PostCancelTransaction();
         isTransactionPending(true, false);
     }
 }
Пример #2
0
        public SENDSALE sendSale(double ammount)
        {
            isTransactionPending(true, false);

            IsAbortPending(true, false);
            var test  = isTransactionPending(false, false);
            var test1 = IsAbortPending(false, false);

            try
            {
                var config         = getConfigProperties();
                var jobj           = JObject.Parse(config);
                var merchantId     = jobj.SelectToken("MerchantId").ToString();
                var ip             = jobj.SelectToken("IP").ToString();
                var terminalNumber = jobj.SelectToken("TerminalNumber").ToString();

                posi = new WinPOSPoint();
                SENDSALE data = new SENDSALE();

                data.ammount = ammount;
                posi.ClearData();
                posi.TransactionType               = 0;
                posi.MerchantID                    = merchantId;
                posi.TerminalNumber                = int.Parse(terminalNumber);
                posi.Amount                        = ammount * 100.0;
                posi.ClientApplicationName         = "restservice";
                posi.ClientApplicationVersion      = "3.0";
                posi.ServerHostName                = ip;
                posi.ServerPortNumber              = short.Parse("10676");
                posi.EcrCardTransactionReferenceNr = String.Format("{0:00}", DateTime.Now.Hour)
                                                     + String.Format("{0:00}", DateTime.Now.Minute)
                                                     + String.Format("{0:00}", DateTime.Now.Second);
                posi.ConfirmWaitTimeout = 5;
                posi.ProcessTransaction();
                while (true)
                {
                    if (!isTransactionPending(false, false))
                    {
                        isTransactionPending(true, true);
                    }

                    if (IsAbortPending(false, false))
                    {
                        posi.PostCancelTransaction();
                        if (!IsAbortPending(false, false))
                        {
                            IsAbortPending(true, false);
                        }
                    }

                    if (posi.PollProcess() != -1)
                    {
                        isTransactionPending(true, false);
                        break;
                    }
                }

                if (posi.ResponseCode == "0")
                {
                    if (posi.MustConfirmTransaction != 0)
                    {
                        isTransactionPending(true, false);
                        IsAbortPending(true, false);
                        ConfirmTransaction();
                    }

                    data.transactionNumber = posi.TransactionNumber.ToString();
                    data.status            = "success";
                    log("Operation status: " + data.status + " - Transaction Number: " + data.transactionNumber + " - Amount: " + data.ammount + " Timestamp " + DateTime.Now.ToString());
                    isTransactionPending(true, false);
                    IsAbortPending(true, false);
                    return(data);
                }
                else
                {
                    isTransactionPending(true, false);
                    IsAbortPending(true, false);
                    data.status = "failed";
                    log("Operation status: " + data.status + " - Amount: " + data.ammount + " Timestamp " + DateTime.Now.ToString());
                    return(data);
                }
            }
            catch (Exception ex)
            {
                isTransactionPending(true, false);
                IsAbortPending(true, false);
                posi.PostCancelTransaction();
                log(ex.ToString());
                return(null);
            }
        }