public void GetSchemeSettlementEntries_OnValidResponse_ReturnCount()
        {
            // arrange
            var          stlEnqMsg            = new SettlementEnquiryRequest(RequestIdHelper.Id("stlenq")).ToMessage();
            var          transactionFlowState = new TransactionFlowState("1", TransactionType.SettlementEnquiry, 0, stlEnqMsg, $"Waiting for EFTPOS connection to make a settlement enquiry");
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""accumulacxted_purchase_count"":""1"",""accumulated_purchase_value"":""1000"",""accumulated_settle_by_acquirer_count"":""1"",""accumulated_settle_by_acquirer_value"":""1000"",""accumulated_total_count"":""1"",""accumulated_total_value"":""1000"",""bank_date"":""14062019"",""bank_time"":""160940"",""host_response_code"":""941"",""host_response_text"":""CUTOVER COMPLETE"",""merchant_acquirer"":""EFTPOS FROM BANK SA"",""merchant_address"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\n\r\nAustralia\r\n\r\n\r\n SETTLEMENT CUTOVER\r\nTSP     100612348842\r\nTIME   14JUN19 16:09\r\nTRAN   001137-001137\r\nFROM   13JUN19 20:00\r\nTO     14JUN19 16:09\r\n\r\nDebit\r\nTOT     0      $0.00\r\n\r\nMasterCard\r\nTOT     0      $0.00\r\n\r\nVisa\r\nPUR     1     $10.00\r\nTOT     1     $10.00\r\n\r\nBANKED  1     $10.00\r\n\r\nAmex\r\nTOT     0      $0.00\r\n\r\nDiners\r\nTOT     0      $0.00\r\n\r\nJCB\r\nTOT     0      $0.00\r\n\r\nUnionPay\r\nTOT     0      $0.00\r\n\r\nTOTAL\r\nPUR     1     $10.00\r\nTOT     1     $10.00\r\n\r\n (941) CUTOVER COMP\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""schemes"":[{""scheme_name"":""Debit"",""settle_by_acquirer"":""Yes"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""MasterCard"",""settle_by_acquirer"":""Yes"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""Visa"",""settle_by_acquirer"":""Yes"",""total_count"":""1"",""total_purchase_count"":""1"",""total_purchase_value"":""1000"",""total_value"":""1000""},{""scheme_name"":""Amex"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""Diners"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""JCB"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""UnionPay"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""}],""settlement_period_end_date"":""14Jun19"",""settlement_period_end_time"":""16:09"",""settlement_period_start_date"":""13Jun19"",""settlement_period_start_time"":""20:00"",""settlement_triggered_date"":""14Jun19"",""settlement_triggered_time"":""16:09:40"",""stan"":""000000"",""success"":true,""terminal_id"":""100612348842"",""transaction_range"":""001137-001137""},""datetime"":""2019-06-14T16:09:46.395"",""event"":""settle_response"",""id"":""settle116""}}";

            // act
            var msg = Message.FromJson(jsonStr, secrets);

            transactionFlowState.Response = msg;
            var comWrapper     = new ComWrapper();
            var schemeArray    = comWrapper.GetSchemeSettlementEntries(transactionFlowState);
            var settleResponse = new Settlement(transactionFlowState.Response);
            var schemes        = settleResponse.GetSchemeSettlementEntries();
            var schemeList     = new List <SchemeSettlementEntry>();

            foreach (var s in schemes)
            {
                schemeList.Add(s);
            }

            // assert
            Assert.Equal(schemeArray.ToList().Count, schemeList.Count);
        }
