Gamebase SDK for Android  2.17.1
Toast Gamebase Platform
Gamebase.Purchase Class Reference

This class provides wrapping of function execution related to payment. More...

Collaboration diagram for Gamebase.Purchase:
Collaboration graph

Static Public Member Functions

static void requestPurchase (@NonNull final Activity activity, @NonNull final String gamebaseProductId, @NonNull final GamebaseDataCallback< PurchasableReceipt > callback)
 Request Purchasing Item registered in the console with the gamebaseProductId. More...
 
static void requestPurchase (@NonNull final Activity activity, @NonNull final String gamebaseProductId, @NonNull final String payload, @NonNull final GamebaseDataCallback< PurchasableReceipt > callback)
 Request Purchasing Item registered in the console with the gamebaseProductId. More...
 
static void requestPurchase (@NonNull final Activity activity, final long itemSeq, @NonNull final GamebaseDataCallback< PurchasableReceipt > callback)
 Request Purchasing Item that has itemSeq. More...
 
static void requestItemListPurchasable (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< List< PurchasableItem >> callback)
 Request a item list which is purchasable. More...
 
static void requestItemListAtIAPConsole (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< List< PurchasableItem >> callback)
 Request a item list which is purchasable. More...
 
static void requestItemListOfNotConsumed (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< List< PurchasableReceipt >> callback)
 Request a Item List which is not consumed. More...
 
static void requestActivatedPurchases (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< List< PurchasableReceipt >> callback)
 Request a list of payment products that are currently subscribed. More...
 
static void requestRetryTransaction (@NonNull final Activity activity, @NonNull final GamebaseDataCallback< PurchasableRetryTransactionResult > callback)
 'Deprecated API'. More...
 
static String getStoreCode ()
 Gets the store code of the current app. More...
 
static void setStoreCode (final String storeCode)
 Set the store code of the current app. More...
 

Detailed Description

This class provides wrapping of function execution related to payment.

Member Function Documentation

◆ getStoreCode()

static String getStoreCode ( )
static

Gets the store code of the current app.

This should only be called after the SDK has been initialized by calling Gamebase.initialize().

Since
Added 1.4.0.
Deprecated:
As of release 2.6.0, Changing the storeCode in runtime is no longer supported.
Returns
The store code.
Here is the call graph for this function:

◆ requestActivatedPurchases()

static void requestActivatedPurchases ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< List< PurchasableReceipt >>  callback 
)
static

Request a list of payment products that are currently subscribed.

If there is a subscription purchased from another platform (such as iOS), the itemSeq value is returned as -1.

Since
Added 2.6.0.
Parameters
activitycurrent Activity.
callbackcallback pass to API result.
See also
com.toast.android.gamebase.base.purchase.PurchasableReceipt.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestItemListAtIAPConsole()

static void requestItemListAtIAPConsole ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< List< PurchasableItem >>  callback 
)
static

Request a item list which is purchasable.

This list has items which are only registered in ToastCloud IAP Console, not Market(Google, OneStore)

Since
Added 1.4.0.
Parameters
activitycurrent Activity.
callbackcallback pass to API result.
See also
com.toast.android.gamebase.base.purchase.PurchasableItem.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestItemListOfNotConsumed()

static void requestItemListOfNotConsumed ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< List< PurchasableReceipt >>  callback 
)
static

Request a Item List which is not consumed.

You should deliver this itemReceipt info to your game-server to consume it or request consumeAPI to ToastCloud IAP Server.

'Important' : This API is used to retry transaction. See follow guide : https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#retry-transaction-flow Call this API for retry transaction next situations:

Since
Added 1.4.0.
Parameters
activitycurrent Activity.
callbackcallback pass to API result.

Example Usage:

Gamebase.Purchase.requestItemListOfNotConsumed(activity, new GamebaseDataCallback<List<PurchasableReceipt>>() {
@Override
public void onCallback(List<PurchasableReceipt> data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// succeeded.
for (PurchasableReceipt receipt : data) {
// Send userId, gamebaseProductId, paymentSeq, purchaseToken to game server
// and process 'Consume Flow'.
// See follow guide:
// https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#consume-flow
String userId = Gamebase.getUserID();
String gamebaseProductId = receipt.gamebaseProductId;
String paymentSeq = receipt.paymentSeq;
String purchaseToken = receipt.purchaseToken;
// You can extract 'payload' what you entered.
String payload = receipt.payload;
}
} else {
// failed.
}
}
});
See also
com.toast.android.gamebase.base.purchase.PurchasableReceipt.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestItemListPurchasable()

