Automate Authorize.Net Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Authorize.Net ADO.NET Provider

Easy-to-use Authorize.Net client enables .NET-based applications to easily consume Authorize.NET Transactions, Customers, BatchStatistic, etc.



Are you looking for a quick and easy way to access Authorize.Net data from PowerShell? We show how to use the Cmdlets for Authorize.Net and the CData ADO.NET Provider for Authorize.Net to connect to Authorize.Net data and synchronize, automate, download, and more.

The CData Cmdlets for Authorize.Net are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Authorize.Net.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Authorize.Net API, but also an SQL interface; this tutorial shows how to use both to retrieve Authorize.Net data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Authorize.Net. To access Authorize.Net data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Authorize.Net.

After obtaining the needed connection properties, accessing Authorize.Net data in PowerShell consists of three basic steps.

You can obtain the necessary connection properties on the Security Settings -> General Settings page after logging into your Merchant Account.

  • UseSandbox: The Authorize.Net API to be used to process transactions. If you are using a production account, this property can be left blank. If you are using a developer test account, set this to 'TRUE'.
  • LoginID: The API login Id associated with your payment gateway account. This property is used to authenticate that you are authorized to submit website transactions. Note that this value is not the same as the login Id that you use to log in to the Merchant Interface.
  • TransactionKey: The transaction key associated with your payment gateway account. This property is used to authenticate that you are authorized to submit website transactions.

PowerShell

  1. Install the module:

    Install-Module AuthorizeNetCmdlets
  2. Connect:

    $authorizenet = Connect-AuthNet -LoginId "$LoginId" -TransactionKey "$TransactionKey"
  3. Search for and retrieve data:

    $includestatistics = "True" $settledbatchlist = Select-AuthNet -Connection $authorizenet -Table "SettledBatchList" -Where "IncludeStatistics = `'$IncludeStatistics`'" $settledbatchlist

    You can also use the Invoke-AuthNet cmdlet to execute SQL commands:

    $settledbatchlist = Invoke-AuthNet -Connection $authorizenet -Query 'SELECT * FROM SettledBatchList WHERE IncludeStatistics = @IncludeStatistics' -Params @{'@IncludeStatistics'='True'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Authorize.Net\lib\System.Data.CData.AuthorizeNet.dll")
  2. Connect to Authorize.Net:

    $conn= New-Object System.Data.CData.AuthorizeNet.AuthorizeNetConnection("LoginId=MyLoginId;TransactionKey=MyTransactionKey;") $conn.Open()
  3. Instantiate the AuthorizeNetDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT MarketType, TotalCharge from SettledBatchList" $da= New-Object System.Data.CData.AuthorizeNet.AuthorizeNetDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.markettype $_.totalcharge }