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
}];

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
		}];
	}];
}