# hirotomasato/paygateme architecture

> Architecture diagram of the GitHub repository hirotomasato/paygateme, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hirotomasato/paygateme
- Repository: https://github.com/hirotomasato/paygateme

## Overview

PayGateMe is a Go SDK for Shopee and GoPay merchant payments. Its main workflow is provider authentication (OTP or restored session), merchant/store and QRIS setup, payment creation with a unique amount and dynamic QR, then transaction-feed polling and settlement callbacks. The graph includes both provider integrations, shared payment reconciliation, and QRIS conversion. Some wiring is documented in the README rather than shown in sampled source; those relationships are limited to documented calls and data flow.

Main entry points: [`payment/service.go`](https://github.com/hirotomasato/paygateme/blob/main/payment/service.go) (Payment service), [`shopee/provider.go`](https://github.com/hirotomasato/paygateme/blob/main/shopee/provider.go) (Shopee provider), [`gopay/http.go`](https://github.com/hirotomasato/paygateme/blob/main/gopay/http.go) (GoPay HTTP client), [`shopee/http.go`](https://github.com/hirotomasato/paygateme/blob/main/shopee/http.go) (Shopee HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared domain"]
  node_domain["Domain types/errors"]
  node_utils["Shared utilities"]
end

subgraph group_shopee["Shopee provider"]
  node_shopee_provider["Shopee provider<br/>[provider.go]"]
  node_shopee_auth["OTP and SSO auth<br/>[auth.go]"]
  node_shopee_http["Shopee HTTP client<br/>[http.go]"]
  node_shopee_merchant["Merchant and stores<br/>[merchant.go]"]
  node_shopee_feed["Shopee transaction feed<br/>[feed.go]"]
  node_shopee_api{{"Shopee API"}}
end

subgraph group_gopay["GoPay provider"]
  node_gopay_provider["GoPay provider"]
  node_gopay_auth["OTP and token auth<br/>[auth.go]"]
  node_gopay_tokens["Token manager<br/>[token.go]"]
  node_gopay_http["GoPay HTTP client<br/>[http.go]"]
  node_gopay_merchant["Merchant profile<br/>[merchant.go]"]
  node_gopay_feed["GoPay transaction feed<br/>[feed.go]"]
  node_gopay_api{{"GoID and GoBiz APIs"}}
end

subgraph group_payment["Payment runtime"]
  node_service["Payment service<br/>[service.go]"]
  node_allocator["Unique amount allocator<br/>[allocator.go]"]
  node_matcher["Settlement matcher<br/>[matcher.go]"]
  node_store[("Payment store<br/>[store.go]")]
  node_qris["QRIS parse and convert<br/>[convert.go]"]
  node_emv["EMV and CRC<br/>[emv.go]"]
end

node_user(("SDK caller"))
node_callbacks(("Payment callbacks"))

node_user -->|"calls"| node_shopee_provider
node_shopee_provider -->|"delegates auth"| node_shopee_auth
node_shopee_provider -->|"manages merchant"| node_shopee_merchant
node_shopee_provider -->|"creates service"| node_service
node_shopee_provider -->|"binds and converts"| node_qris
node_shopee_auth -->|"sends requests"| node_shopee_http
node_shopee_merchant -->|"sends requests"| node_shopee_http
node_shopee_feed -->|"fetches feed"| node_shopee_http
node_shopee_http -->|"HTTP requests"| node_shopee_api
node_user -->|"calls"| node_gopay_provider
node_gopay_provider -->|"delegates auth"| node_gopay_auth
node_gopay_provider -->|"resolves profile"| node_gopay_merchant
node_gopay_provider -->|"creates service"| node_service
node_gopay_provider -.->|"uses static QRIS"| node_qris
node_gopay_auth -->|"sends requests"| node_gopay_http
node_gopay_tokens -->|"refreshes through"| node_gopay_auth
node_gopay_http -->|"gets valid token"| node_gopay_tokens
node_gopay_merchant -->|"sends requests"| node_gopay_http
node_gopay_feed -->|"fetches feed"| node_gopay_http
node_gopay_http -->|"HTTP requests"| node_gopay_api
node_service -->|"allocates amount"| node_allocator
node_service -->|"reads and writes"| node_store
node_service -->|"fetches transactions"| node_shopee_feed
node_service -->|"fetches transactions"| node_gopay_feed
node_service -->|"reconciles feed"| node_matcher
node_service -->|"builds payment QR"| node_qris
node_qris -->|"parses and builds"| node_emv
node_emv -->|"computes CRC"| node_utils
node_service -->|"emits settlement"| node_callbacks
node_shopee_auth -->|"validates phone"| node_utils
node_shopee_provider -->|"uses domain types"| node_domain
node_service -->|"uses payment types"| node_domain
node_matcher -->|"matches transactions"| node_domain

click node_domain "https://github.com/hirotomasato/paygateme/tree/main/core"
click node_shopee_provider "https://github.com/hirotomasato/paygateme/blob/main/shopee/provider.go"
click node_shopee_auth "https://github.com/hirotomasato/paygateme/blob/main/shopee/auth.go"
click node_shopee_http "https://github.com/hirotomasato/paygateme/blob/main/shopee/http.go"
click node_shopee_merchant "https://github.com/hirotomasato/paygateme/blob/main/shopee/merchant.go"
click node_shopee_feed "https://github.com/hirotomasato/paygateme/blob/main/shopee/feed.go"
click node_gopay_auth "https://github.com/hirotomasato/paygateme/blob/main/gopay/auth.go"
click node_gopay_tokens "https://github.com/hirotomasato/paygateme/blob/main/gopay/token.go"
click node_gopay_http "https://github.com/hirotomasato/paygateme/blob/main/gopay/http.go"
click node_gopay_merchant "https://github.com/hirotomasato/paygateme/blob/main/gopay/merchant.go"
click node_gopay_feed "https://github.com/hirotomasato/paygateme/blob/main/gopay/feed.go"
click node_service "https://github.com/hirotomasato/paygateme/blob/main/payment/service.go"
click node_allocator "https://github.com/hirotomasato/paygateme/blob/main/payment/allocator.go"
click node_matcher "https://github.com/hirotomasato/paygateme/blob/main/payment/matcher.go"
click node_store "https://github.com/hirotomasato/paygateme/blob/main/payment/store.go"
click node_qris "https://github.com/hirotomasato/paygateme/blob/main/qris/convert.go"
click node_emv "https://github.com/hirotomasato/paygateme/blob/main/qris/emv.go"
click node_utils "https://github.com/hirotomasato/paygateme/tree/main/utils"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_domain,node_utils toneBlue
class node_shopee_provider,node_shopee_auth,node_shopee_http,node_shopee_merchant,node_shopee_feed,node_shopee_api toneAmber
class node_gopay_provider,node_gopay_auth,node_gopay_tokens,node_gopay_http,node_gopay_merchant,node_gopay_feed,node_gopay_api toneMint
class node_service,node_allocator,node_matcher,node_store,node_qris,node_emv toneRose
class node_user,node_callbacks toneIndigo
```

## Components

### Shared domain

- [Domain types/errors](https://github.com/hirotomasato/paygateme/tree/main/core): `core`
- [Shared utilities](https://github.com/hirotomasato/paygateme/tree/main/utils): `utils`

### Shopee provider

- [Shopee provider](https://github.com/hirotomasato/paygateme/blob/main/shopee/provider.go): `shopee/provider.go`
- [OTP and SSO auth](https://github.com/hirotomasato/paygateme/blob/main/shopee/auth.go): `shopee/auth.go`
- [Shopee HTTP client](https://github.com/hirotomasato/paygateme/blob/main/shopee/http.go): `shopee/http.go`
- [Merchant and stores](https://github.com/hirotomasato/paygateme/blob/main/shopee/merchant.go): `shopee/merchant.go`
- [Shopee transaction feed](https://github.com/hirotomasato/paygateme/blob/main/shopee/feed.go): `shopee/feed.go`
- **Shopee API**

### GoPay provider

- **GoPay provider**
- [OTP and token auth](https://github.com/hirotomasato/paygateme/blob/main/gopay/auth.go): `gopay/auth.go`
- [Token manager](https://github.com/hirotomasato/paygateme/blob/main/gopay/token.go): `gopay/token.go`
- [GoPay HTTP client](https://github.com/hirotomasato/paygateme/blob/main/gopay/http.go): `gopay/http.go`
- [Merchant profile](https://github.com/hirotomasato/paygateme/blob/main/gopay/merchant.go): `gopay/merchant.go`
- [GoPay transaction feed](https://github.com/hirotomasato/paygateme/blob/main/gopay/feed.go): `gopay/feed.go`
- **GoID and GoBiz APIs**

### Payment runtime

- [Payment service](https://github.com/hirotomasato/paygateme/blob/main/payment/service.go): `payment/service.go`
- [Unique amount allocator](https://github.com/hirotomasato/paygateme/blob/main/payment/allocator.go): `payment/allocator.go`
- [Settlement matcher](https://github.com/hirotomasato/paygateme/blob/main/payment/matcher.go): `payment/matcher.go`
- [Payment store](https://github.com/hirotomasato/paygateme/blob/main/payment/store.go): `payment/store.go`
- [QRIS parse and convert](https://github.com/hirotomasato/paygateme/blob/main/qris/convert.go): `qris/convert.go`
- [EMV and CRC](https://github.com/hirotomasato/paygateme/blob/main/qris/emv.go): `qris/emv.go`

### Other components

- **SDK caller**
- **Payment callbacks**

## Connections

- SDK caller → Shopee provider: calls
- Shopee provider → OTP and SSO auth: delegates auth
- Shopee provider → Merchant and stores: manages merchant
- Shopee provider → Payment service: creates service
- Shopee provider → QRIS parse and convert: binds and converts
- OTP and SSO auth → Shopee HTTP client: sends requests
- Merchant and stores → Shopee HTTP client: sends requests
- Shopee transaction feed → Shopee HTTP client: fetches feed
- Shopee HTTP client → Shopee API: HTTP requests
- SDK caller → GoPay provider: calls
- GoPay provider → OTP and token auth: delegates auth
- GoPay provider → Merchant profile: resolves profile
- GoPay provider → Payment service: creates service
- GoPay provider → QRIS parse and convert: uses static QRIS
- OTP and token auth → GoPay HTTP client: sends requests
- Token manager → OTP and token auth: refreshes through
- GoPay HTTP client → Token manager: gets valid token
- Merchant profile → GoPay HTTP client: sends requests
- GoPay transaction feed → GoPay HTTP client: fetches feed
- GoPay HTTP client → GoID and GoBiz APIs: HTTP requests
- Payment service → Unique amount allocator: allocates amount
- Payment service → Payment store: reads and writes
- Payment service → Shopee transaction feed: fetches transactions
- Payment service → GoPay transaction feed: fetches transactions
- Payment service → Settlement matcher: reconciles feed
- Payment service → QRIS parse and convert: builds payment QR
- QRIS parse and convert → EMV and CRC: parses and builds
- EMV and CRC → Shared utilities: computes CRC
- Payment service → Payment callbacks: emits settlement
- OTP and SSO auth → Shared utilities: validates phone
- Shopee provider → Domain types/errors: uses domain types
- Payment service → Domain types/errors: uses payment types
- Settlement matcher → Domain types/errors: matches transactions
