Automate Stripe Integration Tasks from PowerShell



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 Cmdlets for Stripe are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Stripe.

PowerShell Cmdlets or ADO.NET Provider?

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

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, you will need to 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.

PowerShell

  1. Install the module:

    Install-Module StripeCmdlets
  2. Connect:

    $stripe = Connect-Stripe -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $delinquent = "False" $customers = Select-Stripe -Connection $stripe -Table "Customers" -Where "Delinquent = `'$Delinquent`'" $customers

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

    $customers = Invoke-Stripe -Connection $stripe -Query 'SELECT * FROM Customers WHERE Delinquent = @Delinquent' -Params @{'@Delinquent'='False'}

ADO.NET

  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

PowerShell

Update-Stripe -Connection $Stripe -Columns @('Email','Discount') -Values @('MyEmail', 'MyDiscount') -Table Customers -Id "MyId"

ADO.NET

$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

PowerShell

Add-Stripe -Connection $Stripe -Table Customers -Columns @("Email", "Discount") -Values @("MyEmail", "MyDiscount")

ADO.NET

$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

PowerShell

Remove-Stripe -Connection $Stripe -Table "Customers" -Id "MyId"

ADO.NET

$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 account data including Accounts, BankAccounts, Customers, Transfers, and more!