ドキュメント

​
​

Development

User Acquisition

Monetization

産業

In-App Purchasing

IAP Client API

IAP SDK API

Webshop Admin API

Webshop Client API

In-App Purchasing

LiveOps
​
​
使用の準備
  • 概要
  • IAP の概要
  • IAP v5の新機能
  • IAP v4からv5へのアップグレード
コンシューマー (D2C)への直接支払い
  • コンシューマー (D2C)支払いプロバイダーへの直接送信
    • D2C支払いプロバイダーの統合ワークフロー
      • Create Remote Catalog
      • Initialize services to handle the start up sequence
      • Fetch Remote Catalog
      • Configure a webhook or Cloud Code module for purchase fulfillment
      • Configure your payment provider
      • Add a routing rule
      • Fulfill purchases
      • Test your integration
    • 購入の開始
    • AppleおよびGoogleの外部購入要件への準拠
    • ディープリンク成功URL例
ウェブショップ
  • 概要
  • 使用の準備
  • ビルドと公開
  • 設定
  • ゲームに接続
  • 管理
  • Webshop のトラブルシューティング
プラットフォームネイティブ
  • プラットプラットフォームネイティブの IAP の設定
  • Codeless IAP
カタログとストア管理
  • 製品カタログの作成
  • サポートされているストア
  • リファレンス
購入 /Purchases
  • 購入管理とフルフィルメント
IAP パフォーマンスの監視
  • 概要
  • IAP収益パフォーマンス
  • D2C パフォーマンス
プライバシー
  • プライバシーと同意
  1. Unity アプリ内課金
  2. コンシューマー向け直接(D2C)支払いプロバイダー

起動シーケンスをハンドルするサービスの初期化

Unity Gaming Services、Authentication、アプリ内課金(IAP)を初期化して、Direct to Consumer (D2C)の支払いプロバイダーと統合できるようにします。
読み終わるまでの所要時間 4 分
最終更新 2ヶ月前

IAP の起動シーケンスをハンドルするために Unity Gaming Services(UGS)を初期化するスクリプトを作成します。このスタートアップスクリプトは、以下の行うことができます。
  1. Unity Gaming Services を初期化します。
  2. Authenticationイベント ハンドラーを設定します。
  3. サインインします。
  4. IAP を初期化し、リモートカタログをフェッチします。詳細については、「 リモートカタログの取得 」を参照してください。
注
UGS を初期化する前に、環境を設定 します。
初期化スクリプトで、Inspector で
PurchaseManager
コンポーネントを割り当てていることを確認します。
PurchaseManager
コンポーネントは、次のリモートカタログ取得ステップの一部として作成されます。

Initialize services スクリプト例

以下のスクリプト例は、
ServiceOrchestrator
という名前です。
重要
推奨されるベスト プラクティスは、認証メソッドとして匿名ログインを使用しないことです。匿名ログインを使用すると、セッション トークンが紛失した後に購入が保持されないためです。アプリケーションで円滑なプラットフォーム固有のプロバイダーが利用できない場合は、匿名認証とリンクを参照してください。
using System;using System.Threading.Tasks;using Unity.Services.Authentication;using Unity.Services.Core;using UnityEngine;// Ensure you have reference to your PurchaseManager namespace if applicablepublic class ServiceOrchestrator :MonoBehaviour{ // Assign this in the Inspector public PurchaseManager purchaseManager; async void Awake() { try { // 1.Unity Gaming Services の初期化 await Unity.Services.Core.UnityServices.InitializeAsync(); // 2.認証イベント ハンドラの設定 SetupEvents(); // 3.サインインする await SignUpAnonymouslyAsync(); // 4.IAP とフェッチカタログの初期化 await purchaseManager.InitializeIAP(); } catch (例外 e) { Debug.LogException(e); } } // Setup authentication event handlers if desired void SetupEvents() { AuthenticationService.Instance.SignedIn += () => { // Shows how to get a playerID Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}"); // Shows how to get an access token Debug.Log($"Access Token: {AuthenticationService.Instance.AccessToken}"); }; AuthenticationService.Instance.SignInFailed += (err) => { Debug.LogError(err); }; AuthenticationService.Instance.SignedOut += () => { Debug.Log("Player signed out."); }; AuthenticationService.Instance.Expired += () => { Debug.Log("Player session could not be refreshed and expired."); }; } // Sign in async Task SignUpAnonymouslyAsync() { try { await AuthenticationService.Instance.SignInAnonymouslyAsync(); Debug.Log("Sign in anonymously succeeded!"); Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}"); } catch (AuthenticationException など) { // Compare error code to AuthenticationErrorCodes Debug.LogException(ex); } catch (RequestFailedException など) { // Compare error code to CommonErrorCodes Debug.LogException(ex); } }}

次のステップ

このページは、IAPでD2C支払いプロバイダーを設定するワークフローの一部です。このワークフローを続行するには、以下のオプションのいずれかを選択します。
Integrate D2C payment providers
Integrate D2C payment provider with IAP ワークフロー (D2C 支払いプロバイダーと IAP ワークフローの統合) ページに戻ります。
Fetch your Remote Catalog
ワークフローの次のステップに進み、D2C支払いプロバイダーを設定します。

Copyright © 2026 Unity Technologies
法規事項プライバシーポリシークッキーDocumentation Terms of Use私の個人情報を販売または共有しないプライバシーに関する選択 (クッキー設定)

"Unity" の名称、Unity のロゴ、およびその他の Unity の商標は、米国およびその他の国における Unity Technologies またはその関係会社の商標または登録商標です (詳しくはこちら)。その他の名称またはブランドは該当する所有者の商標です。

一部のページは利便性向上のため機械翻訳を使用しており、内容に不正確な表現が含まれる場合があります。内容に齟齬または不一致が生じた場合は、英語版を正本とします。

  • このページ
    • Initialize services スクリプト例

    • 次のステップ


このページの問題を報告する