购买
Use the SDK to make virtual purchases and redeem real money purchases.
阅读时间5 分钟最后更新于 15 天前
通过
PurchasesMakeVirtualPurchaseAsync
进行 ID 指定的虚拟购买。 此方法可采用MakeVirtualPurchaseOptionsPlayersInventoryItemsMakeVirtualPurchaseResult使用string purchaseID = "BUY_A_SWORD";MakeVirtualPurchaseResult purchaseResult = await EconomyService.Instance.Purchases.MakeVirtualPurchaseAsync(purchaseID);
PlayersInventoryItemstring purchaseID = "BUY_A_SWORD";MakeVirtualPurchaseOptions options = new MakeVirtualPurchaseOptions{ PlayersInventoryItemIds = new List<string> { "playersInventoryItemId1", "playersInventoryItemId2" }};MakeVirtualPurchaseResult purchaseResult = await EconomyService.Instance.Purchases.MakeVirtualPurchaseAsync(purchaseID, options);
MakeVirtualPurchaseOptions
MakeVirtualPurchaseAsync- : 字符串列表。默认为
PlayersInventoryItemIds。玩家背包中要用作购买成本的物品的nullID。PlayersInventoryItem
MakeVirtualPurchaseResult
MakeVirtualPurchaseAsync-
:
Costs对象代表此次购买花费的成本。这又包含两个字段:Costs- :
Currency列表,描述的是用于进行此次购买的货币。CurrencyExchangeItem - :
Inventory列表,描述的是用作此次购买的成本的物品。InventoryExchangeItem
-
:
Rewards对象代表此次购买所得的内容。和以上对象一样,也包含两个字段:Rewards- :
Currency列表,描述的是此次购买所得的货币。CurrencyExchangeItem - :
Inventory列表,描述的是此次购买所得的物品。InventoryExchangeItem
RedeemAppleAppStorePurchaseAsync
通过提交来自 Apple App Store 的收据来兑换进行真实货币购买的所得内容。如果购买经验证有效,将根据配置中定义的所得内容,将所得内容应用于玩家的背包和货币余额。 必须采用RedeemAppleAppStorePurchaseArgsRedeemAppleAppStorePurchaseArgs args = new RedeemAppleAppStorePurchaseArgs("PURCHASE_ID", "RECEIPT_FROM_APP_STORE", 0, "USD");RedeemAppleAppStorePurchaseResult purchaseResult = await EconomyService.Instance.RedeemAppleAppStorePurchaseAsync(args);
RedeemAppleAppStorePurchaseArgs
用于RedeemAppleAppStorePurchaseAsync- :字符串。要进行的购买的配置 ID。
RealMoneyPurchaseId - :字符串。从 Apple App Store 中返回的收据数据。
Receipt - :整数。以整数表示货币中含小数的购买费用,例如,1.99 美元就是 199。
LocalCost - :字符串。购买中使用的货币的 ISO-4217 代码。
LocalCurrency
RedeemAppleAppStorePurchaseResult
RedeemAppleAppStorePurchaseAsync-
:从验证服务返回的收据验证细节。
Verification-
:收据验证的状态。为以下某一种:
Status- :购买有效。
VALID - :购买有效,之前可见,但尚未兑换。
VALID_NOT_REDEEMED - :购买已兑换。
INVALID_ALREADY_REDEEMED - :收据验证服务返回的结果是收据数据无效。
INVALID_VERIFICATION_FAILED - :该收据之前已被另一玩家使用并验证过。
INVALID_ANOTHER_PLAYER - :服务配置无效,更多信息请参见响应的细节部分。
INVALID_CONFIGURATION - :购买配置商店商品标识符与收据中的信息不符。
INVALID_PRODUCT_ID_MISMATCH
-
:来自收据验证服务的细节。这包含三个字段:
Store- :从 Apple App Store 验证服务返回的状态代码。
Code - :返回的状态代码的文本描述。
Message - :购买的收据数据。
Receipt
-
-
:
Rewards对象代表此次购买所得的内容。它包含以下字段:Rewards- :
Currency列表,描述的是此次购买所得的货币。CurrencyExchangeItem - :
Inventory列表,描述的是此次购买所得的物品。InventoryExchangeItem
EconomyAppleAppStorePurchaseFailedException
RedeemAppleAppStorePurchaseAsyncEconomyAppleAppStorePurchaseFailedExceptionEconomyExceptionDataDataRedeemAppleAppStorePurchaseResultRedeemGooglePlayPurchaseAsync
通过提交来自 Google Play 应用商店的收据来兑换进行真实货币购买的所得内容。如果购买经验证有效,将根据配置中定义的所得内容,将所得内容应用于玩家的背包和货币余额。 必须采用RedeemGooglePlayStorePurchaseArgsRedeemGooglePlayStorePurchaseArgs args = new RedeemGooglePlayStorePurchaseArgs("PURCHASE_ID", "PURCHASE_DATA", "PURCHASE_DATA_SIGNATURE", 0, "USD");RedeemGooglePlayPurchaseResult purchaseResult = await EconomyService.Instance.RedeemGooglePlayPurchaseAsync(args);
RedeemGooglePlayStorePurchaseArgs
用于RedeemGooglePlayPurchaseAsync- :字符串。要进行的购买的配置 ID。
RealMoneyPurchaseId - :字符串。成功进行应用内结算购买后所返回的 JSON 编码字符串。
PurchaseData - :字符串。成功进行应用内结算购买后所返回的
PurchaseDataSignature的签名。PurchaseData - :整数。以整数表示货币中含小数的购买费用,例如,1.99 美元就是 199。
LocalCost - :字符串。购买中使用的货币的 ISO-4217 代码。
LocalCurrency
RedeemGooglePlayPurchaseResult
RedeemGooglePlayPurchaseAsync-
:从验证服务返回的收据验证细节。
Verification-
:收据验证的状态。为以下某一种:
Status- :购买有效。
VALID - :购买有效,之前可见,但尚未兑换。
VALID_NOT_REDEEMED - :购买已兑换。
INVALID_ALREADY_REDEEMED - :收据验证服务返回的结果是收据数据无效。
INVALID_VERIFICATION_FAILED - :该收据之前已被另一玩家使用并验证过。
INVALID_ANOTHER_PLAYER - :服务配置无效,更多信息请参见响应的细节部分。
INVALID_CONFIGURATION - :购买配置商店商品标识符与收据中的信息不符。
INVALID_PRODUCT_ID_MISMATCH
-
:来自收据验证服务的细节。它包含一个字段:
Store- :购买的收据数据。
Receipt
-
-
:
Rewards对象代表此次购买所得的内容。它包含以下字段:Rewards- :
Currency列表,描述的是此次购买所得的货币。CurrencyExchangeItem - :
Inventory列表,描述的是此次购买所得的物品。InventoryExchangeItem
EconomyGooglePlayStorePurchaseFailedException
RedeemGooglePlayPurchaseAsyncEconomyGooglePlayStorePurchaseFailedExceptionEconomyExceptionDataDataRedeemGooglePlayPurchaseResultCurrencyExchangeItem
该对象代表购买中涉及的某种货币。它包含以下字段:- :货币的 ID。
Id - :购买时使用的该货币的数量。
Amount
InventoryExchangeItem
该对象表示购买中涉及的背包物品。它包含以下字段:- :货币的 ID。
Id - :购买中使用/所得的该背包物品的数量。
Amount - :购买中使用/所得的实例的 ID 列表。
InstanceIds