<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Authorize.net API and XML to CSV in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Authorize-net-API-and-XML-to-CSV/m-p/84879#M53425</link>
    <description>&lt;P&gt;Don't know why you are not getting the option of csv. As most of the time we get the data in the csv form.&lt;SPAN&gt;&amp;nbsp;But one thing we did as at the start of the year. I hired and expert so that he could make all these things fix for us. And now we are directly getting the csv file. after his configuration and integration through api.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Nov 2022 16:58:10 GMT</pubDate>
    <dc:creator>Enrique6214</dc:creator>
    <dc:date>2022-11-13T16:58:10Z</dc:date>
    <item>
      <title>Authorize.net API and XML to CSV</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Authorize-net-API-and-XML-to-CSV/m-p/84321#M53141</link>
      <description>&lt;P class=""&gt;I'm working with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://authorize.net/" target="_blank" rel="noopener nofollow ugc"&gt;Authorize.net&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;echat&lt;/A&gt;&lt;A href="https://chatspin.download" target="_blank" rel="noopener"&gt;spin&lt;/A&gt;&lt;A href="https://e-chats.com/omegle" target="_blank" rel="noopener"&gt;&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;API in powershell to return some transaction data. The output is in XML and I need to get it into CSV. Here is what I'm needing it to do.&lt;/P&gt;&lt;P class=""&gt;API :&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.authorize.net/api/reference/index.html" target="_blank" rel="noopener nofollow ugc"&gt;https://developer.authorize.net/api/reference/index.html&amp;nbsp;&lt;/A&gt;&lt;A href="https://echat.date" target="_blank" rel="noopener"&gt;/echat&lt;/A&gt;&lt;A href="https://chatrandom.download" target="_blank" rel="noopener"&gt;random&lt;/A&gt;&lt;/P&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;P class=""&gt;Get batchId from data range (&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;getSettledBatchListRequest&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Get all transactionId from batchId (&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;getTransactionListRequest&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Get transaction details for each (&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;getTransactionDetailsRequest&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Take each transaction details response and create a csv file&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Need some kind of error handling to insure all transactions that are called are wrote to the file&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;In each transaction details response i really only care about the following XML nodes: settleAmount, customer id, firstName, lastName, creditCard, bankAccount&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Ideally i need two separate files, one for credit card and one for bank account but the challenge is I don't know what type it is until the transactionId is called again getTransactionDetailsRequest&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;Below is what I've got so far. I've having a bit of trouble with the variable inside of a single quote on the getTransactionDetailsRequest. Any help would be greatly appreciated:&lt;/P&gt;&lt;P class=""&gt;EDIT: fixed the xml variables and then figured out the foreach issue. Now just need to get the foreach results to CSV&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$url = "https://api.authorize.net/xml/v1/request.api"
$api_login_id = "api_login_id"
$transaction_key = "transaction_key"

$authorize_path = "C:\Users\Admin\Desktop\authorize"

$getSettledBatchListRequest_xml = @"
&amp;lt;getSettledBatchListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
  &amp;lt;merchantAuthentication&amp;gt;
    &amp;lt;name&amp;gt;$api_login_id&amp;lt;/name&amp;gt;
    &amp;lt;transactionKey&amp;gt;$transaction_key&amp;lt;/transactionKey&amp;gt;
  &amp;lt;/merchantAuthentication&amp;gt;
  &amp;lt;includeStatistics&amp;gt;true&amp;lt;/includeStatistics&amp;gt;

  &amp;lt;firstSettlementDate&amp;gt;2018-08-01T00:00:00&amp;lt;/firstSettlementDate&amp;gt;
  &amp;lt;lastSettlementDate&amp;gt;2018-08-01T23:59:59&amp;lt;/lastSettlementDate&amp;gt;
&amp;lt;/getSettledBatchListRequest&amp;gt;
"@

# Call for batchId on certain date range. Output XML and get batchId from XML
Invoke-RestMethod -Uri $url -Method Post -Body $getSettledBatchListRequest_xml -ContentType 'application/xml' -OutFile $authorize_path\getSettledBatchListRequest.xml
$getSettledBatchListRequest_results = Get-Content $authorize_path\getSettledBatchListRequest.xml
$batchid = ([xml]$getSettledBatchListRequest_results).getSettledBatchListResponse.batchList.batch.batchId


$getTransactionListRequest_xml = @"
&amp;lt;getTransactionListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
    &amp;lt;merchantAuthentication&amp;gt;
        &amp;lt;name&amp;gt;$api_login_id&amp;lt;/name&amp;gt;
        &amp;lt;transactionKey&amp;gt;$transaction_key&amp;lt;/transactionKey&amp;gt;
    &amp;lt;/merchantAuthentication&amp;gt;
    &amp;lt;batchId&amp;gt;$batchid&amp;lt;/batchId&amp;gt;
    &amp;lt;sorting&amp;gt;
      &amp;lt;orderBy&amp;gt;submitTimeUTC&amp;lt;/orderBy&amp;gt;
      &amp;lt;orderDescending&amp;gt;true&amp;lt;/orderDescending&amp;gt;
    &amp;lt;/sorting&amp;gt;
    &amp;lt;paging&amp;gt;
      &amp;lt;limit&amp;gt;1000&amp;lt;/limit&amp;gt;
      &amp;lt;offset&amp;gt;1&amp;lt;/offset&amp;gt;
    &amp;lt;/paging&amp;gt;
&amp;lt;/getTransactionListRequest&amp;gt;
"@


Invoke-RestMethod -Uri $url -Method Post -Body $getTransactionListRequest_xml -ContentType 'application/xml' -OutFile $authorize_path\getTransactionListRequest.xml
$getTransactionListRequest_results = Get-Content $authorize_path\getTransactionListRequest.xml
$transactionids = ([xml]$getTransactionListRequest_results).getTransactionListResponse.transactions.transaction.transId


$getTransactionDetailsRequest = @"
&amp;lt;getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
      &amp;lt;merchantAuthentication&amp;gt;
        &amp;lt;name&amp;gt;$api_login_id&amp;lt;/name&amp;gt;
        &amp;lt;transactionKey&amp;gt;$transaction_key&amp;lt;/transactionKey&amp;gt;
      &amp;lt;/merchantAuthentication&amp;gt;
      &amp;lt;transId&amp;gt;$transactionid&amp;lt;/transId&amp;gt;
&amp;lt;/getTransactionDetailsRequest&amp;gt;
"@


$results = foreach ($transactionid in $transactionids) {
Invoke-RestMethod -Uri $url -Method Post -Body $getTransactionDetailsRequest -ContentType 'application/xml'
}

$results &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 07:35:47 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Authorize-net-API-and-XML-to-CSV/m-p/84321#M53141</guid>
      <dc:creator>FramJamesgot</dc:creator>
      <dc:date>2022-09-29T07:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Authorize.net API and XML to CSV</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Authorize-net-API-and-XML-to-CSV/m-p/84879#M53425</link>
      <description>&lt;P&gt;Don't know why you are not getting the option of csv. As most of the time we get the data in the csv form.&lt;SPAN&gt;&amp;nbsp;But one thing we did as at the start of the year. I hired and expert so that he could make all these things fix for us. And now we are directly getting the csv file. after his configuration and integration through api.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 16:58:10 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Authorize-net-API-and-XML-to-CSV/m-p/84879#M53425</guid>
      <dc:creator>Enrique6214</dc:creator>
      <dc:date>2022-11-13T16:58:10Z</dc:date>
    </item>
  </channel>
</rss>

