public Transaction(string customerRefNo, int merchantId, string status, decimal amount, string currency, decimal?vat, decimal?capturedAmount, decimal?authorizedAmount, DateTime created, string creditStatus, decimal?creditedAmount, int?merchantResponseCode, string paymentMethod, string cardType, string callbackUrl, string subscriptionId, string subscriptionType, string eci, string mdStatus, string expiryYear, string expiryMonth, string chName, string authCode, TransactionCustomer customer) { CustomerRefNo = customerRefNo; ClientOrderNumber = CustomerRefNo; MerchantId = merchantId; Status = status; Amount = amount; Currency = currency; Vat = vat; CapturedAmount = capturedAmount; AuthorizedAmount = authorizedAmount; Created = created; CreditStatus = creditStatus; CreditedAmount = creditedAmount; MerchantResponseCode = merchantResponseCode; PaymentMethod = paymentMethod; CardType = cardType; CallbackUrl = callbackUrl; SubscriptionId = subscriptionId; SubscriptionType = subscriptionType; Customer = customer; Eci = eci; MdStatus = mdStatus; ExpiryYear = expiryYear; ExpiryMonth = expiryMonth; ChName = chName; AuthCode = authCode; OrderRows = new List <TransactionOrderRow>(); NumberedOrderRows = new List <NumberedOrderRowBuilder>(); }
public QueryResponse(XmlDocument response) : base(response) { if (response.SelectSingleNode("/response/transaction") != null) { TransactionCustomer customer = new TransactionCustomer( AttributeString(response, "/response/transaction/customer", "id"), TextString(response, "/response/transaction/customer/firstname"), TextString(response, "/response/transaction/customer/lastname"), TextString(response, "/response/transaction/customer/initials"), TextString(response, "/response/transaction/customer/fullname"), TextString(response, "/response/transaction/customer/email"), TextString(response, "/response/transaction/customer/ssn"), TextString(response, "/response/transaction/customer/address"), TextString(response, "/response/transaction/customer/address2"), TextString(response, "/response/transaction/customer/city"), TextString(response, "/response/transaction/customer/country"), TextString(response, "/response/transaction/customer/zip"), TextString(response, "/response/transaction/customer/phone"), TextString(response, "/response/transaction/customer/vatnumber"), TextString(response, "/response/transaction/customer/housenumber"), TextString(response, "/response/transaction/customer/companyname") ); Transaction = new Transaction( TextString(response, "/response/transaction/customerrefno"), TextInt(response, "/response/transaction/merchantid").Value, TextString(response, "/response/transaction/status"), MinorCurrencyToDecimalAmount(TextInt(response, "/response/transaction/amount").Value), TextString(response, "/response/transaction/currency"), MinorCurrencyToDecimalAmount(TextInt(response, "/response/transaction/vat")), MinorCurrencyToDecimalAmount(TextInt(response, "/response/transaction/capturedamount")), MinorCurrencyToDecimalAmount(TextInt(response, "/response/transaction/authorizedamount")), DateTime.Parse(TextString(response, "/response/transaction/created")), TextString(response, "/response/transaction/creditstatus"), MinorCurrencyToDecimalAmount(TextInt(response, "/response/transaction/creditedamount")), TextInt(response, "/response/transaction/merchantresponsecode"), TextString(response, "/response/transaction/paymentmethod"), TextString(response, "/response/transaction/cardtype"), TextString(response, "/response/transaction/callbackurl"), TextString(response, "/response/transaction/subscriptionid"), TextString(response, "/response/transaction/subscriptiontype"), TextString(response, "/response/transaction/eci"), TextString(response, "/response/transaction/mdstatus"), TextString(response, "/response/transaction/expiryyear"), TextString(response, "/response/transaction/expirymonth"), TextString(response, "/response/transaction/ch_name"), TextString(response, "/response/transaction/authcode"), customer ); var enumerator = response.SelectNodes("/response/transaction/orderrows/row").GetEnumerator(); var rowNumber = 1; // NumberedOrderRows are 1-indexed while (enumerator.MoveNext()) { var xmlNode = (XmlNode)enumerator.Current; Transaction.OrderRows.Add(new TransactionOrderRow( TextString(xmlNode, "./id"), TextString(xmlNode, "./name"), MinorCurrencyToDecimalAmount(TextInt(xmlNode, "./amount").Value), MinorCurrencyToDecimalAmount(TextInt(xmlNode, "./vat")), TextString(xmlNode, "./description"), TextDecimal(xmlNode, "./quantity").GetValueOrDefault(1), TextString(xmlNode, "./sku"), TextString(xmlNode, "./unit") )); decimal row_amount = MinorCurrencyToDecimalAmount(TextInt(xmlNode, "./amount").Value); decimal row_vat = MinorCurrencyToDecimalAmount(TextInt(xmlNode, "./vat")) ?? 0M; decimal row_amountExVat = (row_amount - row_vat); decimal row_vatPercent = (row_vat / (row_amountExVat)) * 100; var numberedOrderRow = new NumberedOrderRowBuilder() .SetRowNumber(rowNumber++) .SetCreditInvoiceId(null) .SetInvoiceId(null) .SetStatus(null) .SetArticleNumber(TextString(xmlNode, "./sku")) .SetName(TextString(xmlNode, "./name")) .SetDescription(TextString(xmlNode, "./description")) .SetAmountExVat(row_amountExVat) .SetAmountIncVat(row_amount) .SetVatPercent(row_vatPercent) .SetQuantity(TextDecimal(xmlNode, "./quantity").GetValueOrDefault(1)) .SetUnit(TextString(xmlNode, "./unit")) .SetVatDiscount(0) .SetDiscountPercent(0) ; Transaction.NumberedOrderRows.Add(numberedOrderRow); } } }