# Introduction

> What Baziness gives your game, how the parts fit together, and how this wiki is organised.

## What Baziness is

**Baziness** is the game platform of **Gita Games**. When your game integrates it, your players get:

- **A Baziness account:** they sign in with their phone number, and the same account works in every Baziness game.
- **Gita coins** (گیتا کوین): the platform currency. Players earn it in games and spend it on real prizes.
- **Baziness pages inside your game:** sign-in, profile, the «انتخاب جایزه» reward shop, and your game's own offer page.
- **Baziness Pay:** real-money purchases through a hosted payment page.

These come as two **separate** integrations. You can ship either one alone, or both together:

| Integration | What the player gets | Who talks to Baziness | What you need |
| --- | --- | --- | --- |
| **Baziness platform** | accounts, Gita coins, Baziness pages | your **server** calls the platform API; your **client** shows the pages and reads the coin balance | client id, client secret, platform package name |
| **Baziness Pay** | real-money purchases | your **server** calls the Pay API; your **client** opens the payment page | Pay package name, SKUs registered in the Baziness dashboard |

## How the parts fit together

```mermaid
flowchart LR
  subgraph Device["Player device"]
    G["Your game client"]
    S["Baziness sheet<br/>iframe → baziness.com"]
    P["Payment tab<br/>pay.baziness.com/buy"]
  end
  subgraph Backend["Your backend"]
    B["Game server<br/>(holds clientId + clientSecret)"]
  end
  K[("Baziness platform API")]
  Y[("Baziness Pay API")]
  G -- "/api/platform/*" --> B
  G -- "/api/shop/purchase/*" --> B
  B -- "client/auth · create-user · add-coin …" --> K
  B -- "get_payment · verify_payment · consume" --> Y
  G -- "user/get-coin (user token)" --> K
  G -- "opens" --> S
  S -- "postMessage: login · logout · close" --> G
  G -- "opens" --> P
```

The client calls Baziness directly in only two cases: it shows Baziness **pages**, and it reads the coin balance (`user/get-coin`) with the player's own token. Everything else goes through **your server**, because only your server holds the client secret.

## The five golden rules

1. **The client secret never leaves your server.** The browser or app gets only public settings and the player's own token.
2. **The server decides and the client only displays.** Account links, coin grants and purchases are always checked on the server.
3. **Every Baziness page link carries `packageName` and `sdkType=js`.** Without `sdkType=js` the page can't talk to your game, so it can't even close itself.
4. **The game keeps working without Baziness.** If the platform is switched off or unreachable, hide the Baziness parts and carry on.
5. **Every payout has a unique, repeatable id.** A retry, a double tap or a crash must never pay twice.

## Environments

| | Development (test games) | Production |
| --- | --- | --- |
| Platform API | `https://platform-dev.karizmastudios.org/api` | `https://platform.karizmastudio.com/api` |
| Baziness pages | `https://platform-web-dev.karizmastudios.org` | `https://baziness.com` |
| Baziness Pay | `https://pay-dev.karizmastudios.org` | `https://pay.baziness.com` |
| Signing in | **any phone number, code `111111`** (no SMS is sent) | real phone number and SMS code |
| Test purchases | «خرید آزمایشی» on the payment page (no real payment) | real payment |

Each environment has **its own client id and secret**.

## How this wiki is organised

| Section | What is in it | Code? |
| --- | --- | --- |
| **Getting started** | this page, and [the integration step by step](setup.md) | no |
| **API** | every endpoint in order: what it does, when to call it, request, response and rules | only requests and responses |
| **Guides** | the flows: login, Gita coins, the reward page, the tutorial offer page, links | no |
| **Code samples** | ready-made server code (TypeScript, C#, Python) and client code (web, React, Cocos Creator, Unity), including the web view | yes |
| **Example game** | a complete open-source game that uses everything here: [play it and download it](example.md) | the whole project |
| **Reference** | the go-live checklist, troubleshooting, and every endpoint in one table | no |

Every page can be downloaded as **Markdown** or **PDF** from the buttons under its title. The sidebar has the full guide in both formats.
