Invoking the Checkout with the Mac SDK v4

Checkouts can be shown at any time, provided you have already initialized the SDK singleton and the Product you’d like to be purchased:

Before starting, ensure you have followed our Mac SDK v4 Setup instructions.


[paddle showCheckoutForProduct:paddleProduct options:nil checkoutStatusCompletion:^(PADCheckoutState state, NSDictionary * _Nullable checkoutData) {
	// Examine checkout state to determine the checkout result
}];

paddle?.showCheckout(for: paddleProduct, options: nil, checkoutStatusCompletion: { (state: PADCheckoutState, checkoutData: [AnyHashable: Any]?) in
    // Examine checkout state to determine the checkout result
})

A full implementation would look something like:


#import <Paddle/Paddle.h>
	
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

	// Your Paddle SDK Config from the Vendor Dashboard:
	NSString *myPaddleProductID = @"12345";
	NSString *myPaddleVendorID = @"56791";
	NSString *myPaddleAPIKey = @"abc123def345hij678";

	// Populate a local object in case we're unable to retrieve data
  	// from the Vendor Dashboard:
	PADProductConfiguration *defaultProductConfig = [[PADProductConfiguration alloc] init];
	defaultProductConfig.productName = @"My v4 Product";
	defaultProductConfig.vendorName = @"My Company";

	// Initialize the SDK Instance with Seller details:
	Paddle *paddle = [Paddle sharedInstanceWithVendorID:myPaddleVendorID
												 apiKey:myPaddleAPIKey
											  productID:myPaddleProductID
										  configuration:defaultProductConfig];
							
	// Initialize the Product you'd like to work with:	  
	PADProduct *paddleProduct = [[PADProduct alloc] initWithProductID:myPaddleProductID productType:PADProductTypeSDKProduct configuration:nil];

	// Ask the Product to get it's latest state and info from the Paddle Platform:
	[paddleProduct refresh:^(NSDictionary * _Nullable productDelta, NSError * _Nullable error) {
		// Launch the checkout:
		[paddle showCheckoutForProduct:paddleProduct options:nil checkoutStatusCompletion:^(PADCheckoutState state, NSDictionary * _Nullable checkoutData) {
			// Examine checkout state to determine the checkout result
		}];
	}];
}

// Your Paddle SDK Config from the Vendor Dashboard:
let myPaddleVendorID = "12345"
let myPaddleAPIKey = "1234abc5678defg"
let myPaddleProductID = "678910"

// Default Product Config in case we're unable to reach our servers on first run:
let defaultProductConfig = PADProductConfiguration()
defaultProductConfig.productName = "My v4 Product"
defaultProductConfig.vendorName = "My Company"

// Initialize the SDK singleton with the config:
let paddle = Paddle.sharedInstance(withVendorID: myPaddleVendorID, apiKey: myPaddleAPIKey, productID: myPaddleProductID, configuration: defaultProductConfig)

// Initialize the Product you'd like to work with:
let paddleProduct = PADProduct(productID: myPaddleProductID, productType: PADProductType.sdkProduct, configuration: nil)

// Ask the Product to get it's latest state and info from the Paddle Platform:
paddleProduct?.refresh({ (delta: [AnyHashable : Any]?, error: Error?) in
    // Launch the checkout:
    paddle?.showCheckout(for: paddleProduct!, options: nil, checkoutStatusCompletion: { (state: PADCheckoutState, checkoutData: [AnyHashable : Any]?) in
        // Examine checkout state to determine the checkout result
    })
})

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.