Skip to main content

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

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"

Open MShop in WebView

Game can call this API to directly open MShop in the embedded WebView, which supports auto-login.

Region Configuration
  1. The region format should be uppercase, such as TW, TH, etc. Then the link will be set to the corresponding region's MShop website.
  2. 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.
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
}
});

Open MShop in Browser

MShopPaymentManager.openMShop(this, getRegion(), getServerId(), getRoleId(), result->{
if(result.isSuccess()){
// open browser succeed, nothing needs to do
} else {
MSDKError error = result.getErrorInfo();
// handle error
}
});
MShopPaymentManager.getMShopLink(activity, region, serverId, roleId, false, result -> {
if (result.isSuccess()) {
// Get link succeed
} else {
// handle error
}

});