Cmdlets for PayPal

Build 21.0.7930

Establishing a Connection

With the CData Cmdlets users can install a data module, set the connection properties, and start scripting. This section provides examples of using our PayPal Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Installing and Connecting

If you have PSGet, installing the cmdlets can be accomplished from the PowerShell Gallery with the following command. You can also obtain a setup from the CData site.

Install-Module PayPalCmdlets

The following line is then added to your profile, loading the cmdlets on the next session:

Import-Module PayPalCmdlets;

You can then use the Connect-PayPal cmdlet to create a connection object that can be passed to other cmdlets:

$conn = Connect-PayPal -Schema 'REST' -InitiateOAuth 'GETANDREFRESH' -OAuthClientId 'MyOAuthClientId' -OAuthClientSecret 'MyOAuthClientSecret' -UseSandbox 'true'

The provider surfaces tables from two PayPal APIs. The APIs use different authentication methods.

To choose the API you want to work with, set the Schema property to REST or SOAP. By default, the SOAP schema will be used.

  • The REST API uses the OAuth standard. To authenticate to the REST API, you will need to set the AuthScheme to OAuth, the OAuthClientId, and OAuthClientSecret properties. See Connecting to the REST API for more information.
  • The SOAP API requires Signature API credentials. To authenticate to the SOAP API, you will need to set the AuthScheme to Basic, set the Username, Password, and Signature properties. You generate these API credentials when you enable the SOAP API. See Connecting to the SOAP API for more information.

For testing purposes, set UseSandbox to true and use Sandbox credentials.

Retrieving Data

The Select-PayPal cmdlet provides a native PowerShell interface for retrieving data:

$results = Select-PayPal -Connection $conn -Table "Payments" -Columns @("Id, State") -Where "CreateTime='2016-01-15'"
The Invoke-PayPal cmdlet provides an SQL interface. This cmdlet can be used to execute an SQL query via the Query parameter.

Piping Cmdlet Output

The cmdlets return row objects to the pipeline one row at a time. The following line exports results to a CSV file:

Select-PayPal -Connection $conn -Table Payments -Where "CreateTime > '2016-01-15'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myPaymentsData.csv -NoTypeInformation

You will notice that we piped the results from Select-PayPal into a Select-Object cmdlet and excluded some properties before piping them into an Export-CSV cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each row object in the result set, and we do not necessarily want that information in our CSV file.

However, this makes it easy to pipe the output of one cmdlet to another. The following is an example of converting a result set to JSON:

PS C:\> $conn  = Connect-PayPal -Schema 'REST' -InitiateOAuth 'GETANDREFRESH' -OAuthClientId 'MyOAuthClientId' -OAuthClientSecret 'MyOAuthClientSecret' -UseSandbox 'true'
PS C:\> $row = Select-PayPal -Connection $conn -Table "Payments" -Columns (Id, State) -Where "CreateTime > '2016-01-15'" | select -first 1
PS C:\> $row | ConvertTo-Json
  "Connection":  {

  "Table":  "Payments",
  "Columns":  [

  "Id":  "MyId",
  "State":  "MyState"

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930