예제 #2
0
        public void CancelTransactionResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"": {""event"": ""cancel_response"", ""id"": ""0"", ""datetime"": ""2018-02-06T15:16:44.094"", ""data"": {""pos_ref_id"": ""123456abc"", ""success"": false, ""error_reason"": ""TXN_PAST_POINT_OF_NO_RETURN"", ""error_detail"":""Txn has passed the point of no return"" }}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new CancelTransactionResponse(msg);

            // assert
            Assert.Equal("cancel_response", msg.EventName);
            Assert.False(response.Success);
            Assert.Equal("123456abc", response.PosRefId);
            Assert.Equal("TXN_PAST_POINT_OF_NO_RETURN", response.GetErrorReason());
            Assert.True(response.WasTxnPastPointOfNoReturn());
            Assert.NotNull(response.GetErrorDetail());
            Assert.Equal(response.GetResponseValueWithAttribute("pos_ref_id"), response.PosRefId);

            // act
            response = new CancelTransactionResponse();

            // assert
            Assert.Null(SpiClientTestUtils.GetInstanceField(response.GetType(), response, "_m"));
            Assert.Null(response.PosRefId);
        }
        public void AccountVerifyResponseInit_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""account_type"":""CREDIT"",""auth_code"":""316810"",""bank_date"":""11062019"",""bank_settlement_date"":""11062019"",""bank_time"":""182739"",""card_entry"":""EMV_INSERT"",""currency"":""AUD"",""customer_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\nAustralia\r\n\r\nTIME 11JUN19   18:27\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190611001109\r\nVisa Credit     \r\nVisa(I)           CR\r\nCARD............3952\r\nAID   A0000000031010\r\nTVR       0080048000\r\nAUTH          316810\r\n\r\nA/C VERIFIED AUD0.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"",""customer_receipt_printed"":false,""emv_actioncode"":""TC"",""emv_actioncode_values"":""F1F17B37A5BEF2B1"",""emv_pix"":""1010"",""emv_rid"":""A000000003"",""emv_tsi"":""F800"",""emv_tvr"":""0080048000"",""expiry_date"":""1122"",""host_response_code"":""000"",""host_response_text"":""APPROVED"",""informative_text"":""                "",""masked_pan"":""............3952"",""merchant_acquirer"":""EFTPOS FROM BANK SA"",""merchant_addr"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_id"":""22341842"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\nAustralia\r\n\r\nTIME 11JUN19   18:27\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190611001109\r\nVisa Credit     \r\nVisa(I)           CR\r\nCARD............3952\r\nAID   A0000000031010\r\nTVR       0080048000\r\nAUTH          316810\r\n\r\nA/C VERIFIED AUD0.00\r\n\r\n   (000) APPROVED\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""merchant_receipt_printed"":false,""online_indicator"":""Y"",""pos_ref_id"":""actvfy-11-06-2019-18-27-39"",""rrn"":""190611001109"",""scheme_app_name"":""Visa Credit"",""scheme_name"":""Visa"",""stan"":""001109"",""success"":true,""terminal_id"":""100612348842"",""terminal_ref_id"":""12348842_11062019182754"",""transaction_type"":""A/C VERIFIED""},""datetime"":""2019-06-11T18:27:54.933"",""event"":""account_verify_response"",""id"":""prav15""}}";

            // act
            var msg        = Message.FromJson(jsonStr, secrets);
            var comWrapper = new ComWrapper();
            var response   = comWrapper.AccountVerifyResponseInit(msg);

            // assert
            Assert.Equal("account_verify_response", msg.EventName);
            Assert.Equal("actvfy-11-06-2019-18-27-39", response.PosRefId);
            Assert.True(response.Details.Success);
            Assert.Equal("prav15", response.Details.RequestId);
            Assert.Equal("Visa", response.Details.SchemeName);
            Assert.Equal("190611001109", response.Details.GetRRN());
            Assert.NotNull(response.Details.GetCustomerReceipt());
            Assert.NotNull(response.Details.GetMerchantReceipt());
            Assert.Equal("APPROVED", response.Details.GetResponseText());
            Assert.Equal("000", response.Details.GetResponseCode());
            Assert.Equal("EMV_INSERT", response.Details.GetCardEntry());
            Assert.Equal("CREDIT", response.Details.GetAccountType());
            Assert.Equal("316810", response.Details.GetAuthCode());
            Assert.Equal("11062019", response.Details.GetBankDate());
            Assert.Equal("182739", response.Details.GetBankTime());
            Assert.Equal("............3952", response.Details.GetMaskedPan());
            Assert.Equal("100612348842", response.Details.GetTerminalId());
            Assert.False(response.Details.WasCustomerReceiptPrinted());
            Assert.False(response.Details.WasMerchantReceiptPrinted());
            Assert.Equal(DateTime.ParseExact(msg.GetDataStringValue("bank_settlement_date"), "ddMMyyyy", CultureInfo.InvariantCulture).Date, response.Details.GetSettlementDate());
        }
