Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
        public void GetLastTransactionResponse_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 response = new GetLastTransactionResponse(msg);

            response.CopyMerchantReceiptToCustomerReceipt();

            //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());
            Assert.Equal(msg.GetDataStringValue("customer_receipt"), msg.GetDataStringValue("merchant_receipt"));

            // act
            response = new GetLastTransactionResponse();

            // assert
            Assert.Null(SpiClientTestUtils.GetInstanceField(response.GetType(), response, "_m"));
        }