docs.unity.cn
    Show / Hide Table of Contents

    Interface ITransactionManager

    This class contains methods to process virtual transactions and in-app purchases.

    Namespace: UnityEngine.GameFoundation
    Syntax
    public interface ITransactionManager

    Properties

    currentIap

    This is a Transaction that is currently in progress, recently initiated by the user.

    Declaration
    IAPTransaction currentIap { get; }
    Property Value
    Type Description
    IAPTransaction

    purchasingAdapterIsInitialized

    Returns true if the optional purchasing adapter has finished initializing.

    Declaration
    bool purchasingAdapterIsInitialized { get; }
    Property Value
    Type Description
    Boolean

    unprocessedPurchases

    A list of Object that were not automatically processed because the "Process Background Purchases" option was unchecked. It is up to the developer to fully process these.

    Declaration
    List<object> unprocessedPurchases { get; }
    Property Value
    Type Description
    List<Object>

    Methods

    BeginTransaction(BaseTransaction, List<String>)

    Process a transaction.

    Declaration
    Deferred<TransactionResult> BeginTransaction(BaseTransaction transaction, List<string> costItemIds = null)
    Parameters
    Type Name Description
    BaseTransaction transaction

    A BaseTransaction to process.

    List<String> costItemIds

    If this is a virtual transaction with item costs, this is the list of items to consume. If this argument is null or empty, the first inventory items that satisfy the cost will be consumed.

    Returns
    Type Description
    Deferred<TransactionResult>

    Returns a Deferred struct which can be used to track the state of the transaction.

    GetLocalizedIAPProductInfo(String)

    This uses the purchasing adapter to get localized product info from the platform store.

    Declaration
    LocalizedProductMetadata GetLocalizedIAPProductInfo(string productId)
    Parameters
    Type Name Description
    String productId

    The product ID for which you want localized info.

    Returns
    Type Description
    LocalizedProductMetadata

    A struct containing localized name and price strings.

    Exceptions
    Type Condition
    Exception

    Throws an exception if no purchasing adapter has been initialized.

    IsIapProductOwned(String)

    Determine if specified Product Id is owned by the player.

    Declaration
    bool IsIapProductOwned(string productId)
    Parameters
    Type Name Description
    String productId

    Product Id for which to search.

    Returns
    Type Description
    Boolean

    true if specified Product Id is owned by the player, otherwise false.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the ITransactionManager implementation has not been initialized.

    ProcessPurchaseEventArgs(Object)

    Use this to manually process purchases that succeeded in the background, such as when purchases are restored, or automatically processed from a previous session.

    Declaration
    Deferred<TransactionResult> ProcessPurchaseEventArgs(object purchaseEventArgs)
    Parameters
    Type Name Description
    Object purchaseEventArgs

    The Object to process.

    Returns
    Type Description
    Deferred<TransactionResult>

    Returns a Deferred struct which can be used to track the state of the processing.

    RestoreIAPPurchases()

    Tells the IAP system to try and restore past purchases. Currently this only applies to iOS.

    Declaration
    void RestoreIAPPurchases()

    SetIAPValidator(Object)

    Set a validator instance for the purchasing adapter to use.

    Declaration
    void SetIAPValidator(object validator)
    Parameters
    Type Name Description
    Object validator

    The validator reference to set.

    Events

    purchaseSucceededInIAPSDK

    Invoked after a purchase has succeeded in the IAP SDK, but before the purchase has been processed by the Game Foundation data layer. It includes the PurchaseEventArgs object that was returned by the IAP SDK. It does not include an IAPTransaction or IAPTransaction key because this event happens regardless of whether or not an associated IAPTransaction exists. You can use FindIAPTransactionByProductId(String) to see if this PurchaseEventArgs does relate to an IAPTransaction.

    Declaration
    event Action<object> purchaseSucceededInIAPSDK
    Event Type
    Type Description
    Action<Object>

    purchaseSucceededInPurchasingAdapter

    Invoked after a purchase has succeeded in the purchasing adapter, but before the purchase has been processed by the Game Foundation data layer. It includes data that was returned by the purchasing adapter. It does not include an IAPTransaction or IAPTransaction key because this event happens regardless of whether or not an associated IAPTransaction exists. You can use FindIAPTransactionByProductId(String) to see if this IapResult does relate to an IAPTransaction.

    Declaration
    event Action<IapResult> purchaseSucceededInPurchasingAdapter
    Event Type
    Type Description
    Action<IapResult>

    purchasingAdapterInitializeFailed

    Invoked after the purchasing adapter reports failing to initialize.

    Declaration
    event Action<Exception> purchasingAdapterInitializeFailed
    Event Type
    Type Description
    Action<Exception>

    purchasingAdapterInitializeSucceeded

    Invoked after the purchasing adapter reports successfully being initialized.

    Declaration
    event Action purchasingAdapterInitializeSucceeded
    Event Type
    Type Description
    Action

    transactionFailed

    Invoked after a transaction fails.

    Declaration
    event Action<BaseTransaction, Exception> transactionFailed
    Event Type
    Type Description
    Action<BaseTransaction, Exception>

    transactionInitiated

    Invoked as soon as a valid transaction is initiated.

    Declaration
    event Action<BaseTransaction> transactionInitiated
    Event Type
    Type Description
    Action<BaseTransaction>

    transactionProgressed

    Invoked after every time the progress number is increased on a transaction's Deferred<TResult>.

    Declaration
    event Action<BaseTransaction, int, int> transactionProgressed
    Event Type
    Type Description
    Action<BaseTransaction, Int32, Int32>

    transactionSucceeded

    Invoked after a transaction has succeeded at all levels.

    Declaration
    event Action<BaseTransaction, TransactionResult> transactionSucceeded
    Event Type
    Type Description
    Action<BaseTransaction, TransactionResult>
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on 16 June 2021