コード例 #1
0
        public BaseModel Create(byte[] bytes)
        {
            byte[] msg = bytes.Skip(2).ToArray();
            _log.Debug(_helper.AsciiOctets2String(msg));

            As2805 builder = new As2805(msg);

            switch (builder.mti)
            {
            case "0800":     // Network management: SignON request
                return(new SignonRequestModel(builder));

            case "0810":     // Network management: SignON response
                return(new SignonResponseModel(builder));

            case "0820":     // Network management: KeyChange advice request
                return(new KeyChangeRequest(builder));

            case "0830":     // Network management: KeyChange advice response
                return(new KeyChangeResponse(builder));

            case "0210":
                return(new AuthorizationResponseModel().Create(builder));

            case "0430":
                return(new ReversalResponseModel().Create(builder));

            default:
                throw new InvalidOperationException(string.Format("Request message error => mti code not found ({0})", builder.mti));
            }
        }
コード例 #2
0
ファイル: IFactory.cs プロジェクト: AS2805/6.3
        public BaseModel CreateAtmRequest(byte[] bytes)
        {
            try
            {
                string request = _helper.AsciiOctets2String(bytes);
                _log.Debug(request);
                string[] results = _helper.BuildMsgFromAtm(bytes);

                switch (results[2])
                {
                case "11":     // Cash Withdrawal from primary checking account
                case "12":     // Cash Withdrawal from primary savings account
                case "15":     // Cash Withdrawal from primary credit card account
                case "31":     // Primary cheque account balance inquiry
                case "32":     // Primary Savings account balance inquiry
                case "35":     // Primary Credit card balance inquiry
                    return(new TransactionModel().Create(results, request));

                case "60":     // Download configuration table
                    return(new ConfigModel().Create(results, request));

                case "50":     // Get host totals (do not change business day or reset totals)
                case "51":     // Get host totals (Change business date and reset totals)
                    return(new HostTotalModel().Create(results, request));

                case "29":     // Reverse Previous Withdrawal (Reversal Message )
                    return(new ReversalModel().Create(results, request));

                default:
                    throw new InvalidOperationException("Request message error => Transaction code not found");
                }
            }
            catch (Exception)
            {
                throw new FormatException("Invalid ATM Request format");
            }
        }
コード例 #3
0
        public byte[] TranResponse(TransactionModel model)
        {
            _log.Debug("Starting to create transaction response");
            // Example response message
            //<STX>            <FS>0<FS>S9218163       <FS>11<FS>4868<FS>000<FS>00000400<FS>08062015<FS>164607<FS>08062015<FS>00667243<FS>00000100<FS>t164607<FS><FS><FS><ETX>

            string InformationHeader = "            ";
            //string authorizationNum = "00000400";
            string transactionDate = DateTime.Now.ToString("MMddyy"); // Transaction Date  6 Numeric Date of transaction in MMDDYY format. Set by processor.
            string transactionTime = DateTime.Now.ToString("HHmmss"); // Time of the transaction in HHMMSS format. Set by processor.
            string businessDate    = DateTime.Now.ToString("MMddyy"); // Business date of the transaction in MMDDYY format. Set by processor.

            string builder = "";


            builder += InformationHeader;
            builder += "\x1C" + "0"; // Multi-Block Indicator 1 Numeric
            builder += "\x1C" + model.TerminalId;
            builder += "\x1C" + model.TransactionCode;
            builder += "\x1C" + model.AtmSeqNo.ToString("D4");           // Sequence Number  4 Numeric Copied from request message.
            builder += "\x1C" + model.AuthorizationCode.PadLeft(3, '0'); // Response Code  3 Numeric Result of request. Approved = 000. Non-0000 = declined. See Authorization Codes for list of decline codes.
            builder += "\x1C" + model.AuthorizationNum.ToString("D8");   // Authorization Num.  8 Numeric
            //*
            // Authorization number generated by the processor for the transaction. Right justified, zero filled to the left if not 8 characters.
            //(note: This field is alphanumeric for Quasicash type transaction responses, Zero(030h) or space(020h) filled to the left if less than 8 characters.)
            // */
            builder += "\x1C" + transactionDate;
            builder += "\x1C" + transactionTime;
            builder += "\x1C" + businessDate;
            builder += "\x1C" + model.Balance.ToString("D8"); // Amount 1  8 Numeric  // ACCOUNT BALANCE
            //*
            // * Balance amount. Zero filled to the left, right justified.
            // * If space filled, no balance available (for W/D transactions)
            // * Represents the amount in the smallest possible unit of
            // * currency.
            // * Amount to dispense. Use for transaction codes:
            // * "48" – Check Cashing Withdrawal.
            // * “49” – Receive Money.
            // *
            builder += "\x1C" + model.Amount2.ToString("D8"); // Amount 2  8 Numeric // ATM FEE
            //*
            // * Amount of actual surcharge Zero filled to the left, right
            // * justified. Represents the amount in the smallest possible
            // * unit of currency. An ASCII minus sign (e.g. “-0000100”) in
            // * the first position represents a credit.
            // */
            builder += "\x1C" + model.Miscellaneous1; // Miscellaneous 1  Variable Alphanumeric Miscellaneous data. Refer to Miscellaneous Field ID codes for possible uses for this field.
            builder += "\x1C" + model.Miscellaneous2; // Miscellaneous 2  Variable Alphanumeric Miscellaneous data. Refer to Miscellaneous Field ID codes for possible uses for this field.
            builder += "\x1C" + model.MiscellaneousX; // Miscellaneous X**  Variable Alphanumeric  V  X**  Miscellaneous data. Refer to Miscellaneous Field ID codes for possible uses for this field.
            builder += "\x1C";
            builder += "\x03";
            //builder = "\x02" + builder + HexStringToString(CalculateChecksum(builder));
            builder = "\x02" + builder + CalcLRC(builder);

            byte[] result = Build(builder);
            string encode = _helper.AsciiOctets2String(result);

            _log.Debug("Message sent to ATM: " + encode);
            model.Text = encode;
            return(result);
        }