예제 #1
0
        public void CashoutOnlyResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            const string jsonStr = @"{""message"": {""data"":{""account_type"":""SAVINGS"",""auth_code"":""265035"",""bank_cash_amount"":1200,""bank_date"":""17062018"",""bank_settlement_date"":""18062018"",""bank_time"":""170950"",""card_entry"":""EMV_INSERT"",""cash_amount"":1200,""currency"":""AUD"",""customer_receipt"":""EFTPOS FROM WESTPAC\\r\\nMerchant4\\r\\n213 Miller Street\\r\\nSydney 2060\\r\\nAustralia\\r\\n\\r\\nTIME 17JUN18   17:09\\r\\nMID         22341845\\r\\nTSP     100312348845\\r\\nRRN     180617000151\\r\\nDebit(I)         SAV\\r\\nCARD............2797\\r\\nAUTH          265035\\r\\n\\r\\nCASH        AUD10.00\\r\\nSURCHARGE    AUD2.00\\r\\nTOTAL       AUD12.00\\r\\n\\r\\n   (000) APPROVED\\r\\n\\r\\n  *CUSTOMER COPY*\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n"",""customer_receipt_printed"":true,""expiry_date"":""0722"",""host_response_code"":""000"",""host_response_text"":""APPROVED"",""informative_text"":""                "",""masked_pan"":""............2797"",""merchant_acquirer"":""EFTPOS FROM WESTPAC"",""merchant_addr"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_id"":""22341845"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM WESTPAC\\r\\nMerchant4\\r\\n213 Miller Street\\r\\nSydney 2060\\r\\nAustralia\\r\\n\\r\\nTIME 17JUN18   17:09\\r\\nMID         22341845\\r\\nTSP     100312348845\\r\\nRRN     180617000151\\r\\nDebit(I)         SAV\\r\\nCARD............2797\\r\\nAUTH          265035\\r\\n\\r\\nCASH        AUD10.00\\r\\nSURCHARGE    AUD2.00\\r\\nTOTAL       AUD12.00\\r\\n\\r\\n   (000) APPROVED\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n"",""merchant_receipt_printed"":true,""online_indicator"":""Y"",""pos_ref_id"":""launder-18-06-2018-03-09-17"",""rrn"":""180617000151"",""scheme_name"":""Debit"",""stan"":""000151"",""success"":true,""surcharge_amount"":200,""terminal_id"":""100312348845"",""terminal_ref_id"":""12348845_18062018031010"",""transaction_type"":""CASH""},""datetime"":""2018-06-18T03:10:10.580"",""event"":""cash_response"",""id"":""cshout4""}}";
            var          msg     = Message.FromJson(jsonStr, null); // todo: any method in arrange should be unit tested

            // act
            var response = new CashoutOnlyResponse(msg);

            // assert
            Assert.True(response.Success);
            Assert.Equal("cshout4", response.RequestId);
            Assert.Equal("launder-18-06-2018-03-09-17", response.PosRefId);
            Assert.Equal("Debit", response.SchemeName);
            Assert.Equal("180617000151", response.GetRRN());
            Assert.Equal(1200, response.GetCashoutAmount());
            Assert.Equal(0, response.GetBankNonCashAmount());
            Assert.Equal(1200, response.GetBankCashAmount());
            Assert.Equal(200, response.GetSurchargeAmount());
            Assert.NotNull(response.GetCustomerReceipt());
            Assert.Equal("APPROVED", response.GetResponseText());
            Assert.Equal("000", response.GetResponseCode());
            Assert.Equal("12348845_18062018031010", response.GetTerminalReferenceId());
            Assert.Equal("SAVINGS", response.GetAccountType());
            Assert.Equal("17062018", response.GetBankDate());
            Assert.NotNull(response.GetMerchantReceipt());
            Assert.Equal("170950", response.GetBankTime());
            Assert.Equal("............2797", response.GetMaskedPan());
            Assert.Equal("100312348845", response.GetTerminalId());
            Assert.Equal("265035", response.GetAuthCode());
            Assert.True(response.WasCustomerReceiptPrinted());
            Assert.True(response.WasMerchantReceiptPrinted());
        }
예제 #2
0
        private void HandleFinishedCashout(TransactionFlowState txState)
        {
            CashoutOnlyResponse cashoutResponse;

            switch (txState.Success)
            {
            case Message.SuccessState.Success:
                Console.WriteLine($"# CASH-OUT SUCCESSFUL - HAND THEM THE CASH!");
                cashoutResponse = new CashoutOnlyResponse(txState.Response);
                Console.WriteLine("# Response: {0}", cashoutResponse.GetResponseText());
                Console.WriteLine("# RRN: {0}", cashoutResponse.GetRRN());
                Console.WriteLine("# Scheme: {0}", cashoutResponse.SchemeName);
                Console.WriteLine("# Customer Receipt:");
                Console.WriteLine(!cashoutResponse.WasCustomerReceiptPrinted() ? cashoutResponse.GetCustomerReceipt().TrimEnd() : "# PRINTED FROM EFTPOS");
                Console.WriteLine("# CASHOUT: {0}", cashoutResponse.GetCashoutAmount());
                Console.WriteLine("# BANKED NON-CASH AMOUNT: {0}", cashoutResponse.GetBankNonCashAmount());
                Console.WriteLine("# BANKED CASH AMOUNT: {0}", cashoutResponse.GetBankCashAmount());
                break;

            case Message.SuccessState.Failed:
                Console.WriteLine($"# CASHOUT FAILED!");
                if (txState.Response != null)
                {
                    cashoutResponse = new CashoutOnlyResponse(txState.Response);
                    Console.WriteLine("# Error: {0}", txState.Response.GetError());
                    Console.WriteLine("# Error Detail: {0}", txState.Response.GetErrorDetail());
                    Console.WriteLine("# Response: {0}", cashoutResponse.GetResponseText());
                    Console.WriteLine("# RRN: {0}", cashoutResponse.GetRRN());
                    Console.WriteLine("# Scheme: {0}", cashoutResponse.SchemeName);
                    Console.WriteLine("# Customer Receipt:");
                    Console.WriteLine(cashoutResponse.GetCustomerReceipt().TrimEnd());
                }
                break;

            case Message.SuccessState.Unknown:
                Console.WriteLine($"# WE'RE NOT QUITE SURE WHETHER THE CASHOUT WENT THROUGH OR NOT :/");
                Console.WriteLine($"# CHECK THE LAST TRANSACTION ON THE EFTPOS ITSELF FROM THE APPROPRIATE MENU ITEM.");
                Console.WriteLine($"# YOU CAN THE TAKE THE APPROPRIATE ACTION.");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }