> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 경제와 게임 설정

> 게임 설정, 확률표, 인앱 결제 검증을 Unity SDK에서 사용합니다.

경제와 설정 기능은 운영자가 Console에서 값을 게시하고, Unity 클라이언트가 게시된 값을 읽거나 서버 검증을 요청하는 방식으로 동작합니다.

## 게임 설정

게임 설정은 밸런스 값, 기능 플래그, 시즌 설정처럼 클라이언트가 읽어야 하는 JSON 설정입니다.

```cs theme={null}
var balance = await HyperX.Core.Economy.GameConfigs.Get("balance");
int maxLevel = (int)balance.Data["max_level"];
```

특정 버전을 고정해서 읽을 수도 있습니다.

```cs theme={null}
var season = await HyperX.Core.Economy.GameConfigs.Get("season", "v2");
```

## 확률표

확률표는 아이템 키, 가중치, 선택적 payload를 가진 항목으로 구성됩니다. Console에서 저장할 때 가중치와 형식을 검증하고, 게시된 버전만 SDK에서 사용할 수 있습니다.

```cs theme={null}
var table = await HyperX.Core.Economy.Probability.Get("starter_box");

var draw = await player.DrawProbability(
    tableKey: "starter_box",
    seed: "tutorial-reward"
);

Debug.Log(draw.ItemKey);
```

`seed`를 전달하면 같은 유저, 같은 게시 버전, 같은 seed에 대해 같은 결과를 얻습니다. 보상 지급은 게임의 지급 정책에 맞게 처리하세요.

## 인앱 결제 검증

스토어 결제가 완료되면 클라이언트는 HyperX에 영수증 정보를 전달합니다. HyperX는 Console에 등록된 스토어 자격증명으로 provider API를 호출하고 성공한 구매만 저장합니다.

```cs theme={null}
var purchase = await player.ValidatePurchase(
    provider: "google_play",
    productId: "gold_pack_100",
    transactionId: "GPA.1234-5678-9012-34567",
    receiptPayload: new
    {
        purchase_token = "STORE_PURCHASE_TOKEN",
        app_identifier = "com.example.game"
    },
    rewardPayload: new { gold = 100 }
);
```

지원하는 프로덕션 provider는 `google_play`, `app_store`, `one_store`입니다.

| Provider      | 필요한 receipt 값                                                  |
| ------------- | -------------------------------------------------------------- |
| `google_play` | `purchase_token` 또는 `token`, `app_identifier`                  |
| `app_store`   | StoreKit transaction ID를 `transactionId`로 전달, `app_identifier` |
| `one_store`   | `purchase_token` 또는 `token`, `app_identifier`                  |

같은 `provider + transaction_id` 조합은 중복 호출해도 같은 구매 기록을 반환합니다. 결제 성공 후 보상 지급은 서버 구매 이력과 게임 정책을 기준으로 처리하세요.

## 구매 이력과 환불

```cs theme={null}
var history = await player.PurchaseHistory(limit: 20);
```

환불, 취소, 회수 이벤트는 provider webhook으로 서버에 반영됩니다. 클라이언트는 로컬에서 임의로 entitlement를 되돌리지 말고 구매 이력을 다시 조회해 서버 상태와 동기화하세요.

스토어 자격증명과 webhook 설정은 [Provider 연동](/guide/dotnet/provider-integrations)을 참고하세요.
