2016-09-20 67 views
0

我打算在ASP.Net MVC中使用sofort payment API,但我有問題需要在C#中以下XML格式添加信息。如何使用C#添加信息以柔化API XML

<?xml version="1.0" encoding="UTF-8" ?> 
<multipay>  
    <project_id>53245</project_id> 
    <interface_version>pn_test_1</interface_version> 
    <amount>2.20</amount> 
    <currency_code>EUR</currency_code> 
    <reasons> 
     <reason>Testueberweisung</reason> 
     <reason>-TRANSACTION-</reason> 
    </reasons> 
    <user_variables> 
     <user_variable>test</user_variable> 
    </user_variables> 
    <success_url>xyz</success_url> 
    <success_link_redirect>1</success_link_redirect> 
    <abort_url>xyz</abort_url> 
    <notification_urls> 
     <notification_url>xyz</notification_url> 
     <notification_url notify_on="received,loss">xyz</notification_url> 
    </notification_urls> 
    <su /> 
</multipay> 
+0

描述你的確切問題;如果您發佈任何錯誤消息,它將更有幫助。 – Jacob

回答

0
var xmlRequest = new XElement("multipay", 
new XElement("project_id", "53245"), 
new XElement("interface_version", "pn_test_1"), 
new XElement("amount", "2.20"), 
new XElement("currency_code", "EUR"), 
new XElement("reasons", new XElement("reason", "Testueberweisung"), new XElement("reason", "-TRANSACTION-")) 
); 

串xmlreq = xmlRequest.ToString();

+0

太棒了!你的代碼工作。 –