static void requestItemListPurchasable ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< List< PurchasableItem >>  callback 
)
static

Request a item list which is purchasable.

This list has items which are registered in both Market(AppStore) and ToastCloud IAP Console.

Since
Added 1.4.0.
Parameters
activitycurrent Activity.
callbackcallback pass to API result.
See also
com.toast.android.gamebase.base.purchase.PurchasableItem.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestPurchase() [1/3]

static void requestPurchase ( @NonNull final Activity  activity,
@NonNull final String  gamebaseProductId,
@NonNull final GamebaseDataCallback< PurchasableReceipt callback 
)
static

Request Purchasing Item registered in the console with the gamebaseProductId.

Since
Added 2.11.0.
Parameters
activitycurrent Activity.
gamebaseProductIdregistered in the Gamebase console.
callbackcallback pass to API result.

Example Usage:

Gamebase.Purchase.requestPurchase(activity, "productId", new GamebaseDataCallback<PurchasableReceipt>() {
@Override
public void onCallback(PurchasableReceipt data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Purchase flow is succeeded.
// Call Gamebase.Purchase.requestItemListOfNotConsumed() API and process 'Consume Flow'
// https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#purchase-flow
Gamebase.Purchase.requestItemListOfNotConsumed(...);
} else {
// Purchase flow is failed.
}
}
});
See also
com.toast.android.gamebase.base.purchase.PurchasableReceipt.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestPurchase() [2/3]

static void requestPurchase ( @NonNull final Activity  activity,
@NonNull final String  gamebaseProductId,
@NonNull final String  payload,
@NonNull final GamebaseDataCallback< PurchasableReceipt callback 
)
static

Request Purchasing Item registered in the console with the gamebaseProductId.


The value entered in the payload can be checked again in the PurchasableReceipt.payload, so it can be used as a method of classifying item payment according to the game server channel and character.

Since
Added 2.11.0.
Parameters
activitycurrent Activity.
gamebaseProductIdregistered in the Gamebase console.
payloadused to enter the information you want to check again on the receipt.
callbackcallback pass to API result.

Example Usage:

String payload = "{\"gameServer\":\"Server01\",\"characterId\":\"abcd001\"}";
Gamebase.Purchase.requestPurchase(activity, "productId", payload, new GamebaseDataCallback<PurchasableReceipt>() {
@Override
public void onCallback(PurchasableReceipt data, GamebaseException exception) {
if (Gamebase.isSuccess(exception)) {
// Purchase flow is succeeded.
// Call Gamebase.Purchase.requestItemListOfNotConsumed() API and process 'Consume Flow'
// https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#purchase-flow
// Specify item with payload what you input
String payloadResponse = data.payload;
Gamebase.Purchase.requestItemListOfNotConsumed(...);
} else {
// Purchase flow is failed.
}
}
});
See also
com.toast.android.gamebase.base.purchase.PurchasableReceipt.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestPurchase() [3/3]

static void requestPurchase ( @NonNull final Activity  activity,
final long  itemSeq,
@NonNull final GamebaseDataCallback< PurchasableReceipt callback 
)
static

Request Purchasing Item that has itemSeq.

This is legacy purchase API. We recommend to use the new API Purchase#requestPurchase(Activity, String, GamebaseDataCallback).

Since
Added 1.4.0.
Parameters
activitycurrent Activity.
itemSeqrepresent to item ID.
callbackcallback pass to API result.
See also
com.toast.android.gamebase.base.purchase.PurchasableReceipt.
com.toast.android.gamebase.GamebaseDataCallback.

◆ requestRetryTransaction()

static void requestRetryTransaction ( @NonNull final Activity  activity,
@NonNull final GamebaseDataCallback< PurchasableRetryTransactionResult callback 
)
static

'Deprecated API'.

This API is not work anymore.
Processes incomplete purchases. Request a retrying transaction which is not completed to IAP Server

Since
Added 1.4.0.
Deprecated:
As of release 2.6.0, You don't need to call this API anymore.
Parameters
activitycurrent Activity.
callbackcallback pass to API result.
See also
com.toast.android.gamebase.base.purchase.PurchasableRetryTransactionResult.
com.toast.android.gamebase.GamebaseDataCallback.

◆ setStoreCode()

static void setStoreCode ( final String  storeCode)
static

Set the store code of the current app.

Since
Added 1.4.0.
Deprecated:
As of release 2.6.0, changing the storeCode in runtime is no longer supported. You can set storeCode with GamebaseConfiguration#newBuilder(String, String, String) method only.
Parameters
storeCodeInput store code.
Here is the call graph for this function: