API Reference

Script Reference

ISN_SKStoreReviewController

namespace SA.IOSNative.StoreKit
...

/// <summary>
/// Controls the process of requesting App Store ratings and reviews from users.
/// </summary>
public static class ISN_SKStoreReviewController  {
    /// <summary>
    /// Use the <see cref="RequestReview"/>  method to indicate when it makes sense 
    /// within the logic of your app to ask the user for ratings and reviews within your app.
    /// </summary>
    public static void RequestReview();
}

ISN_SKPaymentQueue

namespace SA.IOSNative.StoreKit
...

/// <summary>
/// A queue of payment transactions to be processed by the App Store.
/// 
/// The payment queue communicates with the App Store 
/// and presents a user interface so that the user can authorize payment. 
/// The contents of the queue are persistent between launches of your app.
/// </summary>
public static class ISN_SKPaymentQueue 
{   
    //--------------------------------------
    //  Public Methods
    //--------------------------------------
    /// <summary>
    /// Initializes the Store Kit with the set of perviosly defined product
    /// Products can be defined under the editor plugin settings: 
    /// Stan's Assets->IOS Native->Edit Settings
    /// Or you can add product's via code using <see cref="RegisterProduct"/>
    /// </summary>
    /// <param name="callback">Callback with the initialization result</param>
    public static void Init(Action<ISN_SKInitResult> callback);

    /// <summary>
    /// Adds an observer to the payment queue.
    /// 
    /// Your application should add an observer to the payment queue during 
    /// application initialization. 
    /// If there are no observers attached to the queue, the payment queue does 
    /// not synchronize its list 
    /// of pending transactions with the Apple App Store, 
    /// because there is no observer to respond to updated transactions.
    /// 
    /// If an application quits when transactions are still being processed, 
    /// those transactions are not lost. The next time the application launches, 
    /// the payment queue will resume processing the transactions. 
    /// Your application should always expect to be notified of completed transactions.
    /// 
    /// If more than one transaction observer is attached to the payment queue, 
    /// no guarantees are made as to the order they will be called in. 
    /// It is safe for multiple observers to call <see cref="FinishTransaction"/>, 
    /// but not recommended. 
    /// It is recommended that you use a single observer to process and 
    ///mfinish the transaction.
    /// </summary>
    /// <param name="observer">The observer to add to the queue.</param>
    public static void AddTransactionObserver(ISN_iSKPaymentTransactionObserver observer);

    /// <summary>
    /// Removes an observer from the payment queue.
    /// 
    /// If there are no observers attached to the queue, 
    /// the payment queue does not synchronize its list of pending transactions with 
    /// the Apple App Store, because there is no observer to respond to updated transactions.
    /// </summary>
    /// <param name="observer">The observer to remove.</param>
    public static void RemoveTransactionObserver(ISN_iSKPaymentTransactionObserver observer);

    /// <summary>
    /// Adds a payment request to the queue.
    /// 
    /// An application should always have at least one observer of the payment queue 
    /// before adding payment requests.
    /// The payment request must have a product identifier registered with the Apple App Store.
    /// 
    /// When a payment request is added to the queue, 
    /// the payment queue processes that request with the Apple App Store 
    /// and arranges for payment from the user. When that transaction is complete or if 
    /// a failure occurs, the payment queue sends the <see cref="ISN_SKPaymentTransaction"/> 
    /// object that encapsulates the request 
    /// to all transaction observers.
    /// </summary>
    /// <param name="productId">Product identifier.</param>
    public static void AddPayment(string productId);

    /// <summary>
    /// Completes a pending transaction.
    /// 
    /// Your application should call this method from a transaction observer 
    /// that received a notification from the payment queue. 
    /// Calling <see cref="FinishTransaction"/> on a transaction removes it from the queue. 
    /// Your application should call <see cref="FinishTransaction"/> only after 
    /// it has successfully processed the transaction and unlocked the functionality 
    /// purchased by the user.
    ///
    /// Calling <see cref="FinishTransaction"/> on a transaction that is in the Purchasing 
    /// state throws an exception.
    /// </summary>
    /// <param name="transaction">transaction to finish</param>
    public static void FinishTransaction(ISN_SKPaymentTransaction transaction);

    /// <summary>
    /// Asks the payment queue to restore previously completed purchases.
    /// 
    /// our application calls this method to restore transactions that were previously 
    /// finished so that you can process them again. 
    /// For example, your application would use this to allow a user to unlock previously 
    /// purchased content onto a new device.
    /// </summary>
    public static void RestoreCompletedTransactions();
            
    /// <summary>
    /// Gets the product by identifier.
    /// </summary>
    /// <returns>The product by identifier.</returns>
    /// <param name="productIdentifier">Prodcut identifier.</param>
    public static ISN_SKProduct GetProductById(string productIdentifier);