예제 #4
0
        public void BillPaymentFlowEndedResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""bill_id"":""1554246591041.23"",""bill_outstanding_amount"":1000,""bill_total_amount"":1000,""card_total_amount"":0,""card_total_count"":0,""cash_total_amount"":0,""cash_total_count"":0,""operator_id"":""1"",""table_id"":""1""},""datetime"":""2019-04-03T10:11:21.328"",""event"":""bill_payment_flow_ended"",""id"":""C12.4""}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new BillPaymentFlowEndedResponse(msg);

            // assert
            Assert.Equal("bill_payment_flow_ended", msg.EventName);
            Assert.Equal("1554246591041.23", response.BillId);
            Assert.Equal(1000, response.BillOutstandingAmount);
            Assert.Equal(1000, response.BillTotalAmount);
            Assert.Equal("1", response.TableId);
            Assert.Equal("1", response.OperatorId);
            Assert.Equal(0, response.CardTotalCount);
            Assert.Equal(0, response.CardTotalAmount);
            Assert.Equal(0, response.CashTotalCount);
            Assert.Equal(0, response.CashTotalAmount);

            // act
            response = new BillPaymentFlowEndedResponse();

            // assert
            Assert.Null(response.BillId);
            Assert.Equal(0, response.BillOutstandingAmount);
        }
        public void GetLastTransactionResponseInit_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""account_type"":""CREDIT"",""auth_code"":""139059"",""bank_date"":""14062019"",""bank_noncash_amount"":1000,""bank_settlement_date"":""14062019"",""bank_time"":""153747"",""card_entry"":""EMV_CTLS"",""currency"":""AUD"",""customer_receipt"":"""",""customer_receipt_printed"":false,""emv_actioncode"":""ARP"",""emv_actioncode_values"":""9BDDE227547B41F43030"",""emv_pix"":""1010"",""emv_rid"":""A000000003"",""emv_tsi"":""0000"",""emv_tvr"":""0000000000"",""expiry_date"":""1122"",""host_response_code"":""000"",""host_response_text"":""APPROVED"",""informative_text"":""                "",""masked_pan"":""............3952"",""merchant_acquirer"":""EFTPOS FROM BANK SA"",""merchant_addr"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_id"":""22341842"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\nAustralia\r\n\r\nTIME 14JUN19   15:37\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190614001137\r\nVisa Credit     \r\nVisa(C)           CR\r\nCARD............3952\r\nAID   A0000000031010\r\nTVR       0000000000\r\nAUTH          139059\r\n\r\nPURCHASE    AUD10.00\r\n\r\n   (000) APPROVED\r\n\r\n*DUPLICATE  RECEIPT*\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""merchant_receipt_printed"":false,""online_indicator"":""Y"",""pos_ref_id"":""prchs-14-06-2019-15-37-49"",""purchase_amount"":1000,""rrn"":""190614001137"",""scheme_app_name"":""Visa Credit"",""scheme_name"":""Visa"",""stan"":""001137"",""success"":true,""terminal_id"":""100612348842"",""terminal_ref_id"":""12348842_14062019153831"",""transaction_type"":""PURCHASE""},""datetime"":""2019-06-14T15:38:31.620"",""event"":""last_transaction"",""id"":""glt10""}}";

            // act
            var msg        = Message.FromJson(jsonStr, secrets);
            var comWrapper = new ComWrapper();
            var response   = comWrapper.GetLastTransactionResponseInit(msg);

            // assert
            Assert.Equal("last_transaction", msg.EventName);
            Assert.True(response.WasRetrievedSuccessfully());
            Assert.Equal(Message.SuccessState.Success, response.GetSuccessState());
            Assert.True(response.WasSuccessfulTx());
            Assert.Equal("PURCHASE", response.GetTxType());
            Assert.Equal("prchs-14-06-2019-15-37-49", response.GetPosRefId());
            Assert.Equal(1000, response.GetBankNonCashAmount());
            Assert.Equal("Visa", response.GetSchemeName());
            Assert.Equal("Visa", response.GetSchemeApp());
            Assert.Equal(0, response.GetAmount());
            Assert.Equal(0, response.GetTransactionAmount());
            Assert.Equal("14062019153747", response.GetBankDateTimeString());
            Assert.Equal("190614001137", response.GetRRN());
            Assert.Equal("APPROVED", response.GetResponseText());
            Assert.Equal("000", response.GetResponseCode());
        }
        public void SettlementInit_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""accumulacxted_purchase_count"":""1"",""accumulated_purchase_value"":""1000"",""accumulated_settle_by_acquirer_count"":""1"",""accumulated_settle_by_acquirer_value"":""1000"",""accumulated_total_count"":""1"",""accumulated_total_value"":""1000"",""bank_date"":""14062019"",""bank_time"":""160940"",""host_response_code"":""941"",""host_response_text"":""CUTOVER COMPLETE"",""merchant_acquirer"":""EFTPOS FROM BANK SA"",""merchant_address"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\n\r\nAustralia\r\n\r\n\r\n SETTLEMENT CUTOVER\r\nTSP     100612348842\r\nTIME   14JUN19 16:09\r\nTRAN   001137-001137\r\nFROM   13JUN19 20:00\r\nTO     14JUN19 16:09\r\n\r\nDebit\r\nTOT     0      $0.00\r\n\r\nMasterCard\r\nTOT     0      $0.00\r\n\r\nVisa\r\nPUR     1     $10.00\r\nTOT     1     $10.00\r\n\r\nBANKED  1     $10.00\r\n\r\nAmex\r\nTOT     0      $0.00\r\n\r\nDiners\r\nTOT     0      $0.00\r\n\r\nJCB\r\nTOT     0      $0.00\r\n\r\nUnionPay\r\nTOT     0      $0.00\r\n\r\nTOTAL\r\nPUR     1     $10.00\r\nTOT     1     $10.00\r\n\r\n (941) CUTOVER COMP\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""schemes"":[{""scheme_name"":""Debit"",""settle_by_acquirer"":""Yes"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""MasterCard"",""settle_by_acquirer"":""Yes"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""Visa"",""settle_by_acquirer"":""Yes"",""total_count"":""1"",""total_purchase_count"":""1"",""total_purchase_value"":""1000"",""total_value"":""1000""},{""scheme_name"":""Amex"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""Diners"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""JCB"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""},{""scheme_name"":""UnionPay"",""settle_by_acquirer"":""No"",""total_count"":""0"",""total_value"":""0""}],""settlement_period_end_date"":""14Jun19"",""settlement_period_end_time"":""16:09"",""settlement_period_start_date"":""13Jun19"",""settlement_period_start_time"":""20:00"",""settlement_triggered_date"":""14Jun19"",""settlement_triggered_time"":""16:09:40"",""stan"":""000000"",""success"":true,""terminal_id"":""100612348842"",""transaction_range"":""001137-001137""},""datetime"":""2019-06-14T16:09:46.395"",""event"":""settle_response"",""id"":""settle116""}}";

            // act
            var msg        = Message.FromJson(jsonStr, secrets);
            var comWrapper = new ComWrapper();
            var response   = comWrapper.SettlementInit(msg);

            // assert
            Assert.Equal("settle_response", msg.EventName);
            Assert.True(response.Success);
            Assert.Equal("settle116", response.RequestId);
            Assert.Equal(1, response.GetSettleByAcquirerCount());
            Assert.Equal(1000, response.GetSettleByAcquirerValue());
            Assert.Equal(1, response.GetTotalCount());
            Assert.Equal(1000, response.GetTotalValue());
            Assert.Equal(DateTime.ParseExact(msg.GetDataStringValue("settlement_period_start_time") + msg.GetDataStringValue("settlement_period_start_date"), "HH:mmddMMMyy", CultureInfo.InvariantCulture), response.GetPeriodStartTime());
            Assert.Equal(DateTime.ParseExact(msg.GetDataStringValue("settlement_period_end_time") + msg.GetDataStringValue("settlement_period_end_date"), "HH:mmddMMMyy", CultureInfo.InvariantCulture), response.GetPeriodEndTime());
            Assert.Equal(DateTime.ParseExact(msg.GetDataStringValue("settlement_triggered_time") + msg.GetDataStringValue("settlement_triggered_date"), "HH:mm:ssddMMMyy", CultureInfo.InvariantCulture), response.GetTriggeredTime());
            Assert.Equal("CUTOVER COMPLETE", response.GetResponseText());
            Assert.NotNull(response.GetReceipt());
            Assert.Equal("001137-001137", response.GetTransactionRange());
            Assert.Equal("100612348842", response.GetTerminalId());
            Assert.False(response.WasMerchantReceiptPrinted());
            Assert.Equal(msg.Data["schemes"].ToArray().Select(jToken => new SchemeSettlementEntry((JObject)jToken)).ToList().Count, response.GetSchemeSettlementEntries().ToList().Count);
        }
예제 #7
0
        public void SpiPayAtTable_OnValidRequest_ReturnStatus()
        {
            // arrange
            var spi = new Spi();

            // act
            var spiPay = new SpiPayAtTable(spi);

            // assert
            Assert.NotNull(spiPay.Config);

            // act
            var spi2 = (Spi)SpiClientTestUtils.GetInstanceField(spiPay.GetType(), spiPay, "_spi");

            // assert
            Assert.Equal(spi.CurrentStatus, spi2.CurrentStatus);

            // arrange
            spiPay = new SpiPayAtTable();

            // act
            var spi3 = (Spi)SpiClientTestUtils.GetInstanceField(spiPay.GetType(), spiPay, "_spi");

            // assert
            Assert.Null(spi3);
        }
예제 #8
0
        public void TerminalConfigurationResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""comms_selected"":""WIFI"",""merchant_id"":""22341842"",""pa_version"":""SoftPay03.16.03"",""payment_interface_version"":""02.02.00"",""plugin_version"":""v2.6.11"",""serial_number"":""321-404-842"",""success"":true,""terminal_id"":""12348842"",""terminal_model"":""VX690""},""datetime"":""2019-06-18T13:00:41.075"",""event"":""terminal_configuration"",""id"":""trmnlcnfg5""}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new TerminalConfigurationResponse(msg);

            // assert
            Assert.Equal("terminal_configuration", msg.EventName);
            Assert.True(response.isSuccess());
            Assert.Equal("WIFI", response.GetCommsSelected());
            Assert.Equal("22341842", response.GetMerchantId());
            Assert.Equal("SoftPay03.16.03", response.GetPAVersion());
            Assert.Equal("02.02.00", response.GetPaymentInterfaceVersion());
            Assert.Equal("v2.6.11", response.GetPluginVersion());
            Assert.Equal("321-404-842", response.GetSerialNumber());
            Assert.Equal("12348842", response.GetTerminalId());
            Assert.Equal("VX690", response.GetTerminalModel());

            // act
            response = new TerminalConfigurationResponse();

            // assert
            Assert.False(response.isSuccess());
        }
예제 #9
0
        public void GetLastTransactionResponse_OnValidResponseTimeOutOfSyncError_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""account_type"":""NOT-SET"",""bank_date"":""07062019"",""bank_settlement_date"":""06062019"",""bank_time"":""143821"",""card_entry"":""NOT-SET"",""error_detail"":""see 'host_response_text' for details"",""error_reason"":""TIME_OUT_OF_SYNC"",""host_response_code"":""511"",""host_response_text"":""TRANS CANCELLED"",""pos_ref_id"":""prchs-07-06-2019-14-38-20"",""rrn"":""190606000000"",""scheme_name"":""TOTAL"",""stan"":""000000"",""success"":false,""terminal_ref_id"":""12348842_07062019144136""},""datetime"":""2019-06-07T14:41:36.857"",""event"":""last_transaction"",""id"":""glt18""}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new GetLastTransactionResponse(msg);

            // assert
            Assert.Equal("last_transaction", msg.EventName);
            Assert.Equal("see 'host_response_text' for details", msg.GetErrorDetail());
            Assert.True(response.WasTimeOutOfSyncError());
            Assert.True(response.WasRetrievedSuccessfully());
            Assert.Equal(Message.SuccessState.Failed, response.GetSuccessState());
            Assert.False(response.WasSuccessfulTx());
            Assert.Equal("prchs-07-06-2019-14-38-20", response.GetPosRefId());
            Assert.Equal(0, response.GetBankNonCashAmount());
            Assert.Equal("TOTAL", response.GetSchemeName());
            Assert.Equal("07062019143821", response.GetBankDateTimeString());
            Assert.Equal("190606000000", response.GetRRN());
            Assert.Equal("TRANS CANCELLED", response.GetResponseText());
            Assert.Equal("511", response.GetResponseCode());
        }
예제 #10
0
        public void RetriesBeforePairing_OnValidValue_Checked()
        {
            // arrange
            const int retriesBeforePairing = 3;

            // act
            Spi spi = new Spi();

            // assert
            Assert.Equal(retriesBeforePairing, SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_retriesBeforePairing"));
        }
예제 #11
0
        public void RetriesBeforeResolvingDeviceAddress_OnValidValue_Checked()
        {
            // arrange
            const int retriesBeforeResolvingDeviceAddress = 3;

            // act
            Spi spi = new Spi();

            // assert
            Assert.Equal(retriesBeforeResolvingDeviceAddress, SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_retriesBeforeResolvingDeviceAddress"));
        }
예제 #12
0
        public void SleepBeforeReconnectMs_OnValidValue_Checked()
        {
            // arrange
            const int sleepBeforeReconnectMs = 3000;

            // act
            Spi spi = new Spi();

            // assert
            Assert.Equal(sleepBeforeReconnectMs, SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_sleepBeforeReconnectMs"));
        }
예제 #13
0
        public void SpiInitiate_OnValidCharactersForPosId_IsSet()
        {
            // arrange
            const string posId         = "RamenPos@";
            const string eftposAddress = "10.20.30.40";

            // act
            var spi   = new Spi(posId, "", eftposAddress, null);
            var value = SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_posId");

            // assert
            Assert.NotEqual("", value);
        }
예제 #14
0
        public void SpiInitate_OnValidCharactersForEftposAddress_IsSet()
        {
            // arrange
            const string eftposAddress = "10.20.30.40";
            const string posId         = "DummyPos";

            // act
            var spi   = new Spi(posId, "", eftposAddress, null);
            var value = SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_eftposAddress").ToString().Replace("ws://", "");

            // assert
            Assert.Equal(eftposAddress, value);
        }
예제 #15
0
        public void GeneratePongResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""datetime"":""2019-06-14T18:47:55.411"",""event"":""pong"",""id"":""ping563""}}";

            // act
            var msg     = Message.FromJson(jsonStr, secrets);
            var message = PongHelper.GeneratePongRessponse(msg);

            // assert
            Assert.Equal(msg.EventName, "pong");
        }
예제 #16
0
        public void SetPosId_OnValidCharacters_IsSet()
        {
            // arrange
            const string posId         = "RamenPos";
            const string eftposAddress = "10.20.30.40";
            var          spi           = new Spi(posId, "", eftposAddress, null);

            // act
            spi.SetPosId(posId);
            var value = SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_posId");

            // assert
            Assert.Equal(posId, value);
        }
예제 #17
0
        public void SetPosId_OnInvalidLength_IsSet()
        {
            // arrange
            const string posId         = "12345678901234567";
            const string eftposAddress = "10.20.30.40";
            var          spi           = new Spi(posId, "", eftposAddress, null);

            // act
            spi.SetPosId(posId);
            var value = SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_posId");

            // assert
            Assert.NotEqual("", value);
        }
예제 #18
0
        public void SetAutoAddressResolution_TurnOnAutoAddress_Enabled()
        {
            // arrange
            const bool autoAddressResolutionEnable = true;
            var        spi = new Spi("", "", "", null);

            SpiClientTestUtils.SetInstanceField(spi, "_currentStatus", SpiStatus.Unpaired);

            // act
            spi.SetAutoAddressResolution(autoAddressResolutionEnable);

            // assert
            Assert.Equal(autoAddressResolutionEnable, SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_autoAddressResolutionEnabled"));
        }
예제 #19
0
        public void SetSerialNumber_ValidSerialNumber_IsSet()
        {
            // arrange
            const string serialNumber = "111-111-111";
            var          spi          = new Spi("", "", "", null);

            SpiClientTestUtils.SetInstanceField(spi, "_currentStatus", SpiStatus.Unpaired);

            // act
            spi.SetSerialNumber(serialNumber);

            // assert
            Assert.Equal(serialNumber, SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_serialNumber"));
        }
예제 #20
0
        public void KeyCheck_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets            = SpiClientTestUtils.SetTestSecrets("3DFC835E5A24C63F3DD04E0BCC54FDBB441339A4D26589D1558D2C10A18AEE4F", "F2AEAC7AA7776D7178F0AC4F0F6D4EF1B5F22630EA93C309620E44ABA5A82D32");
            const string keyResponseJsonStr = @"{""enc"":""6A45A1F6E746CCE3FA470BEAC479F79783C03331DE10A795A859F6D5564168C956557BCCD3EDA55BBEACF34916269537"",""hmac"":""75B56FE4978AC9A22B2D56DDF952983CE8BECE1B6CEC8A7EEEE6ABF9CA2CB471""}";

            // act
            var msg     = Message.FromJson(keyResponseJsonStr, secrets);
            var request = new KeyCheck(msg);

            // assert
            Assert.Equal(msg.EventName, "key_check");
            Assert.Equal(request.ConfirmationCode, msg.IncomingHmac.Substring(0, 6));
        }
예제 #21
0
        public void TerminalBatteryInit_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""battery_level"":""40""},""datetime"":""2019-06-18T13:02:41.777"",""event"":""battery_level_changed"",""id"":""C1.3""}}";

            // act
            var msg        = Message.FromJson(jsonStr, secrets);
            var comWrapper = new ComWrapper();
            var response   = comWrapper.TerminalBatteryInit(msg);

            // assert
            Assert.Equal("battery_level_changed", msg.EventName);
            Assert.Equal("40", response.BatteryLevel);
        }
예제 #22
0
        public void PairResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""success"":true},""event"":""pair_response"",""id"":""pr1""}}";

            // act
            var msg          = Message.FromJson(jsonStr, secrets);
            var pairResponse = new PairResponse(msg);

            // assert
            Assert.True(pairResponse.Success);
            Assert.Equal(msg.EventName, "pair_response");
            Assert.Equal(msg.Id, "pr1");
        }
예제 #23
0
        public void SignatureRequired_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""merchant_receipt"": ""\nEFTPOS FROM WESTPAC\nVAAS Product 2\n275 Kent St\nSydney 2000\nAustralia\n\n\nMID         02447506\nTSP     100381990116\nTIME 26APR17   11:29\nRRN     170426000358\nTRAN 000358   CREDIT\nAmex               S\nCARD............4477\nAUTH          764167\n\nPURCHASE   AUD100.00\nTIP          AUD5.00\n\nTOTAL      AUD105.00\n\n\n (001) APPROVE WITH\n     SIGNATURE\n\n\n\n\n\n\nSIGN:_______________\n\n\n\n\n\n\n\n"",""pos_ref_id"":""prchs-06-06-2019-11-49-05""},""datetime"": ""2017-04-26T11:30:21.000"",""event"": ""signature_required"",""id"": ""24""}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new SignatureRequired(msg);

            // assert
            Assert.Equal("signature_required", msg.EventName);
            Assert.Equal("24", response.RequestId);
            Assert.Equal("prchs-06-06-2019-11-49-05", response.PosRefId);
            Assert.NotNull(response.GetMerchantReceipt());
        }
예제 #24
0
        public void PurchaseResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""account_type"":""SAVINGS"",""auth_code"":""278045"",""bank_cash_amount"":200,""bank_date"":""06062019"",""bank_noncash_amount"":1200,""bank_settlement_date"":""06062019"",""bank_time"":""110750"",""card_entry"":""MAG_STRIPE"",""cash_amount"":200,""currency"":""AUD"",""customer_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\nAustralia\r\n\r\nTIME 06JUN19   11:07\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190606001102\r\nDebit(S)         SAV\r\nCARD............5581\r\nAUTH          278045\r\n\r\nPURCHASE    AUD10.00\r\nCASH         AUD2.00\r\nSURCHARGE    AUD2.00\r\nTOTAL       AUD14.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"",""customer_receipt_printed"":false,""expiry_date"":""0822"",""host_response_code"":""000"",""host_response_text"":""APPROVED"",""informative_text"":""                "",""masked_pan"":""............5581"",""merchant_acquirer"":""EFTPOS FROM BANK SA"",""merchant_addr"":""213 Miller Street"",""merchant_city"":""Sydney"",""merchant_country"":""Australia"",""merchant_id"":""22341842"",""merchant_name"":""Merchant4"",""merchant_postcode"":""2060"",""merchant_receipt"":""EFTPOS FROM BANK SA\r\nMerchant4\r\n213 Miller Street\r\nSydney 2060\r\nAustralia\r\n\r\nTIME 06JUN19   11:07\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190606001102\r\nDebit(S)         SAV\r\nCARD............5581\r\nAUTH          278045\r\n\r\nPURCHASE    AUD10.00\r\nCASH         AUD2.00\r\nSURCHARGE    AUD2.00\r\nTOTAL       AUD14.00\r\n\r\n   (000) APPROVED\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""merchant_receipt_printed"":false,""online_indicator"":""Y"",""pos_ref_id"":""prchs-06-06-2019-11-07-50"",""purchase_amount"":1000,""rrn"":""190606001102"",""scheme_name"":""Debit"",""stan"":""001102"",""success"":true,""surcharge_amount"":200,""terminal_id"":""100612348842"",""terminal_ref_id"":""12348842_06062019110812"",""transaction_type"":""PURCHASE""},""datetime"":""2019-06-06T11:08:12.946"",""event"":""purchase_response"",""id"":""prchs5""}}";

            // act
            var msg      = Message.FromJson(jsonStr, secrets);
            var response = new PurchaseResponse(msg);

            // assert
            Assert.Equal("purchase_response", msg.EventName);
            Assert.True(response.Success);
            Assert.Equal("prchs5", response.RequestId);
            Assert.Equal("prchs-06-06-2019-11-07-50", response.PosRefId);
            Assert.Equal("Debit", response.SchemeName);
            Assert.Equal("190606001102", response.GetRRN());
            Assert.Equal(1000, response.GetPurchaseAmount());
            Assert.Equal(200, response.GetCashoutAmount());
            Assert.Equal(0, response.GetTipAmount());
            Assert.Equal(200, response.GetSurchargeAmount());
            Assert.Equal(1200, response.GetBankNonCashAmount());
            Assert.Equal(200, response.GetBankCashAmount());
            Assert.NotNull(response.GetCustomerReceipt());
            Assert.NotNull(response.GetMerchantReceipt());
            Assert.Equal("APPROVED", response.GetResponseText());
            Assert.Equal("000", response.GetResponseCode());
            Assert.Equal("12348842_06062019110812", response.GetTerminalReferenceId());
            Assert.Equal("MAG_STRIPE", response.GetCardEntry());
            Assert.Equal("SAVINGS", response.GetAccountType());
            Assert.Equal("278045", response.GetAuthCode());
            Assert.Equal("06062019", response.GetBankDate());
            Assert.Equal("110750", response.GetBankTime());
            Assert.Equal("............5581", response.GetMaskedPan());
            Assert.Equal("100612348842", response.GetTerminalId());
            Assert.False(response.WasCustomerReceiptPrinted());
            Assert.False(response.WasMerchantReceiptPrinted());
            Assert.Equal(DateTime.ParseExact(msg.GetDataStringValue("bank_settlement_date"), "ddMMyyyy", CultureInfo.InvariantCulture).Date, response.GetSettlementDate());
            Assert.Equal(response.GetResponseValue("pos_ref_id"), response.PosRefId);

            // act
            response = new PurchaseResponse();

            // assert
            Assert.Null(SpiClientTestUtils.GetInstanceField(response.GetType(), response, "_m"));
            Assert.Null(response.PosRefId);
        }
예제 #25
0
        public void SetPosInfoResponse_ValidResponse_IsSet()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""success"":true},""datetime"":""2019-06-07T10:53:31.517"",""event"":""set_pos_info_response"",""id"":""prav3""}}";
            var          msg     = Message.FromJson(jsonStr, secrets);

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

            // assert
            Assert.Equal("set_pos_info_response", msg.EventName);
            Assert.True(response.isSuccess());
            Assert.Equal("", response.getErrorReason());
            Assert.Equal("", response.getErrorDetail());
            Assert.Equal("", response.getResponseValueWithAttribute("error_detail"));
        }
예제 #26
0
        public void PhoneForAuthRequired_OnValidRequestWithMessage_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""event"":""authorisation_code_required"",""id"":""20"",""datetime"":""2017-11-01T06:09:33.918"",""data"":{""merchant_id"":""12345678"",""auth_centre_phone_number"":""1800999999"",""pos_ref_id"": ""xyz""}}}";

            // act
            var msg     = Message.FromJson(jsonStr, secrets);
            var request = new PhoneForAuthRequired(msg);

            // assert
            Assert.Equal("authorisation_code_required", msg.EventName);
            Assert.Equal("xyz", request.PosRefId);
            Assert.Equal("20", request.RequestId);
            Assert.Equal("1800999999", request.GetPhoneNumber());
            Assert.Equal("12345678", request.GetMerchantId());
        }
예제 #27
0
        public void TransactionFlowState_OnValidRequestPhoneForAuthRequired_ReturnObjects()
        {
            // arrnge
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""event"":""authorisation_code_required"",""id"":""20"",""datetime"":""2017-11-01T06:09:33.918"",""data"":{""merchant_id"":""12345678"",""auth_centre_phone_number"":""1800999999"",""pos_ref_id"": ""xyz""}}}";
            var          msg     = Message.FromJson(jsonStr, secrets);
            var          request = new PhoneForAuthRequired(msg);
            var          transactionFlowState = new TransactionFlowState("1", TransactionType.SettlementEnquiry, 0, msg, $"Waiting for EFTPOS connection to make a settlement enquiry");

            // act
            transactionFlowState.PhoneForAuthRequired(request, "PhoneForAuthRequired");

            // assert
            Assert.Equal(request, transactionFlowState.PhoneForAuthRequiredMessage);
            Assert.True(transactionFlowState.AwaitingPhoneForAuth);
            Assert.Equal("PhoneForAuthRequired", transactionFlowState.DisplayMessage);
        }
예제 #28
0
        public void SetEftposAddress_OnValidCharacters_IsSet()
        {
            // arrange
            const string eftposAddress = "10.20.30.40";
            var          spi           = new Spi();
            var          conn          = new Connection();

            SpiClientTestUtils.SetInstanceField(spi, "_currentStatus", SpiStatus.Unpaired);
            SpiClientTestUtils.SetInstanceField(spi, "_conn", conn);

            // act
            spi.SetEftposAddress(eftposAddress);
            var value = SpiClientTestUtils.GetInstanceField(typeof(Spi), spi, "_eftposAddress").ToString().Replace("ws://", "");

            // assert
            Assert.Equal(eftposAddress, value);
        }
예제 #29
0
        public void TransactionFlowState_OnValidResponseSignatureRequired_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""merchant_receipt"": ""\nEFTPOS FROM WESTPAC\nVAAS Product 2\n275 Kent St\nSydney 2000\nAustralia\n\n\nMID         02447506\nTSP     100381990116\nTIME 26APR17   11:29\nRRN     170426000358\nTRAN 000358   CREDIT\nAmex               S\nCARD............4477\nAUTH          764167\n\nPURCHASE   AUD100.00\nTIP          AUD5.00\n\nTOTAL      AUD105.00\n\n\n (001) APPROVE WITH\n     SIGNATURE\n\n\n\n\n\n\nSIGN:_______________\n\n\n\n\n\n\n\n"",""pos_ref_id"":""prchs-06-06-2019-11-49-05""},""datetime"": ""2017-04-26T11:30:21.000"",""event"": ""signature_required"",""id"": ""24""}}";

            // act
            var msg                  = Message.FromJson(jsonStr, secrets);
            var response             = new SignatureRequired(msg);
            var transactionFlowState = new TransactionFlowState("1", TransactionType.SettlementEnquiry, 0, msg, $"Waiting for EFTPOS connection to make a settlement enquiry");

            transactionFlowState.SignatureRequired(response, "SignatureRequired");

            // assert
            Assert.Equal(response, transactionFlowState.SignatureRequiredMessage);
            Assert.True(transactionFlowState.AwaitingSignatureCheck);
            Assert.Equal("SignatureRequired", transactionFlowState.DisplayMessage);
        }
예제 #30
0
        public void PrintingResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""success"":true},""datetime"":""2019-06-14T18:51:00.948"",""event"":""print_response"",""id"":""C24.0""}}";
            var          msg     = Message.FromJson(jsonStr, secrets);

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

            // assert
            Assert.Equal("print_response", msg.EventName);
            Assert.True(response.IsSuccess());
            Assert.Equal("C24.0", msg.Id);
            Assert.Equal("", response.GetErrorReason());
            Assert.Equal("", response.GetErrorDetail());
            Assert.Equal("", response.GetResponseValueWithAttribute("error_detail"));
        }