EN CN
The Samsung IAP Unity plugin comes with all the content necessary for your integration.
The Plugins folder contains all Samsung IAP related scripts and libraries. Menu Scene is the Unity scene that demonstrates all the functionality of the Samsung IAP Unity plugin.
This section explains how to use Samsung In-App Purchase (IAP) functionality by integrating the Samsung IAP Unity Engine Plugin methods.
To avoid compatibility issues, the plugin requires the following SDKs:
To import the Samsung IAP Unity plugin into your project, in Unity click Assets -> Import Package.
This section explains the fundamental aspects of integrating Samsung IAP functionality into your Android app by making plugin method calls to support the offering and sale of in-app items.
Drag-and-drop the Samsung IAP script into the GameObject of your choice.
During app development and testing:
For beta release:
For validation testing and for normal release:
Sample code:
SamsungIAP.Instance.SetOperationMode(OperationMode.OPERATION_MODE_TEST);
Use the GetProductsDetails() method to get detailed information (for example, item ID, price, and description) about some or all of the in-app items registered to your app that are available for user purchase:
//Get information about three in-app items SamsungIAP.Instance.GetProductsDetails("com.mygame.product1, com.mygame.product2, com.mygame.product3", OnGetProductsDetails); //Get information about all in-app items SamsungIAP.Instance.GetProductsDetails("", OnProductsDetails);
After processing is complete, the OnGetProductsDetails callback is triggered, which contains information about the specified items and API call processing.
Use the StartPayment() method to initiate a purchase and payment transaction for a specified in-app item.
You can specify your own pass-through parameter and use it for purchase and payment verification.
SamsungIAP.Instance.StartPayment("com.mygame.product1", "pass_through_value", OnPayment);
After processing is complete, the OnPayment callback is triggered, which contains information about the purchased item, the transaction, and API call processing.
Use the ConsumePurchasedItems() method and the purchase ID of a consumable in-app item to enable it to be purchased again (whether or not the user has actually used the item).
Your app receives an item's purchase ID in the OnPayment and OnGetOwnedList callbacks. Sample code:
SamsungIAP.Instance.ConsumePurchasedItems(purchase_id, OnConsume);
After processing is complete, the OnConsume callback is triggered, which contains information about the consumed item and API call processing.
Use the GetOwnedList() method to get information about some or all of the items the user has already purchased:
SamsungIAP.Instance.GetOwnedList(ItemType.all, OnGetOwnedList);
After processing is complete, the OnGetOwnedList callback is triggered, which contains information about the specified purchased items and API call processing.