private void HandleFinishedMoto(TransactionFlowState txState) { MotoPurchaseResponse motoResponse; PurchaseResponse purchaseResponse; switch (txState.Success) { case Message.SuccessState.Success: Console.WriteLine($"# WOOHOO - WE GOT MOTO-PAID!"); motoResponse = new MotoPurchaseResponse(txState.Response); purchaseResponse = motoResponse.PurchaseResponse; Console.WriteLine("# Response: {0}", purchaseResponse.GetResponseText()); Console.WriteLine("# RRN: {0}", purchaseResponse.GetRRN()); Console.WriteLine("# Scheme: {0}", purchaseResponse.SchemeName); Console.WriteLine("# Card Entry: {0}", purchaseResponse.GetCardEntry()); Console.WriteLine("# Customer Receipt:"); Console.WriteLine(!purchaseResponse.WasCustomerReceiptPrinted() ? purchaseResponse.GetCustomerReceipt().TrimEnd() : "# PRINTED FROM EFTPOS"); Console.WriteLine("# PURCHASE: {0}", purchaseResponse.GetPurchaseAmount()); Console.WriteLine("# BANKED NON-CASH AMOUNT: {0}", purchaseResponse.GetBankNonCashAmount()); Console.WriteLine("# BANKED CASH AMOUNT: {0}", purchaseResponse.GetBankCashAmount()); break; case Message.SuccessState.Failed: Console.WriteLine($"# WE DID NOT GET MOTO-PAID :("); if (txState.Response != null) { motoResponse = new MotoPurchaseResponse(txState.Response); purchaseResponse = motoResponse.PurchaseResponse; Console.WriteLine("# Error: {0}", txState.Response.GetError()); Console.WriteLine("# Error Detail: {0}", txState.Response.GetErrorDetail()); Console.WriteLine("# Response: {0}", purchaseResponse.GetResponseText()); Console.WriteLine("# RRN: {0}", purchaseResponse.GetRRN()); Console.WriteLine("# Scheme: {0}", purchaseResponse.SchemeName); Console.WriteLine("# Customer Receipt:"); Console.WriteLine(purchaseResponse.GetCustomerReceipt().TrimEnd()); } break; case Message.SuccessState.Unknown: Console.WriteLine($"# WE'RE NOT QUITE SURE WHETHER THE MOTO 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(); } }
public void MotoPurchaseResponse_OnValidResponse_ReturnObjects() { // arrange var secrets = SpiClientTestUtils.SetTestSecrets(); const string jsonStr = @"{""message"":{""data"":{""pos_ref_id"":""a-zA-Z0-9"",""account_type"": ""CREDIT"",""purchase_amount"": 1000,""surcharge_amount"": 200,""bank_noncash_amount"": 1200,""bank_cash_amount"": 200,""auth_code"": ""653230"",""bank_date"": ""07092017"",""bank_time"": ""152137"",""bank_settlement_date"": ""21102017"",""currency"": ""AUD"",""emv_actioncode"": """",""emv_actioncode_values"": """",""emv_pix"": """",""emv_rid"": """",""emv_tsi"": """",""emv_tvr"": """",""expiry_date"": ""1117"",""host_response_code"": ""000"",""host_response_text"": ""APPROVED"",""informative_text"": "" "",""masked_pan"": ""............0794"",""merchant_acquirer"": ""EFTPOS FROM WESTPAC"",""merchant_addr"": ""275 Kent St"",""merchant_city"": ""Sydney"",""merchant_country"": ""Australia"",""merchant_id"": ""02447508"",""merchant_name"": ""VAAS Product 4"",""merchant_postcode"": ""2000"",""online_indicator"": ""Y"",""scheme_app_name"": """",""scheme_name"": """",""stan"": ""000212"",""rrn"": ""1517890741"",""success"": true,""terminal_id"": ""100381990118"",""transaction_type"": ""MOTO"",""card_entry"": ""MANUAL_PHONE"",""customer_receipt"":""EFTPOS FROM WESTPAC\r\nVAAS Product 4\r\n275 Kent St\r\nSydney\r\nMID02447508\r\nTSP100381990118\r\nTIME 07SEP17 15:21\r\nRRN 1517890741\r\nTRAN 000212 CREDIT\r\nVisa Credit \r\nVisa M\r\nCARD............0794\r\nAUTH 653230\r\n\r\nMOTO AUD10000\r\n\r\nTOTAL AUD10000\r\n\r\n\r\n(000)APPROVED\r\n\r\n\r\n *CUSTOMER COPY*\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"",""merchant_receipt"":""EFTPOS FROM WESTPAC\r\nVAAS Product4\r\n275 Kent St\r\nSydney\r\nMID02447508\r\nTSP100381990118\r\nTIME 07SEP17 15:21\r\nRRN 1517890741\r\nTRAN 000212 CREDIT\r\nVisa Credit \r\nVisa M\r\nCARD............0794\r\nAUTH 653230\r\n\r\nPURCHASE AUD10000\r\n\r\nTOTAL AUD10000\r\n\r\n\r\n(000) APPROVED\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n""},""datetime"": ""2018-02-06T04:19:00.545"",""event"": ""moto_purchase_response"",""id"": ""4""}}"; // act var msg = Message.FromJson(jsonStr, secrets); var response = new MotoPurchaseResponse(msg); //assert Assert.Equal("moto_purchase_response", msg.EventName); Assert.True(response.PurchaseResponse.Success); Assert.Equal("4", response.PurchaseResponse.RequestId); Assert.Equal("a-zA-Z0-9", response.PurchaseResponse.PosRefId); Assert.Equal("", response.PurchaseResponse.SchemeName); Assert.Equal("653230", response.PurchaseResponse.GetAuthCode()); Assert.Equal("1517890741", response.PurchaseResponse.GetRRN()); Assert.Equal(1000, response.PurchaseResponse.GetPurchaseAmount()); Assert.Equal(200, response.PurchaseResponse.GetSurchargeAmount()); Assert.Equal(1200, response.PurchaseResponse.GetBankNonCashAmount()); Assert.Equal(200, response.PurchaseResponse.GetBankCashAmount()); Assert.NotNull(response.PurchaseResponse.GetCustomerReceipt()); Assert.NotNull(response.PurchaseResponse.GetMerchantReceipt()); Assert.Equal("APPROVED", response.PurchaseResponse.GetResponseText()); Assert.Equal("000", response.PurchaseResponse.GetResponseCode()); Assert.Equal("MANUAL_PHONE", response.PurchaseResponse.GetCardEntry()); Assert.Equal("CREDIT", response.PurchaseResponse.GetAccountType()); Assert.Equal("07092017", response.PurchaseResponse.GetBankDate()); Assert.Equal("152137", response.PurchaseResponse.GetBankTime()); Assert.Equal("............0794", response.PurchaseResponse.GetMaskedPan()); Assert.Equal("100381990118", response.PurchaseResponse.GetTerminalId()); Assert.False(response.PurchaseResponse.WasCustomerReceiptPrinted()); Assert.False(response.PurchaseResponse.WasMerchantReceiptPrinted()); Assert.Equal(response.PurchaseResponse.GetResponseValue("pos_ref_id"), response.PosRefId); // act response = new MotoPurchaseResponse(); // assert Assert.Null(response.PurchaseResponse); Assert.Null(response.PurchaseResponse?.PosRefId); }