コード例 #1
0
        public void Cancel()
        {
            PgDebugLog.WriteLocal("Start Cancel");
            var error = Native.Cancel(nativeMpos);

            PgDebugLog.WriteLocal($"Called Cancel: result code [{error}]");
        }
コード例 #2
0
        public void Display(string text)
        {
            PgDebugLog.WriteLocal("Start Display");
            var error = Native.Display(nativeMpos, text);

            PgDebugLog.WriteLocal($"Called Display: result code [{error}]");

            if (error != Error.Ok)
            {
                throw new MposException(error);
            }
        }
コード例 #3
0
        public Task Close()
        {
            var source   = new TaskCompletionSource <bool>();
            var callback = MposClosedCallback.Callback(this, source);

            PgDebugLog.WriteLocal("Start Close");
            var error = Native.Close(nativeMpos, "", callback);

            PgDebugLog.WriteLocal($"Called Close: result code [{error}]");

            if (error != Error.Ok)
            {
                throw new MposException(error);
            }

            return(source.Task);
        }
コード例 #4
0
        public Task FinishTransaction(bool success, int responseCode, string emvData)
        {
            var source = new TaskCompletionSource <bool>();

            TransactionStatus status;
            int length;

            if (!success)
            {
                status       = TransactionStatus.Error;
                emvData      = "";
                length       = 0;
                responseCode = 0;
            }
            else
            {
                length = emvData == null ? 0 : emvData.Length;

                if (responseCode < 1000)
                {
                    status = responseCode == 0 ? TransactionStatus.Ok : TransactionStatus.NonZero;
                }
                else
                {
                    status = TransactionStatus.Error;
                }
            }

            var callback = MposFinishTransactionCallback.Callback(this, source);

            PgDebugLog.WriteLocal("Start FinishTransaction");
            var error = Native.FinishTransaction(nativeMpos, status, responseCode, emvData, length, callback);

            PgDebugLog.WriteLocal($"Called FinishTransaction: result code [{error}]");

            if (error != Error.Ok)
            {
                throw new MposException(error);
            }

            return(source.Task);
        }