EN CN
The Samsung IAP Unreal plugin comes with all the content necessary for your integration. The guide explains how to use the Samsung In-App Purchase (IAP) functionality by integrating the Samsung IAP Unreal Engine Plugin.
This section explains how to use the Samsung In-App Purchase(IAP) functionality by integrating the Samsung IAP Unreal Engine Plugin.
To avoid compatibility issues, the plugin requires the following SDKs:
Copy and enable the Unreal Engine Plugin.
If a <unreal_project_directory>/Plugins folder does not exist, create it.
From the Samsung IAP Unreal plugin, copy the SamsungIAP folder and its contents to <unreal_project_directory>/Plugins.
In the Edit->Plugins menu, enable the Samsung IAP Plugin.
Modify the <unreal_project_name>.Buld.cs file by adding "SamsungIAP" to the PublicDependencyModuleNames section.
<unreal_project_name>.Buld.cs
"SamsungIAP"
PublicDependencyModuleNames
Sample code:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore", **"SamsungIAP"** });
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.
Access the Samsung IAP API by including the IAP header file (IAP.h) in the related classes of your project.
#include "IAP.h"
Use the setOperationMode() method to set Samsung IAP to one of three operating modes:
During app development and testing:
For beta release:
For validation testing and for normal release:
samsung::IAP::setOperationMode(IAP_MODE_TEST);
Use the getOwnedList() method to get information about some or all of the items the user has already purchased:
samsung::IAP::getOwnedList(PRODUCT_TYPE_ALL);
After processing is complete, the onGetOwnedProducts callback is triggered, containing information about the specified purchased items and API call processing.
onGetOwnedProducts
Use the getProductsDetails() method and the following parameter settings to get information (including, localized description, price, and currency symbol) about some or all of the registered in-app items that are available for user purchase:
getProductsDetails()
//Get information about three in-app items samsung::IAP::getProductsDetails("com.mygame.product1, com.mygame.product2, com.mygame.product3"); //Get information about all in-app items samsung::IAP::getProductsDetails("");
After processing is complete, the onGetProductsDetails callback is triggered, containing information about the specified registered items and API call processing.
onGetProductsDetails
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.
//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.
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:
//Consume Purchased Items 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.
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)); } }