Integrating Paddle SDK in Your macOS Application

To successfully integrate Paddle into your macOS application, follow the steps outlined below. This guide will help you configure the Paddle SDK and retrieve order details when a user makes a purchase.

Step 1: Configure Paddle SDK

First, you need to set up your Paddle SDK configuration using the credentials from your Vendor Dashboard.

// Paddle SDK Configuration from Vendor Dashboard
NSString *paddleProductID = @"12345";
NSString *paddleVendorID = @"56791";
NSString *paddleAPIKey = @"abc123def345hij678";

// Create a default product configuration
PADProductConfiguration *defaultConfig = [[PADProductConfiguration alloc] init];
defaultConfig.productName = @"My v4 Product";
defaultConfig.vendorName = @"My Company";

// Initialize the Paddle SDK with vendor details
Paddle *paddle = [Paddle sharedInstanceWithVendorID:paddleVendorID
                                               apiKey:paddleAPIKey
                                            productID:paddleProductID
                                        configuration:defaultConfig];

Step 2: Initialize the Product

Next, create an instance of the product you wish to manage within your application.

// Initialize the product instance
PADProduct *paddleProduct = [[PADProduct alloc] initWithProductID:paddleProductID productType:PADProductTypeSDKProduct configuration:nil];

Step 3: Refresh Product Information

To ensure you have the latest product details, refresh the product state from the Paddle platform.

// Refresh product information from Paddle
[paddleProduct refresh:^(NSDictionary * _Nullable productDelta, NSError * _Nullable error) {
    // Display the product access dialog for purchasing
    [paddle showProductAccessDialogWithProduct:paddleProduct];
}];

Step 4: Retrieve Checkout Details

While the showProductAccessDialogWithProduct method allows for product access, you can also use the following method to get detailed checkout information:

// Show checkout for the product and handle the checkout status
[paddle showCheckoutForProduct:paddleProduct options:nil checkoutStatusCompletion:^(PADCheckoutState state, NSDictionary * _Nullable checkoutData) {
    // Analyze the checkout state to retrieve order details
    if (state == PADCheckoutStateCompleted) {
        // Process the checkoutData to access order details
    }
}];

Conclusion

By following these steps, you can integrate Paddle into your macOS application and retrieve order details effectively. If you have any further questions or need assistance, feel free to reach out for support.