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 products.
NoteFor details about Samsung IAP method calls, see the Programming Guide.
Include IAP header file
Access the Samsung IAP API by including the IAP header file IAP.h in the related classes of your project.
CautionEnsure the operation mode is set to IAP_MODE_PRODUCTION before submitting for Beta test or normal publication. In other words, IAP_MODE_TEST or IAP_MODE_TEST_FAILURE must be set only if the app status in Seller Portal is Registering or Updating.
Mode
Description
IAP_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 products purchased in IAP_MODE_PRODUCTION mode are considered owned products.
IAP_MODE_TEST
startPayment() requests are processed as specified, except financial transactions do not occur (licensed testers are not billed for product purchases), and successful results are always returned. For details of the payment window shown in IAP_MODE_TEST mode, see the payment window.
Note: For all other IAP requests:
Only products purchased in IAP_MODE_TEST mode are considered owned products.
In order to purchase in-app products, 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 products for free. All other users see an error message if they try to purchase an in-app product.
IAP_MODE_TEST_FAILURE
All IAP requests fail. This mode is for negative testing to ensure that your app can handle errors such as improper input and user actions.
Code snippet
samsung::IAP::setOperationMode(IAP_MODE_TEST);
Get user-owned products
RequirementYou must call getOwnedList() whenever launching the application in order to check for unconsumed items or subscription availability.
Use the getOwnedList() method to get information about some or all of the products 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 subscriptions
all
Returns all purchased non-consumable items, consumable items that have not been consumed and active subscriptions
NoteBoth purchased consumable items that were previously reported as consumed and expired subscriptions are not returned.
Code snippet
samsung::IAP::getOwnedList("all");
After processing is complete, the onGetOwnedProducts callback is triggered, containing information about the specified purchased products and API call processing.
Use the getProductsDetails() method to get detailed information (for example, item ID, price, and description) about some or all of the in-app products registered to your app that are available for user purchase:
Specify one or more unique in-app product ID values (comma delimited) to get information about the specified products.
Specify an empty string ("") to get information about all registered products.
Code snippet
//Get information about three in-app products
samsung::IAP::getProductsDetails("com.mygame.product1, com.mygame.product2, com.mygame.product3");
//Get information about all in-app products
samsung::IAP::getProductsDetails("");
After processing is complete, the onGetProducts callback is triggered, which contains information about the specified products and API call processing.
Use the startPayment() method to initiate a purchase and payment transaction for a specified in-app product.
You can optionally specify the obfuscated account ID and profile ID in the request for startPayment(). The obfuscated account ID and profile ID are returned in the response. Galaxy Store uses this value to detect fraudulent payments.
NoteThis method was deprecated in Samsung IAP Unreal Engine Plugin v6.5.0:
passThroughParam, which is a unique identifier that your app assigned to the product purchase and payment transaction, has been deprecated in plugin v6.5.0.
Code snippet
//Start purchase and payment of an in-app product.
samsung::IAP::startPayment("com.mygame.product1", "obfuscatedAccountId", "obfuscatedProfileId");
After processing is complete, the onPayment callback is triggered, which contains information about the purchased product, the transaction, and API call processing.
Notify Samsung IAP that the purchase was processed
Consumable items
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.
After processing is complete, the onConsumePurchasedItems callback is triggered, which contains information about the consumed item and API call processing.
Use the acknowledgePurchases() method to acknowledge that the user has been granted entitlement for one or more purchased non-consumable items or subscriptions.
Code snippet
//Acknowledge non-consumable items and subscriptions
samsung::IAP::acknowledgePurchases("purchase_id");
After processing is complete, the onAcknowledgePurchases callback is triggered, which returns non-consumable items or subscription data.
NoteWe recommend reporting purchased consumable items immediately after verifying their purchase and reporting all unreported products in one consumePurchasedItems() or acknowledgePurchases() method call in order to avoid system overload or malfuction.
Use the getPromotionEligibility() method to get the pricing options of a subscription, such as free trials and introductory prices, applicable to the customer.
Specify one or more unique subscription ID values, comma delimited.
Code snippet
//Get promotional offers of items and subscriptions
samsung::IAP::getPromotionEligibility("subItemId_1, subItemId_2");
After processing is complete, the onGetPromotionEligibility callback is triggered, which contains information about the pricing policy list and API call processing.
Use the changeSubscriptionPlan() method to allow your customer to change their existing subscription to another tier of the same subscription.
Proration Mode
Description
PRORATION_MODE_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.
PRORATION_MODE_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.
PRORATION_MODE_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.
PRORATION_MODE_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.
//Change from one subscription plan to another
samsung::IAP::changeSubscriptionPlan("oldItemId", "newItemId", PRORATION_MODE_INSTANT_PRORATED_DATE, "obfuscatedAccountId", "obfuscatedProfileId");
After processing is complete, the onChangeSubscriptionPlan callback is triggered, which contains information about the purchased product, the transaction, and API call processing.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
developer.samsung.com, .samsung.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
Samsung Electronics
.samsung.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
Samsung Electronics
developer.samsung.com, google.account.samsung.com
Preferences Submitted
You have successfully updated your cookie preferences.