예제 #1
0
        public void RefundResponse_OnValidResponse_ReturnObjects()
        {
            // arrange
            var          secrets = SpiClientTestUtils.SetTestSecrets();
            const string jsonStr = @"{""message"":{""data"":{""account_type"":""CREDIT"",""auth_code"":""067849"",""bank_date"":""06062019"",""bank_noncash_amount"":1000,""bank_settlement_date"":""06062019"",""bank_time"":""114905"",""card_entry"":""EMV_CTLS"",""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:49\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190606001105\r\nVisa(C)           CR\r\nCARD............5581\r\nAUTH          067849\r\n\r\nREFUND      AUD10.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"":""ARQ"",""emv_actioncode_values"":""67031BCC5AD15818"",""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:49\r\nMID         22341842\r\nTSP     100612348842\r\nRRN     190606001105\r\nVisa(C)           CR\r\nCARD............5581\r\nAUTH          067849\r\n\r\nREFUND      AUD10.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"":""rfnd-06-06-2019-11-49-05"",""refund_amount"":1000,""rrn"":""190606001105"",""scheme_name"":""Visa"",""stan"":""001105"",""success"":true,""terminal_id"":""100612348842"",""terminal_ref_id"":""12348842_06062019114915"",""transaction_type"":""REFUND""},""datetime"":""2019-06-06T11:49:15.038"",""event"":""refund_response"",""id"":""refund150""}}";

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

            //assert
            Assert.Equal("refund_response", msg.EventName);
            Assert.True(response.Success);
            Assert.Equal("refund150", response.RequestId);
            Assert.Equal("rfnd-06-06-2019-11-49-05", response.PosRefId);
            Assert.Equal("Visa", response.SchemeName);
            Assert.Equal("Visa", response.SchemeAppName);
            Assert.Equal("190606001105", response.GetRRN());
            Assert.Equal(1000, response.GetRefundAmount());
            Assert.NotNull(response.GetCustomerReceipt());
            Assert.NotNull(response.GetMerchantReceipt());
            Assert.Equal("APPROVED", response.GetResponseText());
            Assert.Equal("000", response.GetResponseCode());
            Assert.Equal("12348842_06062019114915", response.GetTerminalReferenceId());
            Assert.Equal("EMV_CTLS", response.GetCardEntry());
            Assert.Equal("CREDIT", response.GetAccountType());
            Assert.Equal("067849", response.GetAuthCode());
            Assert.Equal("06062019", response.GetBankDate());
            Assert.Equal("114905", 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 RefundResponse();

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