In-app checkout (Mac)
A Paddle in-app checkout can be shown at any time, provided you have already initialized both the SDK singleton and the Product you’d like to load in the checkout.
Call the showCheckoutForProduct method to load the checkout:
[paddle showCheckoutForProduct:paddleProduct options:nil checkoutStatusCompletion:^(PADCheckoutState state, ADCheckoutData * _Nullable checkoutData){ // Examine checkout state to determine the checkout result}];paddle?.showCheckout(for: paddleProduct, options: nil, checkoutStatusCompletion: { (state: PADCheckoutState, checkoutData: PADCheckoutData?) 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 delegate:nil];
// Initialize the Product you'd like to work with PADProduct *paddleProduct = [[PADProduct alloc] initWithProductID:myPaddleProductID productType:PADProductTypeSDKProduct configuration:defaultProductConfig];
// Ask the Product to get its 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, PADCheckoutData * _Nullable checkoutData) { // Examine checkout state to determine the checkout result }]; }];}// Your Paddle SDK Config from the Vendor Dashboardlet myPaddleVendorID = "12345"let myPaddleAPIKey = "1234abc5678defg"let myPaddleProductID = "678910"
// Default Product Config in case we're unable to reach our servers on first runlet defaultProductConfig = PADProductConfiguration()defaultProductConfig.productName = "My v4 Product"defaultProductConfig.vendorName = "My Company"
// Initialize the SDK singleton with the configlet paddle = Paddle.sharedInstance( withVendorID: myPaddleVendorID, apiKey: myPaddleAPIKey, productID: myPaddleProductID, configuration: defaultProductConfig, delegate: nil)
// Initialize the Product you'd like to work withlet paddleProduct = PADProduct( productID: myPaddleProductID, productType: PADProductType.sdkProduct, configuration: defaultProductConfig)
// Ask the Product to get its latest state and info from the Paddle PlatformpaddleProduct?.refresh( { (delta: [AnyHashable: Any]?, error: Error?) in // Launch the checkout: paddle?.showCheckout( for: paddleProduct!, options: nil, checkoutStatusCompletion: { ( state: PADCheckoutState, checkoutData: PADCheckoutData? ) in // Examine checkout state to determine the checkout result }) })Checkout Options
Section titled “Checkout Options”The Checkout is quite flexible and supports numerous configuration, pre-fill, and pricing options. These can be leveraged by passing a PADCheckoutOptions object to the Checkout.
Pre-fill Checkout Fields
Section titled “Pre-fill Checkout Fields”You can also pre-fill certain checkout fields such as the email and the postcode by setting their appropriate properties in the PADCheckoutOptions object.
// Create a new checkout options object and set the properties you want to pre-fillPADCheckoutOptions *options = [PADCheckoutOptions options];
options.email = @"example@email.com";options.country = @"GB";options.postcode = @"SE1";options.coupon = @"My-coupon";
// Pass the checkout options to the checkout.[Paddle.sharedInstance showCheckoutForProduct:product options:options checkoutStatusCompletion:nil];// Create a new checkout options object and set the properties you want to pre-filllet options = PADCheckoutOptions()
options.email = "example@email.com"options.country = "GB"options.postcode = "SE1"options.coupon = "My-coupon"
// Pass the checkout options to the checkout.paddle.showCheckout(for: product, options: options, checkoutStatusCompletion: nil)Additional checkout options that can be set directly on the PADCheckoutOptions object include:
quantityandallowQuantitydisableLogoutpassthroughlocaletitlemessage
Additional Parameters
Section titled “Additional Parameters”If you need to pass additional checkout parameters you can also use the PADCheckoutOptions.additionalCheckoutParameters property.
// Create a new checkout options object and set the custom parameters you require.PADCheckoutOptions *options = [PADCheckoutOptions options];
options.additionalCheckoutParameters = @{@"quantity": @32};
// Pass the checkout options to the checkout.[Paddle.sharedInstance showCheckoutForProduct:product options:options checkoutStatusCompletion:nil];// Create a new checkout options object and set the custom parameters you require.let options = PADCheckoutOptions()
options.additionalCheckoutParameters = ["quantity": 32]
// Pass the checkout options to the checkout.paddle.showCheckout(for: product, options: options, checkoutStatusCompletion: nil)This property accepts any JS parameter value from the Checkout Parameters used in the web version of the checkout.