private XElement GenerateAccountElement(PaymentRequest <TPaymentMethod> paymentRequest, IPaymentMethodXmlTransformer <TPaymentMethod> paymentMethodXmlTransformer) { if (paymentRequest.PaymentCode.PaymentMethod is CreditCardPaymentMethod && ( paymentRequest.PaymentCode.PaymentType == PaymentType.Capture || paymentRequest.PaymentCode.PaymentType == PaymentType.Reversal || paymentRequest.PaymentCode.PaymentType == PaymentType.Refund)) { return(null); } return(paymentMethodXmlTransformer.GenerateAccountElement(paymentRequest.PaymentCode.PaymentMethod)); }
public string TransformRequest(PaymentRequest <TPaymentMethod> paymentRequest, IPaymentMethodXmlTransformer <TPaymentMethod> paymentMethodXmlTransformer) { XDocument result = new XDocument( new XDeclaration("1.0", Encoding.UTF8.WebName, "yes"), new XElement("Request", new XAttribute("version", "1.0"), new XElement("Header", new XElement("Security", paymentRequest.InstanceId.ToXAttribute("sender"))), new XElement("Transaction", paymentRequest.TransactionMode.ToXAttribute("mode"), paymentRequest.ResponseMode.ToXAttribute("response"), paymentRequest.ChannelId.ToXAttribute("channel"), new XElement("User", paymentRequest.UserLogin.ToXAttribute("login"), paymentRequest.UserPassword.ToXAttribute("pwd")), new XElement("Identification", paymentRequest.TransactionId.ToXElement("TransactionID"), paymentRequest.InvoiceId.ToXElement("InvoiceID"), paymentRequest.ShopperId.ToXElement("ShopperID"), paymentRequest.ReferenceId.ToXElement("ReferenceID") ), GeneratePaymentElement(paymentRequest), // Recurrence // Job GenerateAccountElement(paymentRequest, paymentMethodXmlTransformer), GenerateCustomerElement(paymentRequest), // Details GenerateFrontendElement(paymentRequest), GenerateAnalysisElement(paymentRequest) ))); return(result.ToString()); }