GS2-Showcase
GS2-SDK for Game Engine Reference
SDK for Game Engine
Models
EzSalesItem
Showcase
Set the price required to purchase the product and the reward earned for the purchase of the product.
Type | Description | |
---|---|---|
name | string | Product Name |
metadata | string | metadata |
consumeActions | List<EzConsumeAction> | List of Consumption Action |
acquireActions | List<EzAcquireAction> | List of Acquire Action |
EzSalesItemGroup
Product Group
A product group is an entity for display on a showcase.
The first product that is determined to be available for purchase is actually displayed on the shelves.
This can be used for products that are discounted only for the first time, or for a system in which the contents of products change depending on the number of times they are purchased, such as a step-up gacha.
Type | Description | |
---|---|---|
name | string | Product Group Name |
metadata | string | metadata |
salesItems | List<EzSalesItem> | Products to be included in the product group |
EzShowcase
Showcase
The sales period can be set for the display shelf.
Type | Description | |
---|---|---|
name | string | Product Name |
metadata | string | metadata |
displayItems | List<EzDisplayItem> | List of Products on display |
EzDisplayItem
Type | Description | |
---|---|---|
displayItemId | string | Displayed Item ID |
type | enum ['salesItem', 'salesItemGroup'] | Type |
salesItem | EzSalesItem | Products to be displayed |
salesItemGroup | EzSalesItemGroup | Product group to be displayed |
EzConfig
Type | Description | |
---|---|---|
key | string | Name |
value | string | Value |
EzConsumeAction
Type | Description | |
---|---|---|
action | enum [] | Types of actions to be performed in the stamp task |
request | string | JSON of the obtain request |
EzAcquireAction
Type | Description | |
---|---|---|
action | enum [] | Types of actions to be performed in the stamp sheet |
request | string | JSON of request |
Methods
buy
buy
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Showcase(
showcaseName: "showcase-0001"
);
var result = await domain.BuyAsync(
displayItemId: "display-item-0001",
quantity: null,
config: null
);
// New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
// エラーが発生すると TransactionException がスローされます。
// TransactionException::Retry() でリトライが可能です。
// In New Experience, stamp sheets are automatically executed at the SDK level.
// If an error occurs, a TransactionException is thrown.
// you can retry with TransactionException::Retry().
}
///////////////////////////////////////////////////////////////
// New Experience
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
var future = profile.Initialize();
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Showcase(
showcaseName: "showcase-0001"
);
var future = domain.Buy(
displayItemId: "display-item-0001",
quantity: null,
config: null
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
// New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
// エラーが発生すると TransactionException がスローされます。
// TransactionException::Retry() でリトライが可能です。
// In New Experience, stamp sheets are automatically executed at the SDK level.
// If an error occurs, a TransactionException is thrown.
// you can retry with TransactionException::Retry().
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzBuyResult> asyncResult = null;
var current = gs2.Showcase.Buy(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace-0001",
showcaseName: "showcase-0001",
displayItemId: "display-item-0001",
quantity: null,
config: null
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
}
const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
"your client id",
"your client secret",
Gs2::Core::Model::ERegion::ApNorthEast1,
MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())
);
Gs2::UE5::Core::Domain::FGs2DomainPtr Gs2;
{
const auto Future = Profile->Initialize();
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Gs2 = Future->GetTask().Result();
Future->EnsureCompletion();
}
// Up to this line is the initialization process.
{
const auto Domain = Gs2->Showcase->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Showcase(
"showcase-0001" // showcaseName
);
const auto Future = Domain->Buy(
"display-item-0001", // displayItemId
nullptr, // quantity
nullptr // config
);
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
}
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->showcase.buy(
[](gs2::ez::account::AsyncEzBuyResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "showcase.buy failed.");
}
else
{
Item = r.getResult()->getItem();
TransactionId = r.getResult()->getTransactionId();
StampSheet = r.getResult()->getStampSheet();
StampSheetEncryptionKeyId = r.getResult()->getStampSheetEncryptionKeyId();
AutoRunStampSheet = r.getResult()->getAutoRunStampSheet();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace-0001"), // namespaceName
TCHAR_TO_ANSI("showcase-0001"), // showcaseName
TCHAR_TO_ANSI("display-item-0001"), // displayItemId
null // quantity,
null // config
);
Buy Product
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
showcaseName | string | ✓ | ~ 128 chars | Product Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
displayItemId | string | ✓ | UUID | ~ 36 chars | Displayed Item ID |
quantity | int | ✓ | 1 | 1 ~ 1000 | Purchase Quantity |
config | List<EzConfig> | [] | Set values to be applied to stamp sheet variables |
Result
Type | Description | |
---|---|---|
item | EzSalesItem | Product |
transactionId | string | Transaction ID of the stamp sheet issued |
stampSheet | string | Stamp sheets used to execute the purchase process |
stampSheetEncryptionKeyId | string | Cryptographic key GRN used for stamp sheet signature calculations |
autoRunStampSheet | bool | Is stamp sheet auto-execution enabled? |
getShowcase
getShowcase
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Showcase(
showcaseName: "showcase-0001"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// New Experience
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
var future = profile.Initialize();
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Showcase(
showcaseName: "showcase-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetShowcaseResult> asyncResult = null;
var current = gs2.Showcase.GetShowcase(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace-0001",
showcaseName: "showcase-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
const auto Profile = MakeShared<Gs2::UE5::Util::FProfile>(
"your client id",
"your client secret",
Gs2::Core::Model::ERegion::ApNorthEast1,
MakeShareable<Gs2::UE5::Util::IReOpener>(new Gs2::UE5::Util::FGs2BasicReOpener())
);
Gs2::UE5::Core::Domain::FGs2DomainPtr Gs2;
{
const auto Future = Profile->Initialize();
Future->StartSynchronousTask();
if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;
Gs2 = Future->GetTask().Result();
Future->EnsureCompletion();
}
// Up to this line is the initialization process.
{
const auto Domain = Gs2->Showcase->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Showcase(
"showcase-0001" // showcaseName
);
const auto item = Domain.Model();
}
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->showcase.getShowcase(
[](gs2::ez::account::AsyncEzGetShowcaseResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "showcase.getShowcase failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace-0001"), // namespaceName
TCHAR_TO_ANSI("showcase-0001") // showcaseName
);
Retrieve showcase
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
showcaseName | string | ✓ | ~ 128 chars | Product Name |
Result
Type | Description | |
---|---|---|
item | EzShowcase | Showcase |