Windows SDK setup
Requirements
Section titled “Requirements”- The Windows SDK works with Windows 7 and above
- The SDK supports .NET frameworks 3.5 and upwards
- The SDK supports WinForms and WPF applications
- The user’s system will need Internet Explorer 10 or above or Edge browser
- The system must also support TLS 1.2
Overview
Section titled “Overview”Paddle’s Windows C# SDK has two primary components: the main Paddle class where most functions are centralized and the PaddleProduct class which represents a Paddle product for you to work with in your app.
Paddle Singleton (Paddle)
Section titled “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)
Section titled “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, or verify or deactivate a license.
- Most Paddle SDK methods will require a
PaddleProduct. You can also have multiple products in play at once.
Visual Studio Setup
Section titled “Visual Studio Setup”Follow these steps to set up the Paddle SDK in your app:
- 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 the reference) - Ensure the
EmbedInteropTypesproperty is set toFalsefor both thePaddleSDKandShDocVw(Right-Click each reference and select Properties). - If targeting WinForms, add a
.manifestfile (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
Section titled “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 Dashboardstring vendorId = "12345";string productId = "678910";string apiKey = "1234abc5678defg";
// Default Product Config in case we're unable to reach our servers on first runvar productInfo = new PaddleProductConfig { ProductName = "My v2 product", VendorName = "My Company" };
// Initialize the SDK singleton with the configPaddle.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 withPaddleProduct product = PaddleProduct.CreateProduct(productId);
// Ask the Product to get it's latest state and info from the Paddle Platformproduct.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); }});