/// <summary> /// Create an item from an existing XML message /// </summary> public NexoItem(string xml) { // try deserializing the mesage to a request //SaleToPOIRequest request = Deserialize<SaleToPOIRequest>(xml); SaleToPOIRequest request = DeserializeRequest(xml); if (ValidMsg(request) && IdentifyNexoObject(request.MessageHeader)) { Request = request; XML = xml; SaleToPOI = AllocateObject(Category); } else { // try deserializing the mesage to a response //SaleToPOIResponse reply = Deserialize<SaleToPOIResponse>(xml); SaleToPOIResponse reply = DeserializeResponse(xml); if (ValidMsg(reply) && IdentifyNexoObject(reply.MessageHeader)) //&& IdentifyNexoObject((MessageCategoryEnumeration)Enum.Parse(typeof(MessageCategoryEnumeration), reply.MessageHeader.MessageCategory))) { Reply = reply; XML = xml; SaleToPOI = AllocateObject(Category); } } }
/// <summary> /// Create an item from a request /// </summary> /// <param name="msg"></param> public NexoItem(SaleToPOIRequest msg) { if (null != msg && null != msg.MessageHeader && null != msg.Item && IdentifyNexoObject(msg.MessageHeader)) { Request = msg; XML = Serialize(Request); SaleToPOI = AllocateObject(Category); } }
protected NexoObject(MessageCategoryEnumeration category) { // prepare request and response objects Request = new SaleToPOIRequest(); Reply = new SaleToPOIResponse(); Request.SecurityTrailer = null; Request.MessageHeader.MessageType = MessageTypeEnumeration.Request.ToString(); Reply.SecurityTrailer = null; Reply.MessageHeader.MessageType = MessageTypeEnumeration.Response.ToString(); MessageCategory = category; RequestItem = ReplyItem = null; }
/// <summary> /// Plain POI Cloud api/terminal api message /// </summary> /// <param name="transactionType"></param> /// <returns></returns> public static SaleToPOIRequest CreatePosPaymentRequest(string transactionType) { var saleToPoiRequest = new SaleToPOIRequest() { MessageHeader = new MessageHeader { MessageType = "Request", MessageClass = "Service", MessageCategory = "Payment", SaleID = "POSSystemID12345", POIID = "MX915-284251016", ProtocolVersion = "3.0", ServiceID = DateTime.Now.ToString("ddHHmmss")//this should be unique }, MessagePayload = new PaymentRequest() { SaleData = new SaleData() { SaleToAcquirerData = "[email protected]&shopperReference=fakeRef&recurringContract=RECURRING", SaleTransactionID = new TransactionIdentification() { TransactionID = "PosAuth", TimeStamp = DateTime.Now }, TokenRequested = "Customer", }, PaymentTransaction = new PaymentTransaction() { AmountsReq = new AmountsReq() { Currency = "EUR", RequestedAmount = 10100 } }, PaymentData = new PaymentData() { Payment = transactionType } }, SecurityTrailer = new ContentInformationType() { } }; return(saleToPoiRequest); }
/// <summary> /// Plain POI Cloud api/terminal api message /// </summary> /// <param name="paymentType"></param> /// <returns></returns> public static SaleToPOIRequest CreatePosPaymentRequest() { var saleToPoiRequest = new SaleToPOIRequest() { MessageHeader = new MessageHeader { MessageType = MessageType.Request, MessageClass = MessageClassType.Service, MessageCategory = MessageCategoryType.Payment, SaleID = "POSSystemID12345", POIID = "MX915-284251016", ServiceID = DateTime.Now.ToString("ddHHmmss")//this should be unique }, MessagePayload = new PaymentRequest() { SaleData = new SaleData() { SaleTransactionID = new TransactionIdentification() { TransactionID = "PosAuth", TimeStamp = DateTime.Now }, TokenRequestedType = TokenRequestedType.Customer, }, PaymentTransaction = new PaymentTransaction() { AmountsReq = new AmountsReq() { Currency = "EUR", RequestedAmount = 10100 } }, PaymentData = new PaymentData() { PaymentType = PaymentType.Normal } }, SecurityTrailer = new ContentInformation() { } }; return(saleToPoiRequest); }
public NexoMessage(SaleToPOIRequest request, string xml, bool incoming) { Reply = null; Request = request; Initialise(xml, incoming); }
private bool ValidMsg(SaleToPOIRequest msg) { return(null != msg && null != msg.MessageHeader && null != msg.Item); }
public void Init() { //Create a mock pos payment request _paymentRequest = MockPosApiRequest.CreatePosPaymentRequest(); }