---
title: "Test in-app purchase prices by currency in C#"
url: https://recursiveai.org/onegame/cookbook/test-store-prices-per-currency/
description: "Test in-app purchase prices in different currencies in C#. Verify USD, EUR, and JPY prices for the same product with OneGame’s fake store."
version: "2.5.3"
---

# Test in-app purchase prices by currency in C#

**onegame** is a free, open-source game engine for .NET from Recursive AI. MIT or Apache-2.0, no editor required.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneGame.Purchases) · [GitHub](https://github.com/recursive-ai-oss/onegame) · [Docs](https://recursiveai.org/onegame/docs/) · [Download example (.zip)](https://recursiveai.org/onegame/cookbook/test-store-prices-per-currency/test-store-prices-per-currency.zip)

Use `FakeStore.SetPrice` to test prices in different currencies without a store account.

```shell
dotnet add package RecursiveAI.OneGame.Purchases
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneGame.Purchases;

const string id = "coins";
ProductDefinition[] catalog =
    [new(id, ProductKind.Consumable)];
using var store = FakeStore.For(catalog);
store.Connect();
if (!store.SetPrice(id, 4_990_000, "EUR"))
    throw new InvalidOperationException(id);
store.LoadProducts(catalog);
while (store.TryTake(out var reply))
    foreach (var product in reply.Products)
        Console.WriteLine(product.Price);
```

Prints `€4.99` from the reloaded product, not from the computer’s locale. Amounts are in millionths of the currency (`4_990_000` = 4.99).

Unzip [the example](https://recursiveai.org/onegame/cookbook/test-store-prices-per-currency/test-store-prices-per-currency.zip), then `dotnet run`.

## The full program

The program defines one consumable product, `coins`, in code. It reloads that same product at each test price and checks the display text, currency code, and amount in millionths. No store account, credentials, or input files are needed.

```csharp
using OneGame.Purchases;

var catalog = new[] { new ProductDefinition("coins", ProductKind.Consumable) };
using var store = FakeStore.For(catalog);
store.Connect();
if (!store.TryTake(out var connected) || connected.Kind != StoreEventKind.Connected)
    throw new InvalidOperationException("Fake store did not connect.");

Check("USD", 4_990_000, "$4.99");
Check("EUR", 4_990_000, "€4.99");
Check("JPY", 1_200_000_000, "¥1,200");

void Check(string currency, long micros, string expected, string? display = null)
{
    if (!store.SetPrice("coins", micros, currency, display))
        throw new InvalidOperationException("Unknown product: coins");
    store.LoadProducts(catalog);
    if (!store.TryTake(out var reply) || reply.Kind != StoreEventKind.ProductsLoaded ||
        reply.Products.Count != 1)
        throw new InvalidOperationException("Product did not load.");

    var product = reply.Products[0];
    if (product.Price != expected || product.Currency != currency || product.PriceMicros != micros)
        throw new InvalidOperationException($"Unexpected price for {currency}.");
    Console.WriteLine($"{product.Currency}: {product.Price} ({product.PriceMicros} micros)");
}
```

```text
USD: $4.99 (4990000 micros)
EUR: €4.99 (4990000 micros)
JPY: ¥1,200 (1200000000 micros)
```

If the old price is still on screen, reload the product after calling `SetPrice` and update the UI from the new product data. A misspelled product ID returns `false` from `SetPrice`.

## Variations

Pass explicit display text when testing a label you expect from a real store. Add this after the three `Check` calls:

```csharp
Check("CHF", 5_000_000, "5 francs", "5 francs");
```

## Related recipes

- [Write C# game tests](https://recursiveai.org/onegame/cookbook/csharp-game-tests/)
- [Test a game with YAML scenarios](https://recursiveai.org/onegame/cookbook/automated-game-testing/)

## The short answer

Call `FakeStore.SetPrice` for a product your fake store already sells. Give it the amount in millionths of the currency and a currency code, then reload the products. In a test, check what came back from the store, not only what you passed in. OneGame’s `StoreProduct` carries the display `Price`, the numeric `PriceMicros`, and the `Currency` separately.

## How do you test in-app purchase prices in another currency without changing regions?

A fake-store test sets an explicit price, so the same test can check euros, yen, and dollars on the same machine. It does not convert prices or choose a price for a country. For example, `4_990_000` means 4.99 units in either USD or EUR. In JPY, `1_200_000_000` means 1,200 yen, not 12 yen. The millionths convention is the same even when the display has no decimal places.

If your game already uses OneGame YAML scenarios with the fake store, the `price` action does the reload for you. Put these steps in a scenario for a game with a `coins` product:

```yaml
steps:
  - store: {action: price, product: coins, amount: "4.99", currency: EUR}
  - step: 1
  - expect:
      store:
        price: "coins=€4.99"
        currency: "coins=EUR"
        micros: "coins=4990000"
```

`amount` takes the decimal currency amount, with a period rather than a comma. `micros` checks the stored integer. Checking both formatted text and numeric amount catches mistakes such as treating millionths as cents.

## How do you display the price of an in-app purchase in a foreign currency?

Use `StoreProduct.Price` as the label rather than rebuilding it from `PriceMicros` and the device locale. In the fake store, `FakePrice.Format` gives a fixed format so screenshots and assertions don’t change across machines. If your layout needs to handle a particular spacing or symbol placement, set `display` to that exact string and check that your UI leaves it alone. `Currency` and `PriceMicros` still describe the amount even when you supply the text yourself.

This tests how your game handles a price response. It doesn’t check which regional price the real storefront returns, whether taxes are reflected in the displayed amount, or whether checkout succeeds. Use the store’s test environment for those checks.
