MShop Purchase
Overview
MShop is Garena's digital marketplace that allows players to purchase in-game items and currency. The SDK provides multiple ways to integrate MShop into your game.
Setup
- Android
- Unity
- Unreal
Add the following code in build.gradle on the app-level, and replace $msdk_version with the actual MSDK version.
implementation "com.garena.sdk.android:payment-mshop:$msdk_version"
Need to add mshop feature when packaging unitypackage.
Need to add mshop feature when packaging unreal plugin.
Open MShop in WebView
Game can call this API to directly open MShop in the embedded WebView, which supports auto-login.
Region Configuration
- The region format should be uppercase, such as
TW,TH, etc. Then the link will be set to the corresponding region's MShop website. - If the region is empty or null, the link will be set to https://shop.garena.com, and redirect to the region's MShop website based on client IP.
- Android
- Unity
- Unreal
MShopPaymentManager.openEmbeddedMShop(
this, // activity instance
getRegion(),
getServerId(),
getRoleId(),
new MShopPaymentManager.MShopInteractionListener() {
@Override
public void onError(@NonNull MSDKError error) {
// Handle error
}
@Override
public void onDismiss() {
// Refresh your in-game balance
}
});
GMSDKHandler.MShopClient.openEmbeddedMShop(region, serverID, roleID, LogScene.LogResult, OnDismiss);
MsdkCallbacks->OnOpenEmbeddedMShopError.AddDynamic(this, &UTestMShopWidget::OnOpenEmbeddedMShopError);
MsdkCallbacks->OnOpenEmbeddedMShopDismiss.AddDynamic(this, &UTestMShopWidget::OnOpenEmbeddedMShopDismiss);
UMsdkShop::OpenEmbeddedMShop(Region, ServerId, RoleId);
Open MShop in Browser
- Android
- Unity
- Unreal
MShopPaymentManager.openMShop(this, getRegion(), getServerId(), getRoleId(), result->{
if(result.isSuccess()){
// open browser succeed, nothing needs to do
} else {
MSDKError error = result.getErrorInfo();
// handle error
}
});
GMSDKHandler.MShopClient.OpenMShop(region, serverID, roleID, LogScene.LogResult);
MsdkCallbacks->OnOpenMShopInBrowser.AddDynamic(this, &UTestMShopWidget::OnOpenMShop);
UMsdkShop::OpenMShop(Region, ServerId, RoleId);
Get MShop Link
- Android
- Unity
- Unreal
MShopPaymentManager.getMShopLink(activity, region, serverId, roleId, false, result -> {
if (result.isSuccess()) {
// Get link succeed
} else {
// handle error
}
});
GMSDKHandler.MShopClient.GetMShopLink(region, serverID, roleID, embedded, LogScene.LogResult);
MsdkCallbacks->OnGetMShopLink.AddDynamic(this, &UTestMShopWidget::OnGetMShopLink);
UMsdkShop::GetMShopLink(Region, ServerId, RoleId);