![]() |
VOOZH | about |
The CData Cmdlets for PayPal are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to PayPal.
The Cmdlets are not only a PowerShell interface to PayPal, but also an SQL interface; this tutorial shows how to use both to retrieve PayPal data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for PayPal. To access PayPal data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for PayPal.
Once you have acquired the necessary connection properties, accessing PayPal data in PowerShell can be enabled in three steps.
The provider surfaces tables from two PayPal APIs. The APIs use different authentication methods.
See the "Getting Started" chapter of the help documentation for a guide to obtaining the necessary API credentials.
To select the API you want to work with, you can set the Schema property to REST or SOAP. By default the SOAP schema will be used.
For testing purposes you can set UseSandbox to true and use sandbox credentials.
Install the module:
Install-Module PayPalCmdlets
Connect:
$paypal = Connect-PayPal -Schema "$Schema" -Username "$Username" -Password "$Password" -Signature "$Signature" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$transactionclass = "Received" $transactions = Select-PayPal -Connection $paypal -Table "Transactions" -Where "TransactionClass = `'$TransactionClass`'" $transactions
You can also use the Invoke-PayPal cmdlet to execute SQL commands:
$transactions = Invoke-PayPal -Connection $paypal -Query 'SELECT * FROM Transactions WHERE TransactionClass = @TransactionClass' -Params @{'@TransactionClass'='Received'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for PayPal\lib\System.Data.CData.PayPal.dll")
Connect to PayPal:
$conn= New-Object System.Data.CData.PayPal.PayPalConnection("Schema=SOAP;Username=sandbox-facilitator_api1.test.com;Password=xyz123;Signature=zx2127;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the PayPalDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Date, GrossAmount from Transactions"
$da= New-Object System.Data.CData.PayPal.PayPalDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.date $_.grossamount
}
Download a free trial of the PayPal Data Provider to get started:
Download NowLearn more:
👁 PayPal IconEasy-to-use PayPal client enables .NET-based applications to easily consume PayPal Transactions, Orders, Sales, Invoices, etc.