# payment gateway

Innovasia mendukung **3 payment gateway** untuk memproses pembayaran donasi/produk: **Winpay**, **Midtrans**, dan **Faspay**. Semua konfigurasi dilakukan di menu **Master Data → Payment**.

> **Screenshot:** *\[letakkan screenshot halaman Master Data → Payment yang menampilkan 3 tab provider]*

## 1. Winpay

Winpay adalah payment gateway utama dengan cakupan paling luas: **Virtual Account semua bank**, **E-Wallet**, dan **QRIS**.

### 1.1 Kredensial yang Dibutuhkan

| Field               | Keterangan              |
| ------------------- | ----------------------- |
| `winpay_partner_id` | Partner ID dari Winpay  |
| `winpay_user_token` | Bearer token otentikasi |

### 1.2 Payment Methods & Minimum Nominal

| Method                                                              | Kategori        | Min. Nominal |
| ------------------------------------------------------------------- | --------------- | ------------ |
| BCA VA, BNI VA, BRI VA, BSI VA, Mandiri VA, Permata VA, Muamalat VA | Virtual Account | Rp 10.000    |
| OVO, Dana, ShopeePay                                                | E-Wallet        | Rp 1.000     |
| QRIS                                                                | QR Code         | Rp 1.000     |

### 1.3 Setup di Dashboard

{% stepper %}
{% step %}

### Buka **Master Data → Payment**

Masuk ke menu **Master Data → Payment**.
{% endstep %}

{% step %}

### Pilih tab **Winpay**

Pilih tab **Winpay**.
{% endstep %}

{% step %}

### Masukkan kredensial

Masukkan **Partner ID** dan **User Token**.
{% endstep %}

{% step %}

### Klik **Simpan & Test Koneksi**

Klik **Simpan & Test Koneksi**.
{% endstep %}

{% step %}

### Non-aktifkan method yang tidak dipakai

Pada tab **Disabled Methods**, non-aktifkan method yang tidak dipakai (opsional).
{% endstep %}
{% endstepper %}

> **Screenshot:** *\[letakkan screenshot form Winpay setup dengan field Partner ID + Token]*

### 1.4 Webhook URL

```
https://<domain-anda>/webhook/payment/winpay/{token}
```

Token unique di-generate otomatis saat pembuatan invoice. **Tidak perlu setting manual** di dashboard Winpay — sistem kami registrasikan secara dinamis per transaksi.

## 2. Midtrans

Midtrans dipakai khusus untuk **Gopay** dan **ShopeePay** (E-Wallet premium).

### 2.1 Kredensial

| Field                 | Keterangan                         |
| --------------------- | ---------------------------------- |
| `midtrans_server_key` | Server Key dari Midtrans Dashboard |

### 2.2 Konfigurasi di Midtrans Dashboard

{% stepper %}
{% step %}

### Login ke `dashboard.midtrans.com`

Login ke `dashboard.midtrans.com`.
{% endstep %}

{% step %}

### Ambil **Server Key**

Settings → **Access Keys** → copy **Server Key**.
{% endstep %}

{% step %}

### Paste ke Innovasia panel

Paste ke Innovasia panel (Master Data → Payment → Midtrans).
{% endstep %}

{% step %}

### Set **Payment Notification URL**

Settings → **Configuration** → **Payment Notification URL**:

```
https://<domain-anda>/webhook/payment/midtrans/{token}
```

{% endstep %}

{% step %}

### Ubah ke mode **Production**

Toggle ke mode **Production** setelah sandbox testing selesai.
{% endstep %}
{% endstepper %}

> **Screenshot:** *\[letakkan screenshot Midtrans Dashboard bagian Access Keys]*

### 2.3 Signature Verification

Sistem memverifikasi webhook via SHA512 hash:

```
SHA512(order_id + status_code + gross_amount + server_key)
```

Request yang tidak lolos verifikasi di-reject otomatis.

## 3. Faspay

Faspay menawarkan multi-channel dengan kode numerik per method.

### 3.1 Kredensial

| Field                  | Keterangan                |
| ---------------------- | ------------------------- |
| `faspay_merchant_code` | Merchant Code dari Faspay |
| `faspay_merchant_name` | Nama merchant terdaftar   |
| `faspay_username`      | Username API              |
| `faspay_password`      | Password API              |

### 3.2 Payment Methods & Kode

| Method         | Kode |
| -------------- | ---- |
| LinkAja        | 302  |
| BCA VA         | 702  |
| Mandiri VA     | 802  |
| BRI VA         | 800  |
| BNI VA         | 801  |
| ShopeePay QRIS | 711  |
| ShopeePay      | 713  |
| OVO Direct     | 812  |
| Dana           | 819  |

### 3.3 Webhook URL

```
https://<domain-anda>/webhook/payment/faspay/{token}
```

**Signature Verification:** `SHA1(MD5(merchant_code + trx_id + nominal + status))`

## 4. Status Flow (Semua Provider)

Setelah webhook diterima, transaksi diupdate ke salah satu status:

| Status       | Arti           | Aksi Sistem                                                                  |
| ------------ | -------------- | ---------------------------------------------------------------------------- |
| `settlement` | Dana diterima  | Kirim notif sukses, trigger Zains (jika aktif), kirim BSZ (jika SIMBA aktif) |
| `pending`    | Menunggu bayar | Template reminder bisa dikirim                                               |
| `expired`    | Kadaluarsa     | Update status, kirim pesan expired                                           |
| `failed`     | Gagal          | Update status                                                                |

## 5. Struktur File Sistem

| File                                                         | Fungsi                      |
| ------------------------------------------------------------ | --------------------------- |
| `modules/Integration/Providers/Payment.php`                  | Entry point unified payment |
| `modules/Integration/Providers/Payment/Winpay/`              | Winpay driver               |
| `modules/Integration/Providers/Payment/Midtrans/`            | Midtrans driver             |
| `modules/Integration/Providers/Payment/Faspay/`              | Faspay driver               |
| `modules/Integration/Http/Controllers/PaymentController.php` | Receive webhook             |

## 6. Troubleshooting

| Gejala                             | Solusi                                                                     |
| ---------------------------------- | -------------------------------------------------------------------------- |
| Webhook tidak dipanggil            | Pastikan domain publik + SSL aktif. Cek firewall.                          |
| Status tetap pending setelah bayar | Cek `storage/logs/laravel.log` untuk signature error.                      |
| Connect button gagal               | Validasi kredensial ulang. Pastikan environment Production, bukan sandbox. |
| Minimum nominal error              | Sesuaikan nominal dengan tabel method di atas.                             |
| Status ganda (ter-update dua kali) | Normal — Winpay kadang retry webhook. Sistem idempotent.                   |

## 7. Screenshots untuk GitBook

*Tempatkan screenshot berikut di section terkait:*

* Halaman **Master Data → Payment** dengan 3 tab provider.
* Form konfigurasi tiap provider (Winpay, Midtrans, Faspay).
* Dashboard Midtrans dengan highlight "Access Keys" dan "Payment Notification URL".
* Contoh flow pembayaran end-to-end: invoice → QR/VA → status settlement.

## 8. Support

* **WhatsApp:** 0823-1548-6886


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.innovasia.id/dokumentasi/external-api/payment-gateway.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
