Purchases
Use the SDK to make virtual purchases and redeem real money purchases.
Read time 4 minutesLast updated a day ago
The methods in the
PurchasesMakeVirtualPurchaseAsync
Makes a virtual purchase specified by ID. This method optionally takes aMakeVirtualPurchaseOptionsPlayersInventoryItemsMakeVirtualPurchaseResultAlternative Example usingstring 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
The options object for aMakeVirtualPurchaseAsync- : A list of strings. Defaults to
PlayersInventoryItemIds. ThenullIDs of the items in the players inventory that you want to use towards the cost(s) of the purchase.PlayersInventoryItem
MakeVirtualPurchaseResult
This object is returned by aMakeVirtualPurchaseAsync-
: A
Costsobject representing the costs that were spent in this purchase. This in turn has two fields:Costs- : A list of
Currencydescribing the currencies used to make this purchase.CurrencyExchangeItem - : A list of
Inventorydescribing the items used as a cost in order to make this purchase.InventoryExchangeItem
-
: A
Rewardsobject representing the rewards given in exchange for this purchase. This also has two fields as above:Rewards- : A list of
Currencydescribing the currencies rewarded as part of this purchase.CurrencyExchangeItem - : A list of
Inventorydescribing the items rewarded as part of this purchase.InventoryExchangeItem
RedeemAppleAppStorePurchaseAsync
Redeems a real money purchase by submitting a receipt from the Apple App Store. This is validated and if valid, the rewards as defined in the configuration are applied to the player’s inventory and currency balances. Takes a requiredRedeemAppleAppStorePurchaseArgsRedeemAppleAppStorePurchaseArgs args = new RedeemAppleAppStorePurchaseArgs("PURCHASE_ID", "RECEIPT_FROM_APP_STORE", 0, "USD");RedeemAppleAppStorePurchaseResult purchaseResult = await EconomyService.Instance.Purchases.RedeemAppleAppStorePurchaseAsync(args);
RedeemAppleAppStorePurchaseArgs
The arguments object for aRedeemAppleAppStorePurchaseAsync- : A string. The configuration ID of the purchase to make.
RealMoneyPurchaseId - : A string. The receipt data as returned from the Apple App Store.
Receipt - : An int. The cost of the purchase as an integer in the minor currency format, for example, $1.99 USD would be 199.
LocalCost - : A string. ISO-4217 code of the currency used in the purchase.
LocalCurrency
RedeemAppleAppStorePurchaseResult
This object is returned by aRedeemAppleAppStorePurchaseAsync-
: The receipt verification details from the validation service.
Verification-
: Status of the receipt verification. This will be one of:
Status- : The purchase was valid.
VALID - : The purchase was valid but seen before, but had not yet been redeemed.
VALID_NOT_REDEEMED - : The purchase has already been redeemed.
INVALID_ALREADY_REDEEMED - : The receipt verification service returned that the receipt data was not valid.
INVALID_VERIFICATION_FAILED - : The receipt has previously been used by a different player and validated.
INVALID_ANOTHER_PLAYER - : The service configuration is invalid, further information in the details section of the response.
INVALID_CONFIGURATION - : The purchase configuration store product identifier does not match the one in the receipt.
INVALID_PRODUCT_ID_MISMATCH
-
: Details from the receipt validation service. This has three fields:
Store- : The status code sent back from the Apple App Store verification service.
Code - : A textual description of the returned status code.
Message - : The purchase receipt data.
Receipt
-
-
: A
Rewardsobject representing the rewards given in exchange for this purchase. This has the following fields:Rewards- : A list of
Currencydescribing the currencies rewarded as part of this purchase.CurrencyExchangeItem - : A list of
Inventorydescribing the items rewarded as part of this purchase.InventoryExchangeItem
INVALID_VERIFICATION_FAILED
If you get anINVALID_VERIFICATION_FAILEDThe receipt could not be authenticated.21003EconomyAppleAppStorePurchaseFailedException
RedeemAppleAppStorePurchaseAsyncEconomyAppleAppStorePurchaseFailedExceptionEconomyExceptionDataDataRedeemAppleAppStorePurchaseResultRedeemGooglePlayPurchaseAsync
Redeems a real money purchase by submitting a receipt from the Google Play Store. This is validated and if valid, the rewards as defined in the configuration are applied to the player’s inventory and currency balances. Takes a requiredRedeemGooglePlayStorePurchaseArgsRedeemGooglePlayStorePurchaseArgs args = new RedeemGooglePlayStorePurchaseArgs("PURCHASE_ID", "PURCHASE_DATA", "PURCHASE_DATA_SIGNATURE", 0, "USD");RedeemGooglePlayPurchaseResult purchaseResult = await EconomyService.Instance.Purchases.RedeemGooglePlayPurchaseAsync(args);
RedeemGooglePlayStorePurchaseArgs
The arguments object for aRedeemGooglePlayPurchaseAsync- : A string. The configuration ID of the purchase to make.
RealMoneyPurchaseId - : A string. A JSON encoded string returned from a successful in app billing purchase.
PurchaseData - : A string. A signature of the
PurchaseDataSignaturereturned from a successful in app billing purchase.PurchaseData - : An int. The cost of the purchase as an integer in the minor currency format, for example, $1.99 USD would be 199.
LocalCost - : A string. ISO-4217 code of the currency used in the purchase.
LocalCurrency
RedeemGooglePlayPurchaseResult
This object is returned by aRedeemGooglePlayPurchaseAsync-
: The receipt verification details from the validation service.
Verification-
: Status of the receipt verification. This will be one of:
Status- : The purchase was valid.
VALID - : The purchase was valid but seen before, but had not yet been redeemed.
VALID_NOT_REDEEMED - : The purchase has already been redeemed.
INVALID_ALREADY_REDEEMED - : The receipt verification service returned that the receipt data was not valid.
INVALID_VERIFICATION_FAILED - : The receipt has previously been used by a different player and validated.
INVALID_ANOTHER_PLAYER - : The service configuration is invalid, further information in the details section of the response.
INVALID_CONFIGURATION - : The purchase configuration store product identifier does not match the one in the receipt.
INVALID_PRODUCT_ID_MISMATCH
-
: Details from the receipt validation service. This has one field:
Store- : The purchase receipt data.
Receipt
-
-
: A
Rewardsobject representing the rewards given in exchange for this purchase. This has the following fields:Rewards- : A list of
Currencydescribing the currencies rewarded as part of this purchase.CurrencyExchangeItem - : A list of
Inventorydescribing the items rewarded as part of this purchase.InventoryExchangeItem
EconomyGooglePlayStorePurchaseFailedException
RedeemGooglePlayPurchaseAsyncEconomyGooglePlayStorePurchaseFailedExceptionEconomyExceptionDataDataRedeemGooglePlayPurchaseResultCurrencyExchangeItem
This object represents a currency that was part of a purchase. It has these fields:- : The ID of the currency.
Id - : The amount of this currency used in the purchase.
Amount
InventoryExchangeItem
This object represents an inventory item that was part of a purchase. It has these fields:- : The ID of the currency.
Id - : The amount of this inventory item used/rewarded in the purchase.
Amount - : A list of instance IDs that were used/rewarded in the purchase.
InstanceIds