Windows SDK C# v2 Setup

Our Windows C# SDK has two primary components (and a handful of auxiliary / customization objects): the main Paddle class where most things are centralized and the Product class which represents your Paddle product(s) for you to work with in your app.

The SDK currently only supports WinForms and WPF applications.

Paddle Singleton (Paddle)

This is the centre of the Paddle SDK experience. Here, you can do general configuration and control for the SDK for example, initialize the SDK, control the SDK UI, and trigger actions like license recovery.

Paddle Product (PaddleProduct)

This is a local representation of your Paddle Product or Subscription. It contains details such as trial days remaining, activation date, price and actions on the Product to refresh its data from the vendor dashboard, verify license, deactivate etc…

Most Paddle SDK methods will require a PaddleProduct. You can also have multiple products in play at once.

Visual Studio Setup

To setup the Paddle SDK in your app please follow these steps:

  • Add the Paddle SDK to your project via NuGet;
  • Add a reference to ShDocVw (Right-click the Solution Explorer then select “Add a reference”, then “COM”, locate Microsoft Internet Controls, and add that reference)
    • Ensure the EmbedInteropTypes property is set to False for both the PaddleSDK and ShDocVw (Right-Click each reference and select Properties).
    • If targeting WinForms, add a .manifest file (go to Solution Explorer, select Add, then New item (or CTRL+SHIFT+A), then select Application Manifest File) and uncomment the following code snippet:

<windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>

Example Paddle SDK Setup

The Paddle SDK requires that you initialize it with an SDK Product. You’ll need to create one via the Vendor Dashboard. Once initialized you can work with any type of Product or Subscription. We’ll never assume the SDK Product used to initialize the SDK is the relevant one.

Import the Paddle Singleton to your class:


using PaddleSDK;
using PaddleSDK.Checkout;
using PaddleSDK.Product;

Configure and initialize the SDK and your Product:


/// Your Paddle SDK Config from the Vendor Dashboard
string vendorId = "12345";
string productId = "678910";
string apiKey = "1234abc5678defg";

// Default Product Config in case we're unable to reach our servers on first run
var productInfo = new PaddleProductConfig { ProductName = "My v2 product", VendorName = "My Company" };

// Initialize the SDK singleton with the config
Paddle.Configure(apiKey, vendorId, productId, productInfo);

// Set up events for Checkout.
// We recommend handling the TransactionComplete and TransactionError events.
// TransactionBegin is optional.
Paddle.Instance.TransactionCompleteEvent += Paddle_TransactionCompleteEvent;
Paddle.Instance.TransactionErrorEvent += Paddle_TransactionErrorEvent;
Paddle.Instance.TransactionBeginEvent += Paddle_TransactionBeginEvent;

// Initialize the Product you'd like to work with
PaddleProduct product = PaddleProduct.CreateProduct(productId);

// Ask the Product to get it's latest state and info from the Paddle Platform
product.Refresh((success) =>
{
    // product data was successfully refreshed
    if (success)
    {
        if (!product.Activated)
        {
            // Product is not activated, so let's show the Product Access dialog to gatekeep your app
            Paddle.Instance.ShowProductAccessWindowForProduct(product);
        }
    }
    else
    {
        // The SDK was unable to get the last info from the Paddle Platform.
        // We can show the Product Access dialog with the data provided in the PaddleProductConfig object.
        Paddle.Instance.ShowProductAccessWindowForProduct(product);
    }
});

Customization

You can further configure and customize the experience using various customization objects in the SDK.

Paddle Checkout Options

Here are ways you can further customize and configure the checkout experience:

  • Pre-fill various checkout fields (email, country, etc…)
  • Coupons
  • Accepts Paddle Price Overrides
  • Passthrough
  • Custom parameters etc…

Paddle Product Configuration

  • Set the default values to be shown in the SDK UI if triggered while offline without a local Paddle Product.
  • Let the SDK know what the trial configuration should be if launched offline.

Questions about Paddle?

If you need any help regarding your Paddle integration, please get in touch with our Customer Success team using the form below.