Quick Start

This is a quick introduction into how to get up and running with PurchaseStacks SDK to start tracking your in app purchases.


Add a new app

PurchaseStacks dashboard offers an easy way to add a new application. One application is used for multiple platforms. Follow guide here.

Configure Products and Groups

App Store Connect provides the option to add products and if the products are of subscription type, you need to put them under a group. On Play Console, you do not need to configure them under any group.

We mirror the same behavior of App Store Connect for easier tracking of subscriptions both for android and iOS.

We provide one more layer of granularity through Packages for you to be able to price test or change which product is in display on the fly. Groups can have many packages and each package can have one active product from each store. This way you can deactivate one product and activate another on the fly. It enables you to change the product without changing your code.

See how to configure products and groups in detail here.

Product Groups

Configure SDK and Sync Products

To configure the SDK, you will need an API key and secret. You can get them from the dashboard inside the apps section. For more information check out the in-depth guide.

With the API key and secret, now you configure the SDK. As soon as you configure the SDK and launch the app, we will sync the products that you have configured in the PurchaseStacks dashboard. We will fetch relevant information including pricing from Apple or Google.

PSPurchase.config(withAPIKey: "API_KEY", withAPISecret: "API_SECRET")

Display Products

After you have configured the SDK, you can display the products you have enabled in the PurchaseStacks dashboard.

PSPurchase.shared.group { (groupsByName, error) in
if let groupsByName = groupsByName {
if let group = groupsByName["PREMIUM"] {
if let monthlyPackage = group.packageByName["Monthly"] {
showPaywall(monthlyPackage.activeProduct())
}
}
}
}

Make a Purchase

We have created one simple function that you can use to purchase and get the status of the transaction and all the groups if needed.

PFPurchase.shared.make(with: monthlyPackage) { (transaction, groupsByName, error, cancelled) in
if let groupsByName = groupsByName {
let group = groupsByName["PREMIUM"]
if (group.isActive) {
// Purchase is successful
}
}
}

Get Subscription Status

With this, you can check the current user's active subscriptions, purchase products, latest expiration date. You can use this method anytime to check the user's latest information.

PSPurchase.shared.groups { (groupsInfo, error) in
// groupsInfo contains all groups information
}
Congratulations! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰

Your purchase and subscription tracking system is fully configured. Now grab a cup of coffee and see your purchases right in the dashboard.