internal void _handleBillPaymentAdvice(Message m) { var billPayment = new BillPayment(m); // Ask POS for Bill Details, inluding encoded PaymentData var existingBillStatus = GetBillStatus(billPayment.BillId, billPayment.TableId, billPayment.OperatorId); if (existingBillStatus.Result != BillRetrievalResult.SUCCESS) { _log.Warn("Could not retrieve Bill Status for Payment Advice. Sending Error to Eftpos."); _spi._send(existingBillStatus.ToMessage(m.Id)); } var existingPaymentHistory = existingBillStatus.getBillPaymentHistory(); var foundExistingEntry = existingPaymentHistory.Find(phe => phe.GetTerminalRefId() == billPayment.PurchaseResponse.GetTerminalReferenceId()); if (foundExistingEntry != null) { // We have already processed this payment. // perhaps Eftpos did get our acknowledgement. // Let's update Eftpos. _log.Warn("Had already received this bill_paymemnt advice from eftpos. Ignoring."); _spi._send(existingBillStatus.ToMessage(m.Id)); return; } // Let's add the new entry to the history var updatedHistoryEntries = new List <PaymentHistoryEntry>(existingPaymentHistory) { new PaymentHistoryEntry { PaymentType = billPayment.PaymentType.ToString().ToLower(), PaymentSummary = billPayment.PurchaseResponse.ToPaymentSummary() } }; var updatedBillData = BillStatusResponse.ToBillData(updatedHistoryEntries); // Advise POS of new payment against this bill, and the updated BillData to Save. var updatedBillStatus = BillPaymentReceived(billPayment, updatedBillData); // Just in case client forgot to set these: updatedBillStatus.BillId = billPayment.BillId; updatedBillStatus.TableId = billPayment.TableId; if (updatedBillStatus.Result != BillRetrievalResult.SUCCESS) { _log.Warn("POS Errored when being Advised of Payment. Letting EFTPOS know, and sending existing bill data."); updatedBillStatus.BillData = existingBillStatus.BillData; } else { updatedBillStatus.BillData = updatedBillData; } _spi._send(updatedBillStatus.ToMessage(m.Id)); }
private BillStatusResponse OnPayAtTableBillPaymentReceived(BillPayment billPayment, string updatedBillData) { BillPaymentInfo billPaymentInfo = new BillPaymentInfo(); billPaymentInfo.BillPayment = billPayment; billPaymentInfo.UpdatedBillData = updatedBillData; BillStatusResponse billStatusResponse = new BillStatusResponse(); callBackPayAtTableBillPaymentReceived(billPaymentInfo, out billStatusResponse); return(billStatusResponse); }
private BillStatusResponse OnPayAtTableGetBillStatus(string billId, string tableId, string operatorId) { BillStatusInfo billStatusInfo = new BillStatusInfo(); billStatusInfo.BillId = billId; billStatusInfo.TableId = tableId; billStatusInfo.OperatorId = operatorId; BillStatusResponse billStatusResponse = new BillStatusResponse(); callBackPayAtTableGetBillStatus(billStatusInfo, out billStatusResponse); return(billStatusResponse); }
private BillStatusResponse OnPayAtTableGetBillStatus(string billId, string tableId, string operatorId, bool paymentFlowStarted) { BillStatusRequest billStatusRequest = new BillStatusRequest { BillId = billId, TableId = tableId, OperatorId = operatorId, PaymentFlowStarted = paymentFlowStarted }; BillStatusResponse billStatusResponse = new BillStatusResponse(); callBackPayAtTableGetBillStatus(billStatusRequest, out billStatusResponse); return(billStatusResponse); }