22
33Integrasi sederhana Xendit Payment Gateway untuk memahami cara kerja payment gateway.
44
5- ## 📋 Konsep Payment Gateway
6-
7- ```
8- User → Backend → Xendit → User Bayar → Webhook → Backend Update Status
9- ```
10-
115## 🏗️ Struktur Project
126
137```
@@ -46,14 +40,11 @@ XENDIT_FAILURE_REDIRECT="http://localhost:3000/payment/failed"
4640
4741### 4. Run Migration
4842``` bash
49- make migration-up
50- make seed-up
43+ go run main.go migrate:up
5144```
5245
5346### 5. Start Server
5447``` bash
55- make run-http
56- # atau
5748go run main.go http
5849```
5950
@@ -203,16 +194,6 @@ curl -X POST http://localhost:8000/api/v1/public/payments \
203194curl http:// localhost:8000/api/v1/public/payments/ORDER-1234567890
204195```
205196
206- ### Test Webhook di Local
207-
208- Karena Xendit tidak bisa hit localhost, gunakan salah satu tools:
209- - **ngrok**: `ngrok http 8000`
210- - **localtunnel**: `lt --port 8000`
211-
212- Lalu set webhook URL di Xendit dashboard ke:
213- ```
214- https:// your-ngrok-url.ngrok.io/api/v1/public/webhooks/xendit
215- ```
216197
217198## 📊 Database Structure
218199
@@ -229,38 +210,4 @@ CREATE TABLE testing_transaction (
229210 created_at TIMESTAMP DEFAULT NOW(),
230211 updated_at TIMESTAMP
231212);
232- ```
233-
234- ## 🎯 Key Points
235-
236- 1. **Simple & Clear**: Code dibuat sesederhana mungkin untuk mudah dipahami
237- 2. **Official SDK**: Menggunakan `xendit-go` official SDK, bukan custom HTTP client
238- 3. **Webhook Important**: Webhook adalah cara Xendit memberitahu kita kalau payment berhasil
239- 4. **Async Process**: Payment adalah proses async - user bayar diluar sistem kita
240- 5. **Test Mode**: Gunakan test API key untuk development (tidak ada biaya)
241-
242- ## 🔐 Security Notes
243-
244- - Jangan commit API key ke git
245- - Gunakan `.env` untuk menyimpan credentials
246- - Di production, validate webhook signature dari Xendit
247- - Gunakan HTTPS untuk webhook endpoint
248-
249- ## 📚 Resources
250-
251- - [Xendit API Documentation](https:// developers.xendit.co/api-reference/)
252- - [Xendit Go SDK](https:// github.com/xendit/xendit-go)
253- - [Xendit Dashboard](https:// dashboard.xendit.co)
254-
255- ## ✅ Next Steps
256-
257- Setelah memahami basic flow, bisa develop:
258- 1. Integrate dengan event registration yang sudah ada
259- 2. Tambah email notification setelah payment success
260- 3. Implementasi refund/cancellation
261- 4. Add pagination untuk list payments
262- 5. Export payment report
263-
264- ---
265-
266- **Happy Coding! 🚀**
213+ ```
0 commit comments