# go-pay/gopay architecture

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

- Interactive diagram: https://gitdiagram.com/go-pay/gopay
- Repository: https://github.com/go-pay/gopay

## Overview

GoPay is a Go SDK for integrating with multiple payment providers. A consuming application calls a provider SDK, which handles provider-specific requests and returns responses; Apple’s offering also covers payment verification. The README documents the supported providers and versions. Sampled client code shows several integrations using the shared HTTP client, but most API-method internals were not sampled, so provider-level flows are documented at the SDK boundary rather than expanded into speculative domain stages.

Main entry points: [`pkg/xhttp/client.go`](https://github.com/go-pay/gopay/blob/main/pkg/xhttp/client.go) (HTTP client), [`wechat`](https://github.com/go-pay/gopay/tree/main/wechat) (WeChat Pay V2), [`qq`](https://github.com/go-pay/gopay/tree/main/qq) (QQ Pay), [`douyin`](https://github.com/go-pay/gopay/tree/main/douyin) (Douyin Pay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_china["China payment SDKs"]
  node_wechat_v2["WeChat Pay V2"]
  node_qq["QQ Pay"]
  node_douyin["Douyin Pay"]
  node_cmb["CMB Pay"]
  node_allinpay["Allinpay"]
  node_lakala["Lakala"]
  node_saobei["Saobei"]
end

subgraph group_other["Other payment SDKs"]
  node_paypal["PayPal"]
  node_apple["Apple verification"]
end

subgraph group_versions["Versioned APIs"]
  node_alipay_v2["Alipay SDK"]
  node_alipay_v3["Alipay V3"]
  node_wechat_v3["WeChat V3"]
end

subgraph group_transport["Shared transport"]
  node_xhttp["HTTP client<br/>[client.go]"]
end

node_app(("Integrating application"))
node_wechat_service(("WeChat Pay"))
node_qq_service(("QQ Pay"))
node_douyin_service(("Douyin Pay"))
node_cmb_service(("CMB Pay"))
node_allinpay_service(("Allinpay service"))
node_lakala_service(("Lakala service"))
node_saobei_service(("Saobei service"))
node_paypal_service(("PayPal"))
node_apple_service(("Apple services"))
node_alipay_service(("Alipay"))

node_app -->|"uses SDK"| node_wechat_v2
node_app -->|"uses SDK"| node_qq
node_app -->|"uses SDK"| node_douyin
node_app -->|"uses SDK"| node_cmb
node_app -->|"uses SDK"| node_allinpay
node_app -->|"uses SDK"| node_lakala
node_app -->|"uses SDK"| node_saobei
node_app -->|"uses SDK"| node_paypal
node_app -->|"uses SDK"| node_apple
node_app -->|"uses SDK"| node_alipay_v2
node_app -->|"uses SDK"| node_alipay_v3
node_app -->|"uses SDK"| node_wechat_v3
node_wechat_v2 -->|"sends requests"| node_wechat_service
node_qq -->|"sends requests"| node_qq_service
node_douyin -->|"sends requests"| node_douyin_service
node_cmb -->|"sends requests"| node_cmb_service
node_allinpay -->|"sends requests"| node_allinpay_service
node_lakala -->|"sends requests"| node_lakala_service
node_saobei -->|"sends requests"| node_saobei_service
node_paypal -->|"sends requests"| node_paypal_service
node_apple -->|"verifies with"| node_apple_service
node_alipay_v2 -->|"sends requests"| node_alipay_service
node_alipay_v3 -->|"sends requests"| node_alipay_service
node_wechat_v3 -->|"sends requests"| node_wechat_service
node_wechat_v2 -->|"uses transport"| node_xhttp
node_qq -->|"uses transport"| node_xhttp
node_douyin -->|"uses transport"| node_xhttp
node_lakala -->|"uses transport"| node_xhttp
node_allinpay -->|"uses transport"| node_xhttp
node_alipay_v2 -->|"uses transport"| node_xhttp
node_alipay_v3 -->|"uses transport"| node_xhttp
node_wechat_v3 -->|"uses transport"| node_xhttp
node_paypal -.->|"uses transport"| node_xhttp
node_apple -->|"uses transport"| node_xhttp
node_saobei -->|"uses transport"| node_xhttp

click node_wechat_v2 "https://github.com/go-pay/gopay/tree/main/wechat"
click node_qq "https://github.com/go-pay/gopay/tree/main/qq"
click node_douyin "https://github.com/go-pay/gopay/tree/main/douyin"
click node_cmb "https://github.com/go-pay/gopay/tree/main/cmbpay"
click node_allinpay "https://github.com/go-pay/gopay/tree/main/allinpay"
click node_lakala "https://github.com/go-pay/gopay/tree/main/lakala"
click node_saobei "https://github.com/go-pay/gopay/tree/main/saobei"
click node_paypal "https://github.com/go-pay/gopay/tree/main/paypal"
click node_apple "https://github.com/go-pay/gopay/tree/main/apple"
click node_alipay_v2 "https://github.com/go-pay/gopay/tree/main/alipay"
click node_alipay_v3 "https://github.com/go-pay/gopay/tree/main/alipay/v3"
click node_wechat_v3 "https://github.com/go-pay/gopay/tree/main/wechat/v3"
click node_xhttp "https://github.com/go-pay/gopay/blob/main/pkg/xhttp/client.go"

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_wechat_v2,node_qq,node_douyin,node_cmb,node_allinpay,node_lakala,node_saobei toneBlue
class node_paypal,node_apple toneAmber
class node_alipay_v2,node_alipay_v3,node_wechat_v3 toneMint
class node_xhttp toneRose
class node_app,node_wechat_service,node_qq_service,node_douyin_service,node_cmb_service,node_allinpay_service,node_lakala_service,node_saobei_service,node_paypal_service,node_apple_service,node_alipay_service toneIndigo
```

## Components

### China payment SDKs

- [WeChat Pay V2](https://github.com/go-pay/gopay/tree/main/wechat): `wechat`
- [QQ Pay](https://github.com/go-pay/gopay/tree/main/qq): `qq`
- [Douyin Pay](https://github.com/go-pay/gopay/tree/main/douyin): `douyin`
- [CMB Pay](https://github.com/go-pay/gopay/tree/main/cmbpay): `cmbpay`
- [Allinpay](https://github.com/go-pay/gopay/tree/main/allinpay): `allinpay`
- [Lakala](https://github.com/go-pay/gopay/tree/main/lakala): `lakala`
- [Saobei](https://github.com/go-pay/gopay/tree/main/saobei): `saobei`

### Other payment SDKs

- [PayPal](https://github.com/go-pay/gopay/tree/main/paypal): `paypal`
- [Apple verification](https://github.com/go-pay/gopay/tree/main/apple): `apple`

### Versioned APIs

- [Alipay SDK](https://github.com/go-pay/gopay/tree/main/alipay): `alipay`
- [Alipay V3](https://github.com/go-pay/gopay/tree/main/alipay/v3): `alipay/v3`
- [WeChat V3](https://github.com/go-pay/gopay/tree/main/wechat/v3): `wechat/v3`

### Shared transport

- [HTTP client](https://github.com/go-pay/gopay/blob/main/pkg/xhttp/client.go): `pkg/xhttp/client.go`

### Other components

- **Integrating application**
- **WeChat Pay**
- **QQ Pay**
- **Douyin Pay**
- **CMB Pay**
- **Allinpay service**
- **Lakala service**
- **Saobei service**
- **PayPal**
- **Apple services**
- **Alipay**

## Connections

- Integrating application → WeChat Pay V2: uses SDK (evidence: `README.md`)
- Integrating application → QQ Pay: uses SDK (evidence: `README.md`)
- Integrating application → Douyin Pay: uses SDK (evidence: `README.md`)
- Integrating application → CMB Pay: uses SDK (evidence: `README.md`)
- Integrating application → Allinpay: uses SDK (evidence: `README.md`)
- Integrating application → Lakala: uses SDK (evidence: `README.md`)
- Integrating application → Saobei: uses SDK (evidence: `README.md`)
- Integrating application → PayPal: uses SDK (evidence: `README.md`)
- Integrating application → Apple verification: uses SDK (evidence: `README.md`)
- Integrating application → Alipay SDK: uses SDK (evidence: `README.md`)
- Integrating application → Alipay V3: uses SDK (evidence: `README.md`)
- Integrating application → WeChat V3: uses SDK (evidence: `README.md`)
- WeChat Pay V2 → WeChat Pay: sends requests (evidence: `README.md`)
- QQ Pay → QQ Pay: sends requests (evidence: `README.md`)
- Douyin Pay → Douyin Pay: sends requests (evidence: `README.md`)
- CMB Pay → CMB Pay: sends requests (evidence: `README.md`)
- Allinpay → Allinpay service: sends requests (evidence: `README.md`)
- Lakala → Lakala service: sends requests (evidence: `README.md`)
- Saobei → Saobei service: sends requests (evidence: `README.md`)
- PayPal → PayPal: sends requests (evidence: `README.md`)
- Apple verification → Apple services: verifies with (evidence: `README.md`)
- Alipay SDK → Alipay: sends requests (evidence: `README.md`)
- Alipay V3 → Alipay: sends requests (evidence: `README.md`)
- WeChat V3 → WeChat Pay: sends requests (evidence: `README.md`)
- WeChat Pay V2 → HTTP client: uses transport (evidence: `wechat/client.go`)
- QQ Pay → HTTP client: uses transport (evidence: `qq/client.go`)
- Douyin Pay → HTTP client: uses transport (evidence: `douyin/client.go`)
- Lakala → HTTP client: uses transport (evidence: `lakala/client.go`)
- Allinpay → HTTP client: uses transport (evidence: `allinpay/client.go`)
- Alipay SDK → HTTP client: uses transport (evidence: `alipay/client_request.go`)
- Alipay V3 → HTTP client: uses transport (evidence: `alipay/v3/client.go`)
- WeChat V3 → HTTP client: uses transport (evidence: `wechat/v3/client.go`)
- PayPal → HTTP client: uses transport
- Apple verification → HTTP client: uses transport (evidence: `apple/client.go`)
- Saobei → HTTP client: uses transport (evidence: `saobei/client.go`)
