Skip to main content
Samsung Developer Program

Samsung IAP Unreal Plugin

How to implement Samsung IAP functionality into your Android apps through the Samsung In-App Purchase (IAP) Unreal Plugin.

Get Started

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

System Requirements

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

Android Studio requires that your IDE system meet the following:

  • Microsoft Windows 7/8/10 (32-bit or 64-bit)
  • 2 GB RAM minimum, 8 GB RAM recommended
  • 2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
  • 1280 x 800 minimum screen resolution
  • JDK 8
     

Install the Plugin

Copy and enable the Unreal Engine Plugin.

If a <unreal_project_directory>/Plugins folder does not exist, create it.

From the archive ([Add URL of the plugin archive]), copy the plugin folder contents to <unreal_project_directory>/Plugins.

 

In the Edit->Plugins menu, enable the Samsung IAP Plugin.

 

Add Samsung IAP Dependency

Modify the <unreal_project_name>.Buld.cs file by adding "SamsungIAP" to the PublicDependencyModuleNames section.

Sample code:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore", "SamsungIAP" });

 

Integrate Samsung IAP Functionality

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.

Note: For details about Samsung IAP method calls, see the IAP Helper API Reference.

Include IAP Header File

Access the Samsung IAP API by including the IAP header file (IAP.h) in the related classes of your project.

Sample code:

#include "IAP.h"

 

Set IAP Operating Mode

Use the setOperationMode() method to set Samsung  IAP to one of three operating modes:

  setOperationMode()
Setting
Description

Production

IAP_MODE_PRODUCTION

  • Mode for normal and beta release.
  • Requests are processed as specified, and go through the Samsung IAP server.
  • Successful and failure results can be returned.
  • Caution: Successful purchase requests and payment transactions result in financial billing of the user.

Test

IAP_MODE_TEST

  • Mode for app development and testing.
  • Requests do not go through the Samsung IAP server.
  • Successful and failure results can be returned.
  • Successful purchase requests do not result in payment transactions or financial billing.
  • For requests that succeed, successful results that contain fake information are returned.
  • For requests that fail (for example, due to network issues), failure results that indicate the true type of failure are returned.

Test (Failure)

IAP_MODE_TEST_FAILURE

  • Mode for app development and testing.
  • Requests do not go through the Samsung IAP server.
  • Failure results are returned for all requests.
  • Purchase requests do not result in in payment transactions or financial billing.

 

During app development and testing:

  • Either test mode can be set.
  • IAP_MODE_PRODUCTION mode must not be set.
    Caution: If production mode is set, all requests are blocked and an error is returned.
     

For beta release:

  • IAP_MODE_PRODUCTION mode must be set.
  • All beta testers download paid beta apps for free.
  • Beta testers who are not whitelisted will be financially billed for in-app items, and they can test in-app purchase functionality.
  • Beta testers who are whitelisted get in-app items for free, but they cannot test purchase functionality.
     

For validation testing and for normal release:

  • IAP_MODE_PRODUCTION mode must be set prior to submitting an app and its in-app items to validation testing.
    Caution: If IAP_MODE_TEST mode is set, purchase requests for paid apps and in-app items will not result in financial billing of the user. If IAP_MODE_TEST_FAILURE is set, all requests will fail.
     

Sample code:

samsung::IAP::setOperationMode(IAP_MODE_TEST);  

 

Query Previously Purchased Items

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

getOwnedList()Setting Description
PRODUCT_TYPE_ITEM Returns all purchased non-consumable items, and consumable items that have not been consumed.
PRODUCT_TYPE_SUBSCRIPTION Returns all purchased subscription items with active subscriptions.
PRODUCT_TYPE_ALL Returns all purchased non-consumable items, consumable items that have not been consumed, and subscription items with active subscriptions.

 

Note: Purchased consumable items that were previously reported as consumed are not returned. Purchased subscription items with expired subscriptions are not returned.

 

Sample code:

samsung::IAP::getOwnedList(PRODUCT_TYPE_ALL);
 

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

 

Query Offered Samsung IAP Items

Use the getProductDetails() 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.
     

Sample code:

//Get information about three in-app items. 
samsung::IAP::getProductDetails("com.mygame.product1, com.mygame.product2, com.mygame.product3"); 

//Get information about all in-app items. 
samsung::IAP::getProductDetails("");

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

 

Initiate a Purchase and Payment Transaction

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 later to identify the purchase when verifying the purchase and payment transaction. You must specify whether or not a dialog box is to notify users when the transaction was successful.

Sample code:

//Start purchase and payment of an in-app item.
samsung::IAP::startPayment("com.mygame.product1", "pass_through_value", true);

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

 

Enable a Purchased Consumable Item to be Purchased Again

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:

samsung::IAP::consumePurchasedItems(purchase_id); 
 

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

 

Listen to Callback Events

Implement an IAP Listener class to receive information in all the Samsung IAP callback events.
 

Listener declaration sample code:

class SamsungIAPListener : public samsung::IAPListener { 
public: 
    void onGetProducts(int result, const FString& msg, const std::vector<samsung::ProductVo>& data); 
    void onGetOwnedProducts(int result, const FString& msg, const std::vector<samsung::OwnedProductVo>& data); 
    void onPayment(int result, const FString& msg, const samsung::PurchaseVo& data); 
    void onConsumePurchasedItems(int result, const FString& msg, const std::vector<samsung::ConsumeVo>& data); 
};

 

Listener implementation sample code:

using namespace std; 
using namespace samsung; 

void SamsungIAPListener::onGetProducts(int result, const FString& msg, 
        const vector<ProductVo>& data) 
{ 
    for(auto& i : data) { 
        print(FString::Printf(TEXT(" Name: %s"), *i.mItemName)); 
    } 

} 
void SamsungIAPListener::onGetOwnedProducts(int result, const FString& msg, 
const vector<OwnedProductVo>& data) { 

    for(auto& i : data) { 
        print(FString::Printf(TEXT("Owned Item: %s"), *i.mItemName)); 
    } 

} 
void SamsungIAPListener::onPayment(int result, const FString& msg, 
       const PurchaseVo& data) { 
    print(FString::Printf(TEXT("Item: %s"), *data.mItemName)); 

} 
void SamsungIAPListener::onConsumePurchasedItems(int result, 
       const FString& msg, const vector<ConsumeVo>& data) { 
    for(auto& i : data) { 
        print(FString::Printf(TEXT("Owned Item: %s"), *i.mPurchaseId)); 
    } 

}

 

Publish Your Apps and In-app Items

Register, validate, and distribute (either in beta or normal release) your Samsung IAP integrated Android app and its in-app items in the Samsung Galaxy Apps store:

  1. Get a Galaxy Apps Seller Office commercial account.
  2. Log in to Galaxy Apps Seller Office.
  3. Register your Android app and in-app items.
  4. Submit your app and in-app items for validation testing.
  5. Manage your app distribution, app and in-app items, and your finances.

 

 

  • Was this article helpful?