Documentation

Limit purchases per player

Limit how many times each player can buy a catalog listing per hour, day, or month, and show players how many purchases they have left.
Read time 6 minutesLast updated 12 hours ago

A purchase limit sets the maximum number of times each player can buy a catalog listing in an hour, a day, or a month. For example, you can sell a daily deal that each player can buy once per day, or a monthly bundle that each player can buy three times per month. Limits apply to each catalog listing, so two listings for the same uSKU have separate limits. Use purchase limits on consumable listings, because a non-consumable listing already sells only once to each player.
Unity counts each player's paid and fulfilled orders for a listing, using the player's Unity Player Authentication ID in the project and environment. Abandoned and failed checkouts don't count. A refunded order keeps counting until the order is revoked. For more information, refer to Refunds and disputes for D2C payments. Counts reset on UTC calendar boundaries, not on a rolling window:
  • Hour: At the start of each hour.
  • Day: At 00:00 UTC.
  • Month: At 00:00 UTC on the first day of the month.
Purchase limits apply to purchases through payment providers and your webshop. Purchases through native stores, such as the Apple App Store and Google Play Store, aren't limited and don't count toward a limit.

Set a purchase limit

You can set a purchase limit in the Unity Dashboard or in the Unity Editor. For the field definition, refer to Catalog schema.
If you change a limit, the new limit applies to the next order. Purchases that the player already made in the current period still count.

Set a limit in the Unity Dashboard

To set a purchase limit in the Unity Dashboard:
  1. In the Unity Dashboard, go to In-App Purchases > Catalog.
  2. Add a catalog listing or edit an existing Consumable listing.
  3. In Purchase limit, enable Limit purchases per player.
  4. Enter the number of purchases each player can make, and select Hour, Day, or Month.
  5. Save the listing.
After you save the listing, Unity applies the limit to new orders for that listing. For the full list of listing fields, refer to Add a catalog listing.

Set a limit in the Unity Editor

You can set a purchase limit on a catalog item in a
.ucat
file or in a
.catalog.csv
file.
To set a purchase limit on a
.ucat
catalog item:
  1. Open the catalog item in the Inspector window.
  2. In Purchase Limit, set Period to Hour, Day, or Month.
  3. In Count, enter the number of purchases each player can make.
  4. Deploy the catalog item from the Deployment window. For more information, refer to Upload your product catalog to the Remote Catalog service.
After you deploy the catalog item, Unity applies the limit to new orders for that listing. To remove a limit, set Period to None and deploy the catalog item again.
In a
.catalog.csv
file, use the
PurchaseLimitCount
and
PurchaseLimitPeriod
columns. Leave both empty for no limit. For more information, refer to Create your Remote Catalog.
When you deploy, Unity IAP reports an error if you set a count without a period or a period without a count, if the count isn't a whole number of 1 or more, or if the period isn't
Hour
,
Day
, or
Month
.

Show players their remaining purchases

Your webshop shows the limit on each limited listing. Under the price, a caption shows how many purchases the player has left in the period, for example, Available daily: 1/1.
When the player reaches the limit, the listing shows when they can buy it again. Within 24 hours, it shows a countdown, for example, Available in 10h 35m. Further out, it shows a date, for example, Available Oct 14.
In your game, use the Unity IAP SDK to read a listing's purchase limit and check whether the player can buy it.
Note
The SDK APIs on this page require Unity IAP 5.5.0 or later.

Read a listing's purchase limit

After you fetch products from the payment provider store, read
purchaseLimit
from the product's payment provider metadata. It's
null
when the listing has no limit.
var metadata = product.metadata.GetPaymentProviderProductMetadata();var limit = metadata?.purchaseLimit;if (limit != null){ // For example, "1 per Day". Debug.Log($"{limit.count} per {limit.period}");}

Check whether the player can buy

To show remaining purchases or when a listing is available again, call
GetPurchaseEligibility
on
IPaymentProvidersExtendedService
with up to 50 catalog listing IDs. It returns a result for each ID, keyed by catalog listing ID, and doesn't throw.
var paymentProvidersService = UnityIAPServices.Store(PaymentProvider.Name).PaymentProviders;var results = await paymentProvidersService.GetPurchaseEligibility(new[] { "catalog/daily_deal" });var listing = results["catalog/daily_deal"];if (listing.FailureReason != null){ // The check failed. Don't treat the listing as eligible.}else if (listing.Eligible){ // Remaining is null when the listing has no purchase limit. Debug.Log($"{listing.Remaining} left this period");}else{ // NextEligibleAt is the start of the next period, in UTC. Debug.Log($"Available again at {listing.NextEligibleAt}");}
Fetch products before you call
GetPurchaseEligibility
. If the player hasn't bought the listing in the current period,
Remaining
falls back to the listing's purchase limit, which comes from the fetched product.
If a listing can't be checked,
FailureReason
says why, for example,
ListingNotFound
, or
RequestFailed
when the request itself fails.
Purchase eligibility only reflects purchase limits. It doesn't reflect ownership. To check whether a player already owns a
NonConsumable
listing, use entitlements.

Handle a purchase that reaches the limit

Unity checks the limit when your game or webshop creates an order. After a player reaches the limit, Unity rejects new orders for that listing until the next period starts.

Handle the failure in the Unity IAP SDK

When a player tries to buy a listing past its limit, the purchase fails with
PurchaseFailureReason.PurchaseLimitReached
. Handle it in your
OnPurchaseFailed
callback, for example, by showing when the listing is available again.
storeController.OnPurchaseFailed += failedOrder =>{ if (failedOrder.FailureReason == PurchaseFailureReason.PurchaseLimitReached) { // Show the player that they've reached the limit for this listing. }};

Handle the failure with the REST API

If you create orders from your own client or backend, the create order endpoint returns a
409
response with the
problems/purchase-limit-reached
problem type when the player reaches the limit. To check limits before you create an order, call the purchase eligibility endpoint.