ZSKit

final public class ZSKit : NSObject

The SDK will facilitate purchase with the app store. Any new purchase or changes to existing subscription will be automatically synced to your Zoho Billing organisation and will reflect in your metrics.

  • Call this method to initialize ZSInAppPurchaseKit. This is a one time initialization and has to be done before accessing other methods from the SDK.

    Declaration

    Swift

    public class func initialize(configuration: ZSConfiguration)

    Parameters

    configuration

    This configuration class contains the basic data used to make API calls to Zoho Billing’ server.

  • This method is used to get the array of plans that are applicable to the user. The resulting array will contain the plans that are active in both the app store and Zoho Billing. if you wish to block purchase of a particulate plan, you can mark it as inactive in Zoho Billing Dashboard.

    Declaration

    Swift

    public class func getPlans(completion: @escaping ZSPlansHandler)

    Parameters

    completion

    Returns array of applicable plans. It will returns an empty array if there are no active plans in Zoho Subscription or the App Store. If the call to subscription server or app store fails, it returns an error in the completion block.

  • This method is used to get the array of SKProducts from app store for given produt ids.

    Declaration

    Swift

    public class func getIAPProducts(productIDs: [String], completion: @escaping ZSIAPProductsHandler)

    Parameters

    productIDs

    The list of IAP product ids that need to be fetched from app store.

    completion

    Returns array of SKProduct objects. If the call to app store fails, it returns an error in the completion block.

  • This method initiates the purchasing process for the product passed as parameter. After user confirms the purchase, the in app purchase receipt gets validated in Zoho Subscription’s server. Then a new subscription is created in Zoho Billing if the user does not have any existing subscription running. In case the user already has an existing subscription, the current subscription will be upgraded or downgraded based on the current subscription.

    Declaration

    Swift

    public class func initiatePurchase(product: Product, customFields: [ZSCustomField] = [], completion: @escaping ZSPurchaseHandler)

    Parameters

    product

    The SKProduct of the plan selected by the user. It is provided in the ZSPlan object that you have got from the getPlans method.

    completion

    It will return the Subscription Info of the newly created/updated subscription. If the call to subscription server or app store fails, it returns an error in the completion block.

  • If a subscription is active in App Store and yet to be synced in Zoho Subscription, this method can be called. This method can be called while the user clicks on the ‘Restore’ button from the subscription screen.

    Declaration

    Swift

    public class func restorePurchase(customFields: [ZSCustomField] = [], completion: @escaping ZSPurchaseHandler)

    Parameters

    completion

    It will return the Subscription Info of the newly synced subscription. If the call to subscription server or app store fails, it returns an error in the completion block.

  • This method will sync every one of the current subscriptions to Zoho Billing. If a subscription is active in App Store and yet to be synced in Zoho Subscription, this method can be called. This method can be called while the user clicks on the ‘Restore’ button from the subscription screen. This will restore the subscription if not already synced. If already synced this will throws error mentioning that the purchase is already synced and throws if no active purchase available.

    Declaration

    Swift

    public class func restorePurchase(customFields: [ZSCustomField], completion: @escaping ZSRestorePurchaseHandler)

    Parameters

    completion

    It will return the Subscription Info of the newly synced subscription. If the call to subscription server or app store fails, it returns an error in the completion block.

  • If a subscription is active in App Store and yet to be synced in Zoho Subscription, this method can be called. This method can be called while the user clicks on the ‘Restore’ button from the subscription screen.

    Declaration

    Swift

    public class func restoreSubscription(transaction: Transaction, customFields: [ZSCustomField], completion: @escaping ZSPurchaseHandler)

    Parameters

    completion

    It will return the Subscription Info of the newly synced subscription. If the call to subscription server or app store fails, it returns an error in the completion block.

  • This method initiates the purchasing process for the product passed as parameter. After user confirms the purchase, the in app purchase receipt gets validated in Zoho Subscription’s server. Then a IAP product(consumable/non-consumable) record will be created in Zoho Billing. In case if there are multiple IAP products not synced in Zoho Billing all the products will be synced and sent in the completion.

    Declaration

    Swift

    public class func initiatePurchaseForIAPProduct(product: SKProduct, quantity: Int? = nil, completion: @escaping ZSIAPProductsPurchaseHandler)

    Parameters

    product

    The SKProduct of the plan selected by the user. It is provided in the ZSPlan object that you have got from the getPlans method.

    completion

    It will return the list of IAP Products created in Zoho Billing. If the call to subscription server or app store fails, it returns an error in the completion block.

  • If the user purchased IAP product in App Store and yet to be synced in Zoho Subscription, this method can be called. This method can be called while the user clicks on the ‘Restore’ button from the In-App Purchase products screen.

    Declaration

    Swift

    public class func restoreIAPProductsPurchase(completion: @escaping ZSIAPProductsPurchaseHandler)

    Parameters

    completion

    It will return the list of IAP Products created in Zoho Billing. If the call to subscription server or app store fails, it returns an error in the completion block.

  • Sets the delegate for ZSKit. Setting this delegate will enable the app to receive info about promocode applied in App Store. Once the promo code applied info is received, the SDK will intimate the app via a this delegate.

    Declaration

    Swift

    public class func setDelegate(delegate: ZSKitDelegate)

    Parameters

    delegate

    The Delegate will be responsible for handling promotional product purchases and changes in subscription details.

  • Undocumented

    Declaration

    Swift

    public class func isUserEligibleForIntroductoryOffer(product: Product) async -> Bool
  • Undocumented

    Declaration

    Swift

    public class func isUserEligibleForIntroductoryOffer(groupId: String) async -> Bool
  • Undocumented

    Declaration

    Swift

    public class func isStorePurchaseAssociatedWithCurrentUser(completion: @escaping ZSUserValidateHandler)
  • Undocumented

    Declaration

    Swift

    public class func getPurchaseMetadataFromStore() -> ZSFileAttachment?
  • Undocumented

    Declaration

    Swift

    public class func getCurrentEntitlements() async -> [Transaction]
  • Clear the user information from the sdk on sign out using this method.

    Declaration

    Swift

    public class func clearUserInfo()