# requestPurchase

open fun requestPurchase(@NonNull activity: Activity, @NonNull gamebaseProductId: String, @NonNull callback: GamebaseDataCallback<PurchasableReceipt>)

Request Purchasing Item registered in the console with the gamebaseProductId.

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'
                // <a href="https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#purchase-flow">...</a>
                Gamebase.Purchase.requestItemListOfNotConsumed(...);
            } else {
                // Purchase flow is failed.
            }
        }
    });

Content copied to clipboard

#### Since

Added 2.11.0.

#### Parameters

activity

current Activity.

gamebaseProductId

registered in the Gamebase console.

callback

callback pass to API result.

#### See also

PurchasableReceipt
GamebaseDataCallback

open fun requestPurchase(@NonNull activity: Activity, @NonNull gamebaseProductId: String, @NonNull payload: String, @NonNull callback: GamebaseDataCallback<PurchasableReceipt>)

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.

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'
                // <a href="https://docs.toast.com/ko/Game/Gamebase/ko/aos-purchase/#purchase-flow">...</a>

                // Specify item with payload what you input
                String payloadResponse = data.payload;
                Gamebase.Purchase.requestItemListOfNotConsumed(...);
            } else {
                // Purchase flow is failed.
            }
        }
    });

Content copied to clipboard

#### Since

Added 2.11.0.

#### Parameters

activity

current Activity.

gamebaseProductId

registered in the Gamebase console.

payload

used to enter the information you want to check again on the receipt.

callback

callback pass to API result.

#### See also

PurchasableReceipt
GamebaseDataCallback

open fun requestPurchase(@NonNull activity: Activity, itemSeq: Long, @NonNull callback: GamebaseDataCallback<PurchasableReceipt>)

Request Purchasing Item that has itemSeq.

This is legacy purchase API. We recommend to use the new API requestPurchase.

#### Since

Added 1.4.0.

#### Parameters

activity

current Activity.

itemSeq

represent to item ID.

callback

callback pass to API result.

#### See also

PurchasableReceipt
GamebaseDataCallback