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.

Paddle Singleton (Paddle)

This is the center 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 Paddle Product. You can also have multiple products in play at once.

Visual Studio Setup

Add the Paddle SDK to your project via Nuget.

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
Paddle.Instance.TransactionCompleteEvent += PaddleCheckoutForm_TransactionCompleteEvent;
Paddle.Instance.TransactionErrorEvent += PaddleCheckoutForm_TransactionErrorEvent;
Paddle.Instance.TransactionBeginEvent += PaddleCheckoutForm_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) =>
{
    // Optionally show the default "Product Access" UI to gatekeep your app
    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.