Platform behavior differences

The Ultimate Mobile combines API for a lot of different platforms.  We created a wrapper that allows you to implement InApps API only once, and it will work on all supported platforms.

However, you should know about the differences and possibilities on other platforms.

Android

Initialization

The initialization on Android is always successful, as Android billing API  is using a local cache. However, the attempt to purchase a product may be failed due to the connection issue. Also, you should keep in mind, that you will not get up to date user purchases info, you will get the local purchase cache stored by google on the device since last application launch.

Consume a product

There are no consumable or non-consumable product types. Starting from Android billing API v3 all products are managed (consumable)  which means that a developer is deciding by himself, to consume a product or not, after the product was purchased, based on product id. 

Once a product is purchased, it will be stored in the Android inventory. The same product can't be purchased while we have it in our inventory. So for example, if we need a consumable product logic, then we need to remove it from the inventory using a Consume method right after the product was purchased. After the product is consumed it will be available for purchase again. For a non-consumable product just do not use the Consume method.

So, now you understand that we had to add a Consume step to the general Ultimate Mobile Purchase Flow, so that to support Android. 

Developer Payload

If you want to implement the additional protecting level using the Developer Payload,  you may specify it as the additional parameter for the purchase.

Just use:

AndroidInAppPurchaseManager.Client.Purchase (YOUR_PRODUCT_ID, "Developer Payload");

instead of

UM_InAppPurchaseManager.Client.Purchase(YOUR_PRODUCT_ID);

Then you will get your payload back with the purchase result. Please, take a look at the UM_PurchaseResult class, you will see that with common purchase information it also containts a full result for a target platform. See example how to retrieve the payload below:

UM_InAppPurchaseManager.Client.OnPurchaseFinished += OnPurchaseFlowFinishedAction;
AndroidInAppPurchaseManager.Client.Purchase (YOUR_PRODUCT_ID, "Developer Payload");


void OnPurchaseFlowFinishedAction (UM_PurchaseResult result) {
	UM_InAppPurchaseManager.Client.OnPurchaseFinished -= OnPurchaseFlowFinishedAction;
	if(result.isSuccess) {
		Debug.Log ("Product " + result.product.id + " purchase Success");
		Debug.Log ("Payload: " + result.Google_PurchaseInfo.DeveloperPayload);
	} else  {
		Debug.Log ("Product " + result.product.id + " purchase Failed");
	}
}

 

 

iOS

The iOS platform has two main differences from the other platforms you need to know about.

Restore Purchases

If you have non-consumable products in your app, you have to implement the Restore Purchases feature. You also need to provide the Restore Purchases with your app UI. These are requirements of Apple for the applications with non-consumable products.

Please note that Restore Purchases feature will work only on iOS platform. You need to adjust your app UI accordingly. Only iOS platform UI should have that button.

Once restore flow has started, you will get the OnPurchaseFinished event for every product that was bought earlier by a user.

When restore flow is finished, the OnRestoreFinished will be fired. The code snippet below shows how to start purchase flow and subscribe to a complete event.

UM_InAppPurchaseManager.Client.OnRestoreFinished += OnRestoreFinished;
UM_InAppPurchaseManager.Client.RestorePurchases ();

void OnRestoreFinished (UM_BaseResult result) {
	if(result.IsSucceeded) {
		Debug.Log("Restore Fnished Successfully");
	} else {
		Debug.Log("Restore Fnished with error");
	}
}

Finish Transaction Manually

By default, the plugin will automatically finish the transaction after firing event with the transaction state. But if you work on a big project, you would probably want to finish transaction manually after making sure that a user has got what he paid for. In this case, you need to switch Transaction Handling Mode from Auto to Manual using plugin editor setting under the billing tab.

 

Now transaction will not be marked as finished until you call FinishTransaction method:

UM_InAppPurchaseManager.Client.FinishTransaction(YOUR_PRODUCT_ID);

So the common usage scenario with the manual transaction confirmation is:

  1. Player has bought an item.
  2. Transaction is completed with no errors action received. Please note that your player has already seen the StoreKit default purchase confirmation popup, and he has already charged.
  3. Connect to your server to validate the receipt, reward players with items.
  4. Manually finish the transaction on the device.