API Reference

Script Reference

PaymentManager

namespace SA.IOSNative.StoreKit {
	public class PaymentManager : SA.Common.Pattern.Singleton<PaymentManager> {

		public const string APPLE_VERIFICATION_SERVER;
		public const string SANDBOX_VERIFICATION_SERVER;

		//--------------------------------------
		//  Actions
		//--------------------------------------
		
		public static event Action<SA.Common.Models.Result> OnStoreKitInitComplete;

		public static event Action OnRestoreStarted;
		public static event Action<RestoreResult> OnRestoreComplete;

		public static event Action<string> OnTransactionStarted;
		public static event Action<PurchaseResult> OnTransactionComplete;

		public static event Action<VerificationResponse> OnVerificationComplete;

		//--------------------------------------
		//  PUBLIC METHODS
		//--------------------------------------

		public void LoadStore();

		public void AddProductId(string productId);
		public void AddProduct(Product product)
		public Product GetProductById(string prodcutId);
		public void RegisterProductView(StoreProductView view);

		public void BuyProduct(string productId);
		public void FinishTransaction(string productId);
		public void RestorePurchases();
		public void VerifyLastPurchase(string url);
		
		//--------------------------------------
		//  GET/SET
		//--------------------------------------

		public List<Product> Products {get;}
		public bool IsStoreLoaded {get;}
		public bool IsInAppPurchasesEnabled {get;}
		public bool IsWaitingLoadResult {get;}
	}
}

StoreProductView

namespace SA.IOSNative.StoreKit {
	public class StoreProductView {

		//--------------------------------------
		//  Actions
		//--------------------------------------

		public event Action Loaded;
		public event Action LoadFailed;
		public event Action Appeared;
		public event Action Dismissed;

		//--------------------------------------
		// CONSTRUCTOR
		//--------------------------------------

		public StoreProductView();
		public StoreProductView(params string[] ids);

		//--------------------------------------
		// PUBLIC METHODS
		//--------------------------------------

		public void addProductId(string productId);
		public void Load();
		public void Show();
		
		//--------------------------------------
		// GET / SET
		//--------------------------------------

		public int Id {get;}	
	}
}

Product

namespace SA.IOSNative.StoreKit {
	public class Product  {
		public string Id {get;}
		public string DisplayName {get;}
		public string Description {get;}
		public ProductType Type {get;}
		public float Price {get;}
		public int PriceInMicros {get;}
		public string LocalizedPrice {get;}
		public string CurrencySymbol {get;}
		public string CurrencyCode {get;}
		public Texture2D Texture {get;}
		public PriceTier PriceTier {get;}
		public bool IsAvailable {get;}
	}
}

PurchaseResult

namespace SA.IOSNative.StoreKit {
	public class PurchaseResult : SA.Common.Models.Result  {

		//--------------------------------------
		// Get / Set
		//--------------------------------------

		public TransactionErrorCode TransactionErrorCode {get;}
		public PurchaseState State  {get;}
		public string ProductIdentifier  {get;}
		public string ApplicationUsername  {get;}
		public string Receipt  {get;}
		public string TransactionIdentifier  {get;}
	}
}

RestoreResult

namespace SA.IOSNative.StoreKit {
	public class RestoreResult : SA.Common.Models.Result {
		public TransactionErrorCode TransactionErrorCode {get;}
	}
}

VerificationResponse

namespace SA.IOSNative.StoreKit {
	public class VerificationResponse  {
		public int Status {get;}
		public string Receipt {get;}
		public string ProductIdentifier {get;}
		public string OriginalJSON {get;}
	}
}

PurchaseState

namespace SA.IOSNative.StoreKit {
	public enum PurchaseState {
		Purchased,
		Failed,
		Deferred,
		Restored
	}
}

TransactionErrorCode

namespace SA.IOSNative.StoreKit {
	public enum TransactionErrorCode  {

		SKErrorUnknown = 0,
		SKErrorClientInvalid = 1,                //not allowed to issue the request.
		SKErrorPaymentCanceled = 2,              //user canceled the request, etc.
		SKErrorPaymentInvalid = 3,               //purchase identifier was invalid, etc.
		SKErrorPaymentNotAllowed = 4,            //device is not allowed to make the payment
		SKErrorStoreProductNotAvailable = 5,     // not available in the current storefront
		SKErrorPaymentNoPurchasesToRestore = 6,  // No purchases to restore"
		SKErrorPaymentServiceNotInitialized = 7, //StoreKit initialization required
		SKErrorNone = 8                          //No error occurred
	}
}