    /// <summary>
    /// Simplified product registration by the product identifier.
    /// You can also define products using editor plugin settings: 
    /// Stan's Assets->IOS Native->Edit Settings
    /// </summary>
    /// <param name="productId">Product identifier.</param>
    public static void RegisterProductId(string productId);

    /// <summary>
    /// Registers the product.
    /// You can also define products using editor plugin settings: 
    /// Stan's Assets->IOS Native->Edit Settings
    /// </summary>
    /// <param name="product">Product.</param>
    public static void RegisterProduct(ISN_SKProduct product);

    //--------------------------------------
    //  Get / Set
    //-------------------------------------
    
    /// <summary>
    /// Gets a value indicating whether this 
    /// <see cref="T:SA.IOSNative.StoreKit.Controllers.ISN_SKPaymentQueue"/> is ready.
    /// The ISN_SKPaymentQueue is ready once Init is completed successfully
    /// </summary>
    /// <value><c>true</c> if is ready; otherwise, <c>false</c>.</value>
    public static bool IsReady {get;}

    /// <summary>
    /// For an application purchased from the App Store, use this property 
    /// a to get the receipt. 
    /// This property makes no guarantee about whether there is a file at the URL—only 
    /// that if a receipt is present, that is its location.
    /// </summary>
    /// <returns>The app store receipt.</returns>
    public static ISN_SKAppStoreReceipt AppStoreReceipt {get;}


    /// <summary>
    /// A list of products, one product for each valid product identifier provided 
    /// in the original init request.
    /// only valid to use when <see cref="IsReady"/> is <c>true</c>
    /// </summary>
    public static List<ISN_SKProduct> Products {get;}

    /// <summary>
    /// Indicates whether the user is allowed to make payments.
    /// 
    /// An iPhone can be restricted from accessing the Apple App Store. 
    /// For example, parents can restrict their children’s ability to purchase 
    /// additional content. 
    /// Your application should confirm that the user is allowed to authorize payments 
    /// before adding a payment to the queue. 
    /// Your application may also want to alter its behavior or appearance 
    /// when the user is not allowed to authorize payments.
    /// </summary>
    /// <value><c>true</c> if can make payments; otherwise, <c>false</c>.</value>
    public static bool CanMakePayments {get;}
}

ISN_SKProductSubscriptionPeriod

namespace SA.IOSNative.StoreKit
{
	public class ISN_SKProductSubscriptionPeriod {
		/// <summary>
		/// The number of units per subscription period.
		/// </summary>
		public int NumberOfUnits {get;set;}

		/// <summary>
		/// The increment of time that a subscription period is specified in.
		/// </summary>
		public ISN_SKProductPeriodUnit Unit {get;set;}
	}
}

ISN_SKProductEditorData

namespace SA.IOSNative.StoreKit
...

public class ISN_SKProductEditorData 
{
    public Texture2D Texture;
    public ISN_SKPriceTier PriceTier = ISN_SKPriceTier.Tier1;
    public ISN_SKProductType ProductType = ISN_SKProductType.Consumable;
}

ISN_SKProductDiscount

namespace SA.IOSNative.StoreKit
...

public class ISN_SKProductDiscount 
{
    /// <summary>
    /// The discount price of the product in the local currency.
    /// </summary>
    public float Price {get;set;}

    /// <summary>
    /// The locale used to format the discount price of the product.
    /// </summary>
    public string PriceLocale {get;set;}

    /// <summary>
    /// The payment mode for this product discount.
    /// </summary>
    public ISN_SKPaymentMode PaymentMode {get;set;}

    /// <summary>
    /// An integer that indicates the number of periods the product discount is available.
    /// </summary>
    public int NumberOfUnits {get;set;}

    /// <summary>
    /// An object that defines the period for the product discount.
    /// </summary>
    public ISN_SKProductSubscriptionPeriod SubscriptionPeriod {get;set;}

    /// <summary>
    /// Gets or sets the currency symbol.
    /// </summary>
    public string CurrencySymbol {get;set;}

    /// <summary>
    /// The locale used to format the price of the product.
    /// </summary>
    public string LocalizedPrice {get;set;}
}

ISN_SKProduct

namespace SA.IOSNative.StoreKit
...

public class ISN_SKProduct  {
    /// <summary>
    /// The string that identifies the product to the Apple App Store.
    /// </summary>
    public string ProductIdentifier {get;set;}

    /// <summary>
    /// A description of the product.
    /// </summary>
    public string LocalizedDescription {get;set;}

    /// <summary>
    /// The name of the product.
    /// </summary>
    public string LocalizedTitle {get;set;}

    /// <summary>
    /// The cost of the product in the local currency.
    /// </summary>
    public float Price {get;set;}

