![]() |
VOOZH | about |
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.
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, 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.
Install the module:
Install-Module StripeCmdlets
Connect:
$stripe = Connect-Stripe -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -InitiateOAuth "$InitiateOAuth"
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'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Stripe\lib\System.Data.CData.Stripe.dll")
Connect to Stripe:
$conn= New-Object System.Data.CData.Stripe.StripeConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
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 -Connection $Stripe -Columns @('Email','Discount') -Values @('MyEmail', 'MyDiscount') -Table Customers -Id "MyId"
$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()
Add-Stripe -Connection $Stripe -Table Customers -Columns @("Email", "Discount") -Values @("MyEmail", "MyDiscount")
$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()
Remove-Stripe -Connection $Stripe -Table "Customers" -Id "MyId"
$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()
CodeProject
Download a free trial of the Stripe Data Provider to get started:
Download NowLearn more:
👁 Stripe IconRapidly create and deploy powerful .NET applications that integrate with Stripe account data including Accounts, BankAccounts, Customers, Transfers, and more!