You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document defines the minimum Admin API surface for integrating external payment systems (for example, sub2apipay) with Sub2API for recharge fulfillment and reconciliation.
128
+
### Purpose
129
+
This document describes the minimal Sub2API Admin API surface for external payment integrations (for example, `sub2apipay`), including:
130
+
- Recharge after payment success
131
+
- User lookup
132
+
- Manual balance correction
133
+
- Purchase page query parameter forwarding
164
134
165
135
### Base URL
166
-
167
136
- Production: `https://<your-domain>`
168
137
- Beta: `http://<your-server-ip>:8084`
169
138
170
139
### Authentication
171
-
172
140
Recommended headers:
173
-
174
-
-`x-api-key: admin-<64hex>` (recommended for server-to-server calls)
141
+
-`x-api-key: admin-<64hex>`
175
142
-`Content-Type: application/json`
143
+
-`Idempotency-Key` for idempotent endpoints
176
144
177
-
Note: Admin JWT is also accepted by admin routes, but Admin API key is recommended for machine integrations.
178
-
179
-
### 1) One-step Create + Redeem
145
+
Note: Admin JWT can also access admin routes, but Admin API Key is recommended for server-to-server integration.
curl -X POST "${BASE}/api/v1/admin/redeem-codes/create-and-redeem" \
222
175
-H "x-api-key: ${KEY}" \
@@ -231,32 +184,20 @@ curl -X POST "${BASE}/api/v1/admin/redeem-codes/create-and-redeem" \
231
184
}'
232
185
```
233
186
234
-
### 2) Query User (Optional Pre-check)
235
-
187
+
### 2) Query User (optional pre-check)
236
188
`GET /api/v1/admin/users/:id`
237
189
238
-
Purpose:
239
-
240
-
- Verify target user existence before final recharge/retry.
241
-
242
-
Example:
243
-
244
190
```bash
245
191
curl -s "${BASE}/api/v1/admin/users/123" \
246
192
-H "x-api-key: ${KEY}"
247
193
```
248
194
249
-
### 3) Balance Adjustment (Existing API)
250
-
195
+
### 3) Balance Adjustment (existing API)
251
196
`POST /api/v1/admin/users/:id/balance`
252
197
253
-
Purpose:
254
-
255
-
- Reuse existing admin endpoint for manual reconciliation.
256
-
- Supports `set`, `add`, `subtract`.
198
+
Use case: manual correction with `set` / `add` / `subtract`.
257
199
258
200
Request body example (`subtract`):
259
-
260
201
```json
261
202
{
262
203
"balance": 100.0,
@@ -265,8 +206,6 @@ Request body example (`subtract`):
265
206
}
266
207
```
267
208
268
-
Example:
269
-
270
209
```bash
271
210
curl -X POST "${BASE}/api/v1/admin/users/123/balance" \
272
211
-H "x-api-key: ${KEY}" \
@@ -279,35 +218,24 @@ curl -X POST "${BASE}/api/v1/admin/users/123/balance" \
279
218
}'
280
219
```
281
220
282
-
### 4) Purchase URL Query Parameters (Iframe + New Tab)
283
-
284
-
When Sub2API frontend opens `purchase_subscription_url`, it appends the same query parameters for both iframe and “open in new tab” to keep context consistent.
285
-
286
-
Appended parameters:
287
-
288
-
-`user_id`: current logged-in user id
289
-
-`token`: current logged-in JWT token
290
-
-`theme`: current theme (`light` / `dark`)
291
-
-`ui_mode`: UI mode (fixed `embedded`)
221
+
### 4) Purchase URL query forwarding (iframe and new tab)
222
+
When Sub2API opens `purchase_subscription_url`, it appends:
0 commit comments