Automate Stripe Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Stripe data from PowerShell? This article demonstrates how to utilize the Stripe Cmdlets for tasks like connecting to Stripe data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Stripe is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Stripe.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Stripe; this tutorial shows how to use the Provider to create, retrieve, update, and delete Stripe data.

Once you have acquired the necessary connection properties, accessing Stripe data in PowerShell can be enabled in three steps.

Use the OAuth authentication standard to connect to Stripe. To authenticate using OAuth, register an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" chapter of the help documentation for a guide to using OAuth.

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Stripe.StripeConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
  3. Instantiate the StripeDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Email, Discount from Customers"
    
    $da= New-Object System.Data.CData.Stripe.StripeDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.email $_.discount
    }

Update Stripe Data

$cmd =  New-Object System.Data.CData.Stripe.StripeCommand("UPDATE Customers SET Delinquent='False' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Stripe.StripeParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Stripe Data

$cmd =  New-Object System.Data.CData.Stripe.StripeCommand("INSERT INTO Customers (Delinquent) VALUES (@myDelinquent)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Stripe.StripeParameter("@myDelinquent","False")))
$cmd.ExecuteNonQuery()

Delete Stripe Data

$cmd =  New-Object System.Data.CData.Stripe.StripeCommand("DELETE FROM Customers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Stripe.StripeParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Stripe Data Provider to get started:

 Download Now

Learn more:

Stripe Icon Stripe ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Stripe data including Accounts, BankAccounts, Customers, Transfers, and more!