Gamebase SDK for Unity 2.69.0
Toast Gamebase Platform
Loading...
Searching...
No Matches

◆ SetPromotionIAPHandler()

static void SetPromotionIAPHandler ( GamebaseCallback::GamebaseDelegate< GamebaseResponse::Purchase::PurchasableReceipt > callback)
static

If you want to deliver some items that have been purchased to user, you should implement this handler.

You can receive a GamebaseResponse.Purchase.PurchasableReceipt object and receive whether error or success by callback. This API return same information with 'RequestPurchase' You should call this method after logged in, and you should call this before an other APIs in Gamebase.Purchase. This API can work on iOS11 or later.

Since
Added 1.13.0.
Parameters
callbackCallback may return the result of purchase by App Store Promotion.

Example Usage :

public void SetPromotionIAPHandlerSample()
{
Gamebase.Login(GamebaseAuthProvider.XXX, (authToken, error) =>
{
if (Gamebase.IsSuccess(error) == true)
{
Gamebase.Purchase.SetPromotionIAPHandler((purchasableReceipt, innerError) =>
{
if (Gamebase.IsSuccess(innerError) == true)
{
Debug.Log("SetPromotionIAPHandler succeeded");
var message = new StringBuilder();
message.AppendLine(string.Format("itemSeq:{0}", purchasableReceipt.itemSeq));
message.AppendLine(string.Format("price:{0}", purchasableReceipt.price));
message.AppendLine(string.Format("currency:{0}", purchasableReceipt.currency));
// You will need paymentSeq and purchaseToken when calling the Consume API.
// Refer to the following document for the Consume API.
// http://docs.toast.com/en/Game/Gamebase/en/api-guide/#purchaseiap
message.AppendLine(string.Format("paymentSeq:{0}", purchasableReceipt.paymentSeq));
message.AppendLine(string.Format("purchaseToken:{0}", purchasableReceipt.purchaseToken));
Debug.Log(message);
}
else
{
if (innerError.code == GamebaseErrorCode.PURCHASE_USER_CANCELED)
{
Debug.Log("User canceled purchase.");
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("SetPromotionIAPHandler failed. innerError is {0}", innerError));
}
}
});
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("Login failed. error is {0}", error));
}
});
}
static void Login(string providerName, GamebaseCallback.GamebaseDelegate< GamebaseResponse.Auth.AuthToken > callback)
Try to authenticate by specifying an IdP type.
Definition Gamebase.cs:611
The Gamebase class is core of Gamebase service.
Definition Gamebase.cs:11