Coding Guidelines

Current version of InAppPurchases - v.2.0. 

Note: Amazon Native don`t supports InAppPurchases v.1.0.

Maker sure that InApp purchases Setup Guide is complete.

Before using inApp API, we need to init SA_AmazonBillingManager. We can also subscript for alavalible events before intiing.



After init call we will get folliwing actions fired:

public Action<AMN_GetUserDataResponse> OnGetUserDataReceived = delegate {};
public Action<AMN_PurchaseResponse> OnPurchaseProductReceived = delegate {};
public Action<AMN_GetProductDataResponse> OnGetProductDataReceived = delegate {};
public Action<AMN_GetPurchaseProductsUpdateResponse> OnGetPurchaseProductsUpdatesReceived = delegate {};	


So it's good practice to subscribe on it before initializing SA_AmazonBillingManager, as we already did. Here is parse example of those events.


OnGetPurchaseProductsUpdatesReceived action will tell us about on previously purchased merchandise type Entitlements or Subscriptions and provide info about them.

void OnGetPurchaseProductsUpdatesReceived (AMN_GetPurchaseProductsUpdateResponse result) {
		string _requestId 	= result.RequestId;
		string _userId		= result.UserId;
		string _marketplace = result.Marketplace;
		string _status 	    = result.Status;
		bool _hasMore 	    = result.HasMore;

        listReceipts = SA_AmazonBillingManager.instance.listReceipts;

		foreach(SA_AmazonReceipt receipt in listReceipts) {
			string _sku         = receipt.Sku;
			string _productType = receipt.ProductType;
			string _receiptId   = receipt.ReceiptId;
			long _purchaseDate  = receipt.PurchaseDate;
			long _cancelDate    = receipt.CancelDate;


Note: It will provide info only about non-consumables purchases.

Note: The info will be provided only once. Means you will get it only right after purchase or if you  run application for the firt time on new device. Or if you will clean up your application data as showd on screenshot bellow:




The plugin handles saving purchased products using PlayerPrefs and you will able to rertive all purchased products anytime.

This code snipped show how to print list of all purchased non-consumable products

private List<string> entitlements = AMN_PlayerData.GetAvailableSKUs ();


Warning: Since plugin stores all products information in PlayerPrefs, be aware of using PlayerPrefs.DeleteAll in production, because it will destroy all information about purchased non-consumable products.


PlayerData has two methods that save and retrieve information about your entitlements items at method Awake() and after successfully purchasing adding a new item.

public static void AddNewSKU (string SKU) {
	string entitlements;

	if (PlayerPrefs.HasKey (ENTITLEMENTS)) {
		entitlements = PlayerPrefs.GetString(ENTITLEMENTS);

		entitlements += SKU + DATA_SPLITTER;
	else {
		entitlements = SKU + DATA_SPLITTER;

	PlayerPrefs.SetString(ENTITLEMENTS, entitlements);
public static List<string> GetAvailableSKUs () {
	List<string> list = new List<string> ();

	if (PlayerPrefs.HasKey (ENTITLEMENTS)) {
		string entitlements = PlayerPrefs.GetString(ENTITLEMENTS);

		string[] storeData = entitlements.Split(DATA_SPLITTER[0]);

		for(int i = 0; i < storeData.Length; i++) {

	return list;


OnGetProductDataReceived action will tell us about avaliable items and provide info about them.

	void OnGetProductDataReceived (AMN_GetProductDataResponse result) {
		isInitialized = true;

		string requestId = result.RequestId;
		string status = result.Status;

		availableItems  = SA_AmazonBillingManager.instance.availableItems;			
		unavailableSkus = SA_AmazonBillingManager.instance.unavailableSkus;


And we also can get current user info by parsing OnGetUserDataReceived action result:

void OnGetUserDataReceived(AMN_GetUserDataResponse result) {
	string requestId   = result.RequestId;
	string userId 	   = result.UserId;
	string marketplace = result.Marketplace;
	string status      = result.Status;



Now we ready to make the purchase. All you need to do is to call buyProduct function with product id you whant to buy. Below shows the code where it checks for the availability of the item purchase with the type of Entitlement. Therefore, to purchase ordinary items you must upgrade code under your project by removing the checking on the contents of the list of Entitlements.

private void Purchase() {
	if(entitlements.Contains(SKU_EXAMPLE)) {
		Debug.Log("Already buyed!");
	SA_AmazonBillingManager.instance.Purchase (SKU_EXAMPLE);


When purchase flow if finsihed, the OnPurchaseReceived action will be fired. Here is action result parse example:

void OnPurchaseProductReceived (AMN_PurchaseResponse result) {
	string _requestId   = result.RequestId;
	string _userId 	    = result.UserId;
	string _marketplace = result.Marketplace;
	string _receiptId   = result.ReceiptId;
	long _cancelDate    = result.CancelDate;
	long _purchaseDate  = result.PurchaseDatee;
	string _sku         = result.Sku;
	string _productType = result.ProductType;
	string _status      = result.Status;

The full implementation example can be found under SA_AmazonBillingExample.cs script