en zh

Unity Plugin for Samsung IAP 6.3.0

SamsungIAP_unity_plugin_v6.3.0.unitypackage
(225KB) Mar 19, 2025

The Samsung IAP Unity Plugin comes with all the content necessary for your integration.

Integrate Samsung IAP into Your App

This section explains how to use Samsung In-App Purchase (IAP) functionality by integrating the Samsung IAP Unity Plugin.

System Requirements

To avoid compatibility issues, the plugin requires the following tools:

Import Samsung IAP Plugin

  1. Download the plugin file.
  2. In Unity, click Assets → Import Package → Custom Pacakge...
  3. Check Plugins folder which contains all Samsung IAP related scripts and libraries.

Implement Samsung IAP

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.

Samsung IAP Script

Drag-and-drop the SamsungIAP script into the GameObject of your choice.

Set the IAP Operation Mode

Use the SetOperationMode() method to set the operation mode.

Mode

Description

OPERATION_MODE_PRODUCTION

StartPayment() requests are processed as specified, financial transactions do occur for successful requests, and actual results are returned (successful or failed).

Note: For all other IAP requests:
  • Only items purchased in OPERATION_MODE_PRODUCTION mode are considered owned items.

OPERATION_MODE_TEST

StartPayment() requests are processed as specified, except financial transactions do not occur (licensed testers are not billed for item purchases), and successful results are always returned.
For details of the payment window shown in OPERATION_MODE_TEST mode, see the payment window .

Note: For all other IAP requests:
  • Only items purchased in OPERATION_MODE_TEST mode are considered owned items.
  • In order to purchase in-app items, testers must be registered as a License Tester in the seller's Seller Portal profile. In this mode, licensed testers always get your in-app items for free. All other users see an error message if they try to purchase an in-app item.

OPERATION_MODE_TEST_FAILURE

All IAP requests fail.
It is meant to be negative testing to ensure that your app can handle errors such as improper input and user actions.

Code snippet
SamsungIAP.Instance.SetOperationMode(OperationMode.OPERATION_MODE_TEST);

Get user-owned items

Use the GetOwnedList() method to get information about some or all of the items the user has already purchased:

Product Type

Description

item

Returns all purchased non-consumable items, consumable items that have not been consumed

subscription

Returns all active subscription items

all

Returns all purchased non-consumable items, consumable items that have not been consumed and active subscription items

Code snippet
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.

Get in-app item details

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:

  • Specify one or more unique in-app item ID values (comma delimited) to get information about the specified items.
  • Specify an empty string ("") to get information about all registered items.
Code snippet
// Get information about 3 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("", OnGetProductsDetails);

After processing is complete, the OnGetProductsDetails callback is triggered, which contains information about the specified items and API call processing.

Purchase an in-app item

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.

Code snippet
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.

Acknowledge a purchased consumable item

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 purchaseID in the OnPayment and OnGetOwnedList callbacks.
Specify one or more unique purchaseID values, comma delimited.

Code snippet
SamsungIAP.Instance.ConsumePurchasedItems("purchaseId_1, purchaseId_2, purchaseId_3", OnConsume);

After processing is complete, the OnConsume callback is triggered, which contains information about the consumed item and API call processing.

Get promotion eligibility for subscription

Use the GetPromotionEligibility() method to get the pricing options of a subscription item, such as free trials and introductory prices, applicable to the customer.

Specify one or more unique subscription ID values, comma delimited.

Code snippet
SamsungIAP.Instance.GetPromotionEligibility("subscItemId_1, subscItemId_2", OnGetPromotionEligibility);

After processing is complete, the OnGetPromotionEligibility callback is triggered, which contains information about the pricing policy list and API call processing.

Change subscription plan

Use the ChangeSubscriptionPlan() method to allow your customer to change their existing subscription to another tier of the same subscription item.

Proration Mode

Description

INSTANT_PRORATED_DATE

The subscription is upgraded or downgraded immediately.
Any time remaining is adjusted based on the price difference and credited toward the new subscription by pushing forward the next billing date. There is no any additional payment.

INSTANT_PRORATED_CHARGE

For upgraded subscriptions only.
The subscription is upgraded immediately but the billing cycle remains the same. The price difference for the remaining period is then charged to the user.

INSTANT_NO_PRORATION

For upgraded subscriptions only.
The subscription is upgraded immediately and the new price is charged when the subscription renews. The billing cycle remains the same.

DEFERRED

The subscription is upgraded or downgraded when the subscription renews.
When the subscription renews, the new price is charged. A downgrade is always executed with this mode.

See Proration Modes for more details about the four modes.

Code snippet
SamsungIAP.Instance.ChangeSubscriptionPlan("oldItemId", "newItemId", ProrationMode.INSTANT_PRORATED_CHARGE, "pass_through_value", OnChangeSubscriptionPlan);

After processing is complete, the OnChangeSubscriptionPlan callback is triggered, which contains information about the purchased item, the transaction, and API call processing.