UDN
Search public documentation:
MicroTransactions
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
UE3 Home > PlatformInterface Framework > Micro-Transaction System
Micro-Transaction System
Overview
MicroTransactionBase
MicroTransactionBase
class is the base class containing the functionality for performing micro-transactions. It inherits from the PlatformInterfaceBase
and makes use of the delegate system contained in that class. Each platform (PC, iOS, etc.) has its own subclass extending from CloudStorageBase
that provides the implementation specific to that platform.
Properties
- AvailableProducts - Holds the list of products available to be purchased, populated by
QueryForAvailablePurchases()
after theMTD_PurchaseQueryComplete
callback is complete. - LastError - Holds a description (
string
) of the most recent error if an error occurs during the purchase process. - LastErrorSolution - Holds a description (
string
) of the possible solutions (if any) to the most recent erro if one occurs during the purchase process.
- Init - Event called by the engine to initialize the micro-transaction system.
- QueryForAvailablePurchases - Queries the system for what purchases are available and returns whether the query was initiated successfully.
- IsAllowedToMakePurchase - Returns whether the user is allowed to make purchases.
- BeginPurchase [Index] - Initiates the process of purchasing a product from the
AvailableProducts
list and returns whether the purchase was initiated successfully.- Index - The
Int
specifying the index into theAvailableProducts
array of the product to purchase.
- Index - The
EMicroTransactionDelegate
enum defines the IDs for the types of delegates that can receive callbacks. Delegates can be assigned to each of these using the Platform Interface Delegates system.
- MTD_PurchaseQueryComplete - Delegates assigned to this ID are executed when a query for available products is completed via
QueryForAvailablePurchases()
.- bSuccessful - TRUE.
- Data - Contains no data.
- MTD_PurchaseComplete - Delegates assigned to this ID are executed when an attempt to purchase a product is completed.
- bSuccessful - TRUE.
- Data - The
IntValue
will contain one of the enums inEMicroTransactionResult
, andStringValue
will have theIdentifier
from thePurchaseInfo
that was bought withBeginPurchase
. IfMTR_Failed
was returned, thenLastError
andLastErrorSolution
should be filled out with the most recent localized and possible resolutions.
Products
AvailableProducts
array in the form of a PurchaseInfo
. This struct contains all of the information about the product necessary to dsiplay it to the user and allow it to be purchased.
- Identifier - A
string
representing the unique identifier for the product. - DisplayName - A
string
holding the name of the product to display to the user. - DisplayDescription - A
string
holding the description of the product to display to the user. - DisplayPrice - A
string
holding the price of the product to display to the user.
Implementation Details
- Make sure your game is set up for micro-transactions in the iOS Provisioning Portal and set up available products for your game through the iTunes Connect application. For more information, see the Apple Developer Site.
- Get a reference to the
MicroTransactionBase
object by calling the staticGetMicroTransactionInterface()
of thePlatformInterfaceBase
class and set up your delegates for the product query and purchase callbacks, usually inPostBeginPlay()
or some other initialization function depending on where you are placing the micro-transaction functionality.var MicroTransactionBase MicroTrans; ... MicroTrans = class'PlatformInterfaceBase'.static.GetMicroTransactionInterface(); MicroTrans.AddDelegate(MTD_PurchaseQueryComplete, OnProductQueryComplete); MicroTrans.AddDelegate(MTD_PurchaseComplete, OnProductPurchaseComplete);
OnProductQueryComplete
andOnProductPurchaseComplete
are just examples. These can be the names of any function matching the signature of thePlatformInterfaceDelegate
delegate.delegate PlatformInterfaceDelegate(const out PlatformInterfaceDelegateResult Result);
- To obtain the list of available products for the game, call
QueryForAvailablePurchases()
on theMicroTransactionBase
object and wait for theMTD_PurchaseQueryComplete
callback where you can handle the list ofAvailableProducts
to display them to the user in any way you desire (most likely in a menu of some sort.MicroTrans.QueryForAvailablePurchases();
- Once the list of products is obtained, purchases can be made by calling
BeginPurchase()
on theMicroTransactionBase
object, passing it the index of the product to purchase. This would most likely be the result of the user tapping a button in a menu.This will attempt to purchase the first product (index 0) in the list ofMicroTrans.BeginPurchase(0);
AvailableProducts
.
CloudMenuMicroTransaction.uc
script of the UDKBase\Classes
directory.