    /// <summary>
    /// The locale used to format the price of the product.
    /// </summary>
    public string PriceLocale {get;}

    /// <summary>
    /// The object containing introductory price information for the product.
    /// </summary>
    public ISN_SKProductDiscount IntroductoryPrice {get;}

    /// <summary>
    /// The period details for products that are subscriptions.
    /// </summary>
    public ISN_SKProductSubscriptionPeriod SubscriptionPeriod {get;}

    

    /// <summary>
    /// Gets the price in micros.
    /// </summary>
    public long PriceInMicros {get;}

    /// <summary>
    /// The locale used to format the price of the product.
    /// </summary>
    public string LocalizedPrice {get;}

    /// <summary>
    /// Gets or sets the currency symbol.
    /// </summary>
    public string CurrencySymbol {get;}

    /// <summary>
    /// Gets or sets the currency code.
    /// </summary>
    public string CurrencyCode {get;}


    //--------------------------------------
    // ISN_SKProductEditorData
    //--------------------------------------

    /// <summary>
    /// Type of the product 
    /// </summary>
    public ISN_SKProductType Type {get;set;}

    /// <summary>
    /// Gets icon of the product
    /// </summary>
    public Texture2D Texture {get;set;}

    /// <summary>
    /// Gets and updates Price Tier
    /// </summary>
    public ISN_SKPriceTier PriceTier {get;set;}

    /// <summary>
    /// Contains data that is only can be set using the Edito Plugin Settings
    /// </summary>
    public ISN_SKProductEditorData EditorData {get;set;}
}

ISN_SKPaymentTransaction

namespace SA.IOSNative.StoreKit 
...

public class ISN_SKPaymentTransaction : SA_Result
{
    public ISN_SKPaymentTransaction(ISN_SKProduct product, ISN_SKPaymentTransactionState state);

    /// <summary>
    /// A string used to identify a product that can be purchased from within your application.
    /// </summary>
    public string ProductIdentifier {get;}

    /// <summary>
    /// A string that uniquely identifies a successful payment transaction.
    /// 
    /// The contents of this property are undefined except when <see cref="State"/> 
    /// is set to <see cref="ISN_SKPaymentTransactionState.Purchased"/> 
    /// or <see cref="ISN_SKPaymentTransactionState.Restored"/>. 
    /// The transactionIdentifier is a string that uniquely identifies the processed payment. 
    /// Your application may wish to record this string as part of an audit trail 
    /// for App Store purchases. 
    /// </summary>
    public string TransactionIdentifier {get;}

    /// <summary>
    /// The date the transaction was added to the App Store’s payment queue.
    /// 
    /// The contents of this property are undefined except when <see cref="State"/> 
    /// is set to <see cref="ISN_SKPaymentTransactionState.Purchased"/> 
    /// or <see cref="ISN_SKPaymentTransactionState.Restored"/>.
    /// </summary>
    public DateTime Date {get;}

    /// <summary>
    /// An object describing the error that occurred while processing the transaction.
    /// </summary>
    public ISN_SKPaymentTransactionState State {get;}

    /// <summary>
    /// Gets the associated product with this transaction.
    /// </summary>
    public ISN_SKProduct Product {get;}

    /// <summary>
    /// The transaction that was restored by the App Store.
    /// 
    /// The contents of this property are undefined except when <see cref="State"/> 
    /// is set to <see cref="ISN_SKPaymentTransactionState.Restored"/>. 
    /// When a transaction is restored, the current transaction holds a new transaction 
    /// identifier, receipt, and so on. 
    /// Your application will read this property to retrieve the restored transaction.
    /// </summary>
    /// <value>The original transaction.</value>
    public ISN_SKPaymentTransaction OriginalTransaction {get;}
}

ISN_SKInitResult

namespace SA.IOSNative.StoreKit
...

public class ISN_SKInitResult : SA_Result
{
    public ISN_SKInitResult(List<ISN_SKProduct> products);

    public ISN_SKInitResult(SA_Error error) : base(error);

    /// <summary>
    /// A list of products, one product for each valid product identifier provided 
    /// in the original request.
    /// </summary>
    public List<ISN_SKProduct> Products {get;}

    /// <summary>
    /// An array of product identifier strings that were not recognized by the App Store.
    /// </summary>
    public List<string> InvalidProductIdentifiers {get;}
}

ISN_SKAppStoreReceipt

namespace SA.IOSNative.StoreKit
...

/// <summary>
/// App Store receipt.
/// </summary>
public class ISN_SKAppStoreReceipt
{
    public ISN_SKAppStoreReceipt(string data);

    /// <summary>
    /// The receipt data
    /// </summary>
    public byte[] Data {get;}

    /// <summary>
    /// The receipt data represented as Base64String
    /// </summary>
    public string AsBase64StringString {get;}
}

