private static CreditCardGatewayResult ReadPaymentInformation(Order order) { CreditCardGatewayResult paymentInformation = new CreditCardGatewayResult(); if (!string.IsNullOrEmpty(order.GatewayResult)) { var payResult = new XmlDocument(); payResult.LoadXml(order.GatewayResult); var element = payResult.SelectSingleNode("//req_card_number"); paymentInformation.Number = element?.InnerText; element = payResult.SelectSingleNode("//req_bill_to_surname"); paymentInformation.LastName = element?.InnerText; element = payResult.SelectSingleNode("//req_ship_to_surname"); paymentInformation.FirstName = element?.InnerText; element = payResult.SelectSingleNode("//req_card_expiry_date"); paymentInformation.ExpiryDate = element?.InnerText; element = payResult.SelectSingleNode("//req_card_type"); paymentInformation.Type = element?.InnerText; } return(paymentInformation); }
private XmlNode BuildOrderXml(XmlDocument xmlDocument, Order order, RenderOrderSettings settings) { var tableNode = CreateTableNode(xmlDocument, "EcomOrders"); var itemNode = CreateAndAppendItemNode(tableNode, "EcomOrders"); var user = User.GetUserByID(order.CustomerAccessUserId) ?? (!ExecutingContext.IsBackEnd() ? User.GetCurrentExtranetUser() : null); // do not use order.Modified in XML unless the field can be ignored for hash calculation // in the current version of NAV for vanBaerle, the calculation is made using the ExternalId field name but the logic corresonds to the customer number in DynamicWeb //AddChildXmlNode(itemNode, "OrderCustomerAccessUserExternalId", !string.IsNullOrWhiteSpace(user?.ExternalID) ? user.ExternalID : Settings.Instance.AnonymousUserKey); AddChildXmlNode(itemNode, "OrderCustomerAccessUserExternalId", !string.IsNullOrWhiteSpace(user?.CustomerNumber) ? user.CustomerNumber : Settings.Instance.AnonymousUserKey); AddChildXmlNode(itemNode, "OrderCustomerNumber", !string.IsNullOrWhiteSpace(user?.CustomerNumber) ? user.CustomerNumber : Settings.Instance.AnonymousUserKey); AddChildXmlNode(itemNode, "CreateOrder", settings.CreateOrder.ToString()); AddChildXmlNode(itemNode, "OrderId", order.Id); AddChildXmlNode(itemNode, "OrderAutoId", order.AutoId.ToString()); AddChildXmlNode(itemNode, "OrderIntegrationOrderId", order.IntegrationOrderId); AddChildXmlNode(itemNode, "OrderCurrencyCode", order.CurrencyCode); AddChildXmlNode(itemNode, "OrderDate", order.Date.ToIntegrationString()); AddChildXmlNode(itemNode, "OrderPaymentMethodName", order.PaymentMethod, true); AddChildXmlNode(itemNode, "OrderPaymentMethodId", order.PaymentMethodId); AddChildXmlNode(itemNode, "OrderShippingMethodName", order.ShippingMethod, true); AddChildXmlNode(itemNode, "OrderShippingMethodId", order.ShippingMethodId); AddChildXmlNode(itemNode, "OrderShippingFee", order.ShippingFee.PriceWithoutVAT.ToIntegrationString()); AddChildXmlNode(itemNode, "OrderCustomerName", order.CustomerName); AddChildXmlNode(itemNode, "OrderCustomerAddress", order.CustomerAddress); AddChildXmlNode(itemNode, "OrderCustomerAddress2", order.CustomerAddress2); AddChildXmlNode(itemNode, "OrderCustomerCity", order.CustomerCity); AddChildXmlNode(itemNode, "OrderCustomerState", order.CustomerRegion); AddChildXmlNode(itemNode, "OrderCustomerZip", order.CustomerZip); AddChildXmlNode(itemNode, "OrderCustomerCountryCode", order.CustomerCountryCode); AddChildXmlNode(itemNode, "OrderCustomerEmail", order.CustomerEmail); AddChildXmlNode(itemNode, "OrderCustomerPhone", order.CustomerPhone); AddChildXmlNode(itemNode, "OrderCustomerFax", order.CustomerFax); AddChildXmlNode(itemNode, "OrderDeliveryName", !string.IsNullOrWhiteSpace(order.DeliveryName) ? order.DeliveryName : order.CustomerName); AddChildXmlNode(itemNode, "OrderDeliveryAddress", order.DeliveryAddress); AddChildXmlNode(itemNode, "OrderDeliveryAddress2", order.DeliveryAddress2); AddChildXmlNode(itemNode, "OrderDeliveryCity", order.DeliveryCity); AddChildXmlNode(itemNode, "OrderDeliveryState", order.DeliveryRegion); AddChildXmlNode(itemNode, "OrderDeliveryZip", order.DeliveryZip); AddChildXmlNode(itemNode, "OrderDeliveryCountryCode", order.DeliveryCountryCode); AddChildXmlNode(itemNode, "OrderDeliveryEmail", order.DeliveryEmail); AddChildXmlNode(itemNode, "OrderDeliveryPhone", order.DeliveryPhone); AddChildXmlNode(itemNode, "OrderDeliveryFax", order.DeliveryFax); AddChildXmlNode(itemNode, "OrderCustomerComment", order.CustomerComment); AddChildXmlNode(itemNode, "OrderPriceTotal", order.TotalPrice.ToIntegrationString()); AddChildXmlNode(itemNode, "OrderCaptureAmount", order.CaptureAmount.ToIntegrationString()); AddChildXmlNode(itemNode, "OrderVoucherCode", order.VoucherCode); AddChildXmlNode(itemNode, "OrderTransactionId", order.TransactionNumber); AddChildXmlNode(itemNode, "OrderStateId", order.StateId); AddChildXmlNode(itemNode, "OrderStateName", order.OrderState.Name, true); CreditCardGatewayResult paymentInformation = ReadPaymentInformation(order); AddChildXmlNode(itemNode, "OrderTransactionCardType", paymentInformation.Type, true); AddChildXmlNode(itemNode, "OrderTransactionCardExpiryDate", paymentInformation.ExpiryDate, true); AddChildXmlNode(itemNode, "OrderTransactionMaskedCreditCardNumber", paymentInformation.Number, true); AddChildXmlNode(itemNode, "CardHolderFirstName", paymentInformation.FirstName, true); AddChildXmlNode(itemNode, "CardholderLastName", paymentInformation.LastName, true); if (settings.AddOrderFieldsToRequest) { AppendOrderFields(order, itemNode); } return(tableNode); }