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

# Economy v2 中的真實貨幣價格追蹤

> 在 PlayFab Economy v2 組合上設定 RealMoneyPriceDetails，並透過 marketplace_transaction_redeemed 事件追蹤營收，以進行分析報告。

> [!NOTE]
>
> Economy v2 現已正式推出。如需支援和意見反應，請前往 [PlayFab 論壇](https://community.playfab.com)。

當玩家透過外部市集 (Apple App Store、Google Play、Steam、Microsoft Store、Nintendo eShop、PlayStation Store) 購買物品時，交易涉及真實世界的金錢。藉由在目錄組合上設定 `RealMoneyPriceDetails`，PlayFab 會在 [marketplace\_transaction\_redeemed](/zh-TW/services/playfab/api-references/events/Inventory/marketplace-transaction-redeemed) 事件中記錄營收金額，讓您能夠建置營收分析和報告。

本教學課程會逐步引導您完成端對端流程：在組合上設定真實貨幣價格、兌換購買項目，以及在事件中檢視營收資料。

## 必要條件

* [PlayFab 開發人員帳戶](https://developer.playfab.com/en-us/sign-up)。
* 在 [Game Manager](https://developer.playfab.com/) 中建立的遊戲。
* 已設定的市集整合 (例如 [Google](/zh-TW/services/playfab/economy-monetization/economy-v2/marketplace/marketplace-integrations/google)、[Apple](/zh-TW/services/playfab/economy-monetization/economy-v2/marketplace/marketplace-integrations/apple) 或 [Microsoft Store](/zh-TW/services/playfab/economy-monetization/economy-v2/marketplace/marketplace-integrations/microsoft))。
* 已發佈的組合，且具有將其連結至市集產品的 [Marketplace Mapping](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/bundles)。

## 步驟 1：在組合上設定真實貨幣價格

將 `RealMoneyPriceDetails` 新增至連結到市集產品的組合。依市集以**最小貨幣單位** (例如，美元使用美分) 指定價格。

### API

使用 [UpdateDraftItem](https://learn.microsoft.com/en-us/rest/api/playfab/economy/catalog/update-draft-item) 將價格新增至現有組合，然後加以發佈：

```json theme={null}
{
  "Item": {
    "Id": "{{StarterPackBundleID}}",
    "Type": "bundle",
    "Title": {
      "NEUTRAL": "Starter Pack"
    },
    "ItemReferences": [
      {
        "Id": "{{LaserSwordID}}",
        "Amount": 1
      },
      {
        "Id": "{{GoldCurrencyID}}",
        "Amount": 500
      }
    ],
    "RealMoneyPriceDetails": {
      "GooglePlayPrices": {
        "USD": 499
      },
      "AppleAppStorePrices": {
        "USD": 499
      },
      "MicrosoftStorePrices": {
        "USD": 499
      }
    },
    "AlternateIds": [
      {
        "Type": "GooglePlay",
        "Value": "com.mygame.starterpack"
      },
      {
        "Type": "AppleAppStore",
        "Value": "com.mygame.starterpack"
      },
      {
        "Type": "MicrosoftStore",
        "Value": "9NBLGGH42CFD"
      }
    ]
  },
  "Publish": true
}
```

### Game Manager

1. 前往 **Economy** > **Catalog (V2)** > **Bundles**。
2. 選取要編輯的組合。
3. 在 **Prices** 區段中，為組合出現的每個市集設定真實貨幣價格。
4. 確定 **Marketplace Mapping** 區段中每個市集的 AlternateIds 都正確。
5. 選取 **Save and publish**。

***

### 價格格式參考

價格使用最小貨幣單位。目前僅支援 **USD**。

| 真實世界價格 | 字典值 |
| - | - |
| \$0.99 | `{"USD": 99}` |
| \$1.39 | `{"USD": 139}` |
| \$4.99 | `{"USD": 499}` |
| \$9.99 | `{"USD": 999}` |
| \$19.99 | `{"USD": 1999}` |

只為您的遊戲使用的市集設定價格。支援的市集屬性如下：

* `AppleAppStorePrices`
* `GooglePlayPrices`
* `MicrosoftStorePrices`
* `NintendoEShopPrices`
* `PlayStationStorePrices`
* `SteamPrices`

### 每個市集設定不同價格

如果您在各商店為遊戲設定不同的價格，請個別設定每個市集屬性：

```json theme={null}
"RealMoneyPriceDetails": {
  "GooglePlayPrices": {
    "USD": 499
  },
  "AppleAppStorePrices": {
    "USD": 529
  },
  "SteamPrices": {
    "USD": 449
  }
}
```

## 步驟 2：玩家進行購買並兌換

玩家從外部市集購買物品後，您的遊戲會呼叫適當的兌換 API：

| 市集 | 兌換 API |
| - | - |
| Google Play | [RedeemGooglePlayInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-google-play-inventory-items) |
| Apple App Store | [RedeemAppleAppStoreInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-apple-app-store-inventory-items) |
| Microsoft Store | [RedeemMicrosoftStoreInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-microsoft-store-inventory-items) |
| Steam | [RedeemSteamInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-steam-inventory-items) |
| Nintendo eShop | [RedeemNintendoEShopInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-nintendo-e-shop-inventory-items) |
| PlayStation Store | [RedeemPlayStationStoreInventoryItems](https://learn.microsoft.com/en-us/rest/api/playfab/economy/inventory/redeem-play-station-store-inventory-items) |

當 PlayFab 處理兌換時，它會：

1. 將市集收據與組合的 `AlternateId` 進行比對。
2. 將組合的內容授與至玩家的庫存。
3. 發出 `marketplace_transaction_redeemed` 事件，其中包含來自相符組合的 `RealMoneyPrices`。

## 步驟 3：在事件中檢視營收

成功兌換之後，系統會發出 `marketplace_transaction_redeemed` 事件，其中包含真實貨幣價格資料。您可以在 Game Manager 中找到此事件，或透過資料管線查詢。

### 在 Game Manager 中檢視

1. 前往 **Data** > **Event History** (位於 **Analyze** 區段下)。
2. 搜尋 `marketplace_transaction_redeemed` 事件名稱。
3. 選取事件以檢視其詳細資料，包括 `RealMoneyPrices` 欄位。

### 範例事件承載

Starter Pack (\$4.99 USD) 的 Google Play 兌換會產生如下的事件：

```json theme={null}
{
  "EventName": "marketplace_transaction_redeemed",
  "Marketplace": "GooglePlay",
  "MarketplaceTransctionId": "GPA.1234-5678-9012-34567",
  "MarketplaceAlternateId": "com.mygame.starterpack",
  "Amount": 1,
  "ItemId": "{{StarterPackBundleID}}",
  "ItemType": "bundle",
  "RealMoneyPrices": {
    "USD": 499
  }
}
```

從 Apple App Store 兌換的相同組合 (定價為 \$5.29 USD) 會產生：

```json theme={null}
{
  "RealMoneyPrices": {
    "USD": 529
  }
}
```

PlayFab 會使用發生兌換之特定市集的價格。

### 查詢營收資料

您可以將事件資料用於自訂分析。例如，若要計算一段期間的總營收，請查詢所有 `marketplace_transaction_redeemed` 事件，並加總 `RealMoneyPrices.USD` 值：

```text theme={null}
Total revenue = Sum of (RealMoneyPrices.USD × Amount) across all events
```

> [!NOTE]
>
> `RealMoneyPrices` 反映的是您在 `RealMoneyPriceDetails` 中設定的內容，而不是市集實際收取的金額。請讓您的價格與市集上架資訊保持同步，以取得準確的報告。

## 最佳做法

* **一律在市集組合上設定 `RealMoneyPriceDetails`。** 若未設定，兌換事件中的 `RealMoneyPrices` 欄位會是空的，您將無法掌握營收狀況。
* **使用最小貨幣單位。** 對於 USD，請以美分提供價格 (例如，\$4.99 為 `499`)。
* **只填入您使用的市集。** 您不需要為每個市集設定價格，只需設定您的遊戲所發佈的市集即可。
* **讓價格與市集上架資訊保持同步。** 當您在外部市集更新價格時，請更新 `RealMoneyPriceDetails` 中對應的屬性，以維持準確的報告。
* **價格不同時，請依市集設定價格。** 如果您的遊戲在各商店的定價不同，請使用各市集屬性來反映每個平台上的實際價格。

## 另請參閱

* [真實貨幣價格參考](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/real-money-prices)
* [Economy v2 組合](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/bundles)
* [詐騙防護快速入門](/zh-TW/services/playfab/economy-monetization/economy-v2/fraud-prevention/quickstart)
* [市集整合](/zh-TW/services/playfab/economy-monetization/economy-v2/marketplace/marketplace-integrations/overview)
* [marketplace\_transaction\_redeemed 事件](/zh-TW/services/playfab/api-references/events/Inventory/marketplace-transaction-redeemed)


## Related topics

- [Economy v2 真實貨幣價格](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/real-money-prices.md)
- [Economy (舊版) 中的商店與促銷](/zh-TW/services/playfab/economy-monetization/economy/tutorials/stores-and-sales.md)
- [目錄概觀](/zh-TW/services/playfab/economy-monetization/economy-v2/catalog/catalog-overview.md)
- [在 Economy (舊版) 中取得玩家的累計價值 (VTD)](/zh-TW/services/playfab/economy-monetization/economy/tutorials/getting-a-players-vtd.md)
- [目錄 (舊版 Economy)](/zh-TW/services/playfab/economy-monetization/economy/items/catalogs.md)