TransactionErrorCode

namespace SA.IOSNative.StoreKit.Enum
...

public enum TransactionErrorCode  {
    SKErrorUnknown = 0,

    // client is not allowed to issue the request, etc.
    SKErrorClientInvalid = 1,    

    // user canceled the request, etc.           
    SKErrorPaymentCanceled = 2,

    // purchase identifier was invalid, etc.
    SKErrorPaymentInvalid = 3,      

    // this device is not allowed to make the payment 
    SKErrorPaymentNotAllowed = 4,       

    // Product is not available in the current storefront
    SKErrorStoreProductNotAvailable = 5,    

    // No purchases to restore"
    SKErrorPaymentNoPurchasesToRestore = 6,  

    //StoreKit initialization required
    SKErrorPaymentServiceNotInitialized = 7,  

    //No error occurred
    SKErrorNone = 8 
}

ISN_SKProductPeriodUnit

/// <summary>
/// Values representing the duration of an interval, from a day up to a year.
/// </summary>
public enum ISN_SKProductPeriodUnit
{
    Day = 0,     //An interval lasting one day.
    Week = 1,    //An interval lasting one month.
    Month = 2,   //An interval lasting one week.
    Year = 3     //An interval lasting one year.
}

ISN_SKPriceTier

namespace SA.IOSNative.StoreKit
...
public enum ISN_SKPriceTier  {
    Tier1,
    Tier2,
    Tier3,
    Tier4,
    Tier5,
    Tier6,
    Tier7,
    Tier8,
    Tier9,
    Tier10,
    Tier11,
    Tier12,
    Tier13,
    Tier14,
    Tier15,
    Tier16,
    Tier17,
    Tier18,
    Tier19,
    Tier20,
    Tier21,
    Tier22,
    Tier23,
    Tier24,
    Tier25,
    Tier26,
    Tier27,
    Tier28,
    Tier29,
    Tier30,
    Tier31,
    Tier32,
    Tier33,
    Tier34,
    Tier35,
    Tier36,
    Tier37,
    Tier38,
    Tier39,
    Tier40,
    Tier41,
    Tier42,
    Tier43,
    Tier44,
    Tier45,
    Tier46,
    Tier47,
    Tier48,
    Tier49,
    Tier50,
    Tier51,
    Tier52,
    Tier53,
    Tier54,
    Tier55,
    Tier56,
    Tier57,
    Tier58,
    Tier59,
    Tier60,
    Tier61,
    Tier62,
    Tier63,
    Tier64,
    Tier65,
    Tier66,
    Tier67,
    Tier68,
    Tier69,
    Tier70,
    Tier71,
    Tier72,
    Tier73,
    Tier74,
    Tier75,
    Tier76,
    Tier77,
    Tier78,
    Tier79,
    Tier80,
    Tier81,
    Tier82,
    Tier83,
    Tier84,
    Tier85,
    Tier86,
    Tier87
}

ISN_SKPaymentTransactionState

namespace SA.IOSNative.StoreKit
...

/// <summary>
/// Values representing the state of a transaction.
/// </summary>
public enum ISN_SKPaymentTransactionState
{
    // Transaction is being added to the server queue.
    Purchasing = 0,    

    // Transaction is in queue, user has been charged.  Client should complete the transaction.
    Purchased = 1,     

    // Transaction was cancelled or failed before being added to the server queue.
    Failed = 2,    

    // Transaction was restored from user's purchase history.  Client should complete the transaction.
    Restored = 3,      
    Deferred = 4
}

ISN_SKPaymentMode

namespace SA.IOSNative.StoreKit
...

/// <summary>
/// Values representing the payment modes for a product discount
/// </summary>
public enum ISN_SKPaymentMode
{
    //A constant indicating that the payment mode of a product discount is billed over a 
    //single or multiple billing periods.
    SKProductDiscountPaymentModePayAsYouGo = 1, 

    //A constant indicating that the payment mode of a product discount is paid up front.
    SKProductDiscountPaymentModePayUpFront = 2, 

    //A constant that indicates that the payment mode is a free trial.
    SKProductDiscountPaymentModeFreeTrial = 3   
}

ISN_SKProductType

namespace SA.IOSNative.StoreKit
...

public enum ISN_SKProductType  {
    //A product that is used once, after which it becomes depleted and must be purchased again.
    //Example: Fish food for a fishing app.
    Consumable,

    //A product that is purchased once and does not expire or decrease with use.
    //Example: Race track for a game app.
    NonConsumable,

    //A product that allows users to purchase a service with a limited duration. T
    //The content of this in-app purchase can be static. This type of subscription does 
    //not renew automatically.
    //Example: One-year subscription to a catalog of archived articles.
    NonRenewingSubscription
}