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
-`GET /v1/disputes/stats` - Get dispute statistics
202
-
203
-
### Fraud Detection
204
-
205
-
-`POST /v1/fraud/analyze` - Analyze transaction for fraud risk
206
-
-`GET /v1/fraud/stats` - Get fraud detection statistics
207
-
208
-
### System
209
-
210
-
-`GET /v1/health` - Health check
211
-
212
125
## Authentication
213
126
214
127
All API endpoints (except health check) require authentication using an API key. You can provide the API key in two ways:
@@ -227,203 +140,6 @@ All API endpoints (except health check) require authentication using an API key.
227
140
228
141
**Note**: Replace `your_api_key_here` with your actual API key. For development, you can use any string with at least 10 characters.
229
142
230
-
## API Examples
231
-
232
-
Here are some real examples of how to use the API. The system automatically routes your requests to the right payment provider based on the currency!
233
-
234
-
### Creating Charges
235
-
236
-
#### Basic charge with Stripe (USD)
237
-
238
-
```bash
239
-
curl -X POST http://localhost:8080/v1/charges \
240
-
-H "Content-Type: application/json" \
241
-
-H "X-API-Key: your_api_key_here" \
242
-
-d '{
243
-
"customer_id": "cus_123456789",
244
-
"amount": 2500,
245
-
"currency": "USD",
246
-
"payment_method": "pm_123456789",
247
-
"description": "Payment for order #12345"
248
-
}'
249
-
```
250
-
251
-
#### Charge with metadata using Xendit (IDR)
252
-
253
-
```bash
254
-
curl -X POST http://localhost:8080/v1/charges \
255
-
-H "Content-Type: application/json" \
256
-
-H "X-API-Key: your_api_key_here" \
257
-
-d '{
258
-
"customer_id": "customer_123",
259
-
"amount": 500000,
260
-
"currency": "IDR",
261
-
"payment_method": "pm_xendit_123",
262
-
"description": "Premium subscription payment",
263
-
"metadata": {
264
-
"order_id": "ORD-2024-001",
265
-
"user_id": "user_456",
266
-
"product_type": "subscription",
267
-
"billing_cycle": "monthly"
268
-
}
269
-
}'
270
-
```
271
-
272
-
#### Charge using Razorpay (INR)
273
-
274
-
```bash
275
-
curl -X POST http://localhost:8080/v1/charges \
276
-
-H "Content-Type: application/json" \
277
-
-H "X-API-Key: your_api_key_here" \
278
-
-d '{
279
-
"customer_id": "customer_india_123",
280
-
"amount": 100000,
281
-
"currency": "INR",
282
-
"description": "Payment for order #67890",
283
-
"metadata": {
284
-
"order_id": "ORD-2024-IN-001",
285
-
"payment_method_preference": "upi"
286
-
}
287
-
}'
288
-
```
289
-
290
-
Note: Razorpay uses an Order → Payment flow. The response will include `requires_action: true` with the order ID in `client_secret`. Use Razorpay.js on the frontend to complete the payment.
291
-
292
-
#### High-value charge with Stripe (EUR)
293
-
294
-
```bash
295
-
curl -X POST http://localhost:8080/v1/charges \
296
-
-H "Content-Type: application/json" \
297
-
-d '{
298
-
"customer_id": "cus_europe_789",
299
-
"amount": 9999,
300
-
"currency": "EUR",
301
-
"payment_method": "pm_europe_456",
302
-
"description": "Annual enterprise license",
303
-
"metadata": {
304
-
"license_type": "enterprise",
305
-
"duration": "annual",
306
-
"seats": 100,
307
-
"region": "EU"
308
-
}
309
-
}'
310
-
```
311
-
312
-
### Creating Refunds
313
-
314
-
#### Simple refund
315
-
316
-
```bash
317
-
curl -X POST http://localhost:8080/v1/refunds \
318
-
-H "Content-Type: application/json" \
319
-
-H "X-API-Key: your_api_key_here" \
320
-
-d '{
321
-
"payment_id": "ch_123456789",
322
-
"amount": 2500,
323
-
"currency": "USD",
324
-
"reason": "Customer requested refund"
325
-
}'
326
-
```
327
-
328
-
#### Partial refund with metadata
329
-
330
-
```bash
331
-
curl -X POST http://localhost:8080/v1/refunds \
332
-
-H "Content-Type: application/json" \
333
-
-d '{
334
-
"payment_id": "ch_123456789",
335
-
"amount": 1000,
336
-
"currency": "USD",
337
-
"reason": "Partial refund for damaged item",
338
-
"metadata": {
339
-
"refund_type": "partial",
340
-
"damage_reported": true,
341
-
"customer_service_agent": "agent_123"
342
-
}
343
-
}'
344
-
```
345
-
346
-
### Managing Subscriptions
347
-
348
-
#### Create a subscription plan
349
-
350
-
```bash
351
-
curl -X POST http://localhost:8080/v1/plans \
352
-
-H "Content-Type: application/json" \
353
-
-d '{
354
-
"name": "Premium Plan",
355
-
"description": "Premium features with priority support",
curl -X POST http://localhost:8080/v1/disputes/disp_123/evidence \
407
-
-H "Content-Type: application/json" \
408
-
-d '{
409
-
"type": "customer_communication",
410
-
"description": "Email from customer confirming receipt",
411
-
"files": ["https://example.com/evidence1.pdf"],
412
-
"metadata": {
413
-
"evidence_type": "email",
414
-
"customer_email": "customer@example.com"
415
-
}
416
-
}'
417
-
```
418
-
419
-
### System Health
420
-
421
-
#### Check if the system is healthy
422
-
423
-
```bash
424
-
curl -X GET http://localhost:8080/v1/health
425
-
```
426
-
427
143
## How Currency Routing Works
428
144
429
145
The system is smart about routing your payments to the right provider:
@@ -434,65 +150,16 @@ The system is smart about routing your payments to the right provider:
434
150
435
151
Just specify the currency in your request, and the system automatically picks the best provider.
436
152
437
-
## Important Notes
438
-
439
-
### Amount Format
440
-
441
-
Always use the smallest currency unit:
442
-
443
-
-**USD/EUR**: cents (1000 = $10.00)
444
-
-**IDR**: rupiah (50000 = Rp 50,000)
445
-
-**SGD**: cents (1500 = S$15.00)
446
-
-**INR**: paise (100000 = ₹1,000.00)
447
-
448
-
### Payment Methods
449
-
450
-
Make sure you're using valid payment method IDs from your chosen provider:
451
-
452
-
- Stripe: `pm_123456789`
453
-
- Xendit: `pm_xendit_123`
454
-
455
-
### Customer IDs
456
-
457
-
Your customer IDs should match what's in your provider's system.
458
-
459
-
## Cache support
460
-
461
-
The Redis cache is ready to go and can be used to cache things like payment methods, customer info, and subscription details. Right now, the cache is set up but not actively caching. It's there for when you want to add caching to improve performance.
0 commit comments