Skip to main content

Floating Button

Everything beyond login — top-up, account info, change password, logout — is handled by the SDK's floating button by default.

If you want a top-up button inside your own game UI, use the same SDK payment launcher API documented below. Do not call payment backend APIs directly from the game.

After a player logs in, the SDK automatically mounts a round launcher in the corner of the screen (mirroring the native iOS/Android floating bubble). Tapping it opens a small menu:

ItemIconWhat it does
Nạp Coin💰Opens the Alogame payment portal (your game's payment_url) in a new window, already logged in
Tài khoản👤Opens the Alogame profile portal (profile.alogame.vn) for account info, ID verification, change password — already logged in
Đăng xuất🚪Logs out the current account

The menu and these destinations are managed entirely by the SDK. You do not implement payment or profile screens, and you do not pass the session token around — the SDK bridges the player's login into the portal automatically.

Why a redirect instead of an in-game API?

Top-up, identity verification, and password changes are identity-sensitive and live on the shared Alogame portals (game.alogame.vn, profile.alogame.vn). Routing the player there — already authenticated — keeps the game free of payment/PII handling and guarantees one consistent account experience across all Alogame titles.

Lifecycle (automatic)

You don't call anything — the SDK wires the button to auth state:

login success ─▶ floating button appears
logout ─▶ floating button disappears

This is on by default. There is nothing to mount or render.

Disabling it

If your game wants to draw its own menu instead, turn the launcher off at init:

const sdk = await OEGWebSdk.init({
gameId: 38,
baseUrl: 'https://api-sdk.oeg.vn',
floatingButton: false, // ← SDK will not show its launcher
});

With it disabled, the corresponding actions are your responsibility — but note that top-up and profile must still go through the Alogame portals. The simplest and recommended setup is to leave the floating button enabled.

Open payment from your own button

Use this when your game has a custom Nạp / Top-up button in the lobby, shop, or HUD. The SDK opens the CMS-configured core.payment_url, wraps it through SSO exchange, and lands the player in the payment portal already logged in.

topup.ts
import { OEGPayment } from '@alogame/web-sdk';

async function onTopUpButtonClick() {
const result = await OEGPayment.openPaymentPage();
// Aliases: await OEGPayment.open(); or await OEGPayment.pay();

if (!result.success) {
console.error(result.error || 'Cannot open payment page');
return;
}

console.log('Opened payment page:', result.openedUrl);
}

Or call the initialized SDK instance:

topup.ts
const sdk = await OEGWebSdk.init({ gameId: 38, baseUrl: 'https://api-sdk.oeg.vn' });
await sdk.openPaymentPage();
Call from a user gesture

Browsers may block popups opened outside a click/tap handler. Call openPaymentPage() directly from your button's click/tap callback.

Read the raw payment_url

If you need to render a custom link label or debug the configured portal URL, you can read the raw CMS value. Opening should still use openPaymentPage() so the SSO session handoff is applied.

topup.ts
const rawPaymentUrl = OEGPayment.getPaymentUrl();
// same value: OEGPayment.paymentUrl

const sdkPaymentUrl = sdk.getPaymentUrl();
// same value: sdk.paymentUrl

Payment result

types.ts
interface PaymentResult {
success: boolean;
error?: string;
paymentUrl?: string; // raw CMS payment_url
openedUrl?: string; // final URL opened by SDK, usually SSO exchange URL
target?: 'popup' | 'redirect';
}

What the game implements vs. what the SDK handles

ConcernOwner
Login / register / guest / socialGame (see Authentication)
Reacting to login stateGame (onAuthStateChanged)
Game role bindingGame (setGameRole)
Top-up / paymentSDK floating button → payment portal, or Game calls OEGPayment.openPaymentPage()
Account info / ID verification / change passwordSDK floating button → profile portal
LogoutSDK floating button (or OEGAuth.logout())