@crediblemark/buayar 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +205 -0
- package/dist/index.mjs +205 -0
- package/docs/guide.md +356 -0
- package/package.json +1 -1
- package/docs/adyen.md +0 -60
- package/docs/braintree.md +0 -57
- package/docs/checkoutcom.md +0 -59
- package/docs/doku.md +0 -102
- package/docs/duitku.md +0 -219
- package/docs/faspay.md +0 -109
- package/docs/finpay.md +0 -102
- package/docs/ipaymu.md +0 -106
- package/docs/midtrans.md +0 -207
- package/docs/nicepay.md +0 -106
- package/docs/oy.md +0 -115
- package/docs/paypal.md +0 -73
- package/docs/payu.md +0 -61
- package/docs/prismalink.md +0 -101
- package/docs/razorpay.md +0 -77
- package/docs/square.md +0 -61
- package/docs/stripe.md +0 -103
- package/docs/twocheckout.md +0 -59
- package/docs/xendit.md +0 -112
package/docs/duitku.md
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Duitku (`duitku`)
|
|
2
|
-
|
|
3
|
-
Halaman ini berisi panduan lengkap untuk menggunakan provider **Duitku** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
Untuk menggunakan provider Duitku, Anda perlu menyiapkan objek konfigurasi berikut:
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
const providerConfig = {
|
|
12
|
-
merchantCode: "DXXXX", // Merchant Code dari dashboard Duitku Anda
|
|
13
|
-
apiKey: "xxxxxxxxxxxxxxxx", // API Key / Merchant Key Anda
|
|
14
|
-
sandbox: true, // Set true untuk development / testing
|
|
15
|
-
};
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## 🛠️ Membuat Transaksi (Invoice)
|
|
21
|
-
|
|
22
|
-
### 1. Mode Redirect Checkout (Duitku Checkout Page)
|
|
23
|
-
Jika Anda ingin mengarahkan pelanggan ke halaman pembayaran yang disediakan oleh Duitku (di mana pelanggan dapat memilih sendiri metode pembayaran mereka):
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { paymentManager } from "@crediblemark/buayar";
|
|
27
|
-
|
|
28
|
-
const invoiceParams = {
|
|
29
|
-
orderId: "ORDER-100249",
|
|
30
|
-
amount: 150000, // Nominal dalam Rupiah (integer)
|
|
31
|
-
productDetails: "Pembelian Template Landing Page Premium",
|
|
32
|
-
customer: {
|
|
33
|
-
name: "Rasyiqi Crediblemark",
|
|
34
|
-
email: "rasyiqi@crediblemark.com",
|
|
35
|
-
phone: "081234567890",
|
|
36
|
-
},
|
|
37
|
-
returnUrl: "https://situsbisnis.com/payment/success",
|
|
38
|
-
callbackUrl: "https://api.situsbisnis.com/v1/payment/callback",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
async function checkoutRedirect() {
|
|
42
|
-
try {
|
|
43
|
-
const result = await paymentManager.createInvoice(
|
|
44
|
-
"duitku",
|
|
45
|
-
invoiceParams,
|
|
46
|
-
providerConfig
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (result.success) {
|
|
50
|
-
console.log("Invoice Berhasil Dibuat! 🎉");
|
|
51
|
-
console.log("Halaman Pembayaran:", result.paymentUrl); // Redirect pelanggan ke URL ini
|
|
52
|
-
console.log("Referensi Duitku:", result.reference);
|
|
53
|
-
} else {
|
|
54
|
-
console.error("Gagal membuat invoice:", result.error);
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error("Terjadi kesalahan:", error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 2. Mode Direct Inquiry (Dapatkan VA / QRIS Instan)
|
|
63
|
-
Jika Anda ingin menampilkan nomor Virtual Account atau kode QRIS langsung di website/aplikasi Anda tanpa mengarahkan pelanggan keluar dari situs Anda, sertakan opsi `paymentMethod`:
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
const directParams = {
|
|
67
|
-
orderId: "ORDER-100249",
|
|
68
|
-
amount: 150000,
|
|
69
|
-
productDetails: "Pembelian Template Landing Page Premium",
|
|
70
|
-
customer: {
|
|
71
|
-
name: "Rasyiqi Crediblemark",
|
|
72
|
-
email: "rasyiqi@crediblemark.com",
|
|
73
|
-
phone: "081234567890",
|
|
74
|
-
},
|
|
75
|
-
returnUrl: "https://situsbisnis.com/payment/success",
|
|
76
|
-
callbackUrl: "https://api.situsbisnis.com/v1/payment/callback",
|
|
77
|
-
paymentMethod: "BCA", // Contoh kode pembayaran Duitku untuk BCA Virtual Account
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
async function checkoutDirect() {
|
|
81
|
-
try {
|
|
82
|
-
const result = await paymentManager.createInvoice(
|
|
83
|
-
"duitku",
|
|
84
|
-
directParams,
|
|
85
|
-
providerConfig
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
if (result.success) {
|
|
89
|
-
console.log("Nomor Virtual Account:", result.vaNumber);
|
|
90
|
-
console.log("Referensi Duitku:", result.reference);
|
|
91
|
-
} else {
|
|
92
|
-
console.error("Gagal memproses direct inquiry:", result.error);
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error("Error:", error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## 🔔 Verifikasi Webhook Callback
|
|
103
|
-
Gunakan fungsi ini di endpoint API notifikasi Duitku untuk memverifikasi keaslian signature data:
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
import { paymentManager } from "@crediblemark/buayar";
|
|
107
|
-
|
|
108
|
-
async function handleDuitkuCallback(req: any, res: any) {
|
|
109
|
-
const callbackPayload = req.body; // Payload POST dari Duitku
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const verification = await paymentManager.verifyCallback(
|
|
113
|
-
"duitku",
|
|
114
|
-
callbackPayload,
|
|
115
|
-
providerConfig
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
if (verification.isValid) {
|
|
119
|
-
console.log(`Signature valid untuk Order ID: ${verification.orderId}`);
|
|
120
|
-
|
|
121
|
-
if (verification.status === "paid") {
|
|
122
|
-
console.log("Status: PEMBAYARAN LUNAS! ✅");
|
|
123
|
-
// Update status order di database Anda menjadi LUNAS/SUCCESS
|
|
124
|
-
} else if (verification.status === "failed") {
|
|
125
|
-
console.log("Status: PEMBAYARAN GAGAL ❌");
|
|
126
|
-
// Update status order di database Anda menjadi GAGAL
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Duitku memerlukan respon plaintext "OK" jika callback berhasil diproses
|
|
130
|
-
res.status(200).send("OK");
|
|
131
|
-
} else {
|
|
132
|
-
console.warn("Peringatan: Signature callback tidak valid!");
|
|
133
|
-
res.status(400).send("Bad Signature");
|
|
134
|
-
}
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error("Gagal memproses callback:", error);
|
|
137
|
-
res.status(500).send("Internal Server Error");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## 🔍 Cek Status Transaksi Manual
|
|
145
|
-
Anda dapat melakukan polling atau pemeriksaan status transaksi secara manual:
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
async function checkTransactionStatus() {
|
|
149
|
-
const result = await paymentManager.checkTransaction(
|
|
150
|
-
"duitku",
|
|
151
|
-
{ merchantOrderId: "ORDER-100249" },
|
|
152
|
-
providerConfig
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
if (result.success) {
|
|
156
|
-
console.log("Status Transaksi:", result.status); // "paid" | "pending" | "failed"
|
|
157
|
-
console.log("Detail Status:", result.statusMessage);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 📋 Mendapatkan Daftar Metode Pembayaran Aktif
|
|
165
|
-
Anda dapat mengambil daftar metode pembayaran yang tersedia secara dinamis beserta rincian biaya (fee) transaksi:
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
async function loadDuitkuMethods() {
|
|
169
|
-
const result = await paymentManager.getPaymentMethods(
|
|
170
|
-
"duitku",
|
|
171
|
-
{ amount: 150000 },
|
|
172
|
-
providerConfig
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
if (result.success) {
|
|
176
|
-
console.log("Metode Pembayaran Aktif:", result.methods);
|
|
177
|
-
// SDK secara otomatis mengelompokkan ke dalam kategori terstandarisasi untuk UI:
|
|
178
|
-
// "Virtual Account", "QRIS", "E-Wallet", "Retail / Gerai", "Lainnya"
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## 🏦 Ekstensi `DuitkuClient` (Disbursement & Saldo)
|
|
184
|
-
|
|
185
|
-
Selain alur transaksi reguler, SDK menyediakan **`DuitkuClient`** untuk mengelola pengecekan saldo dan transfer dana / payout (*disbursement*):
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
import { buayar, DuitkuClient } from "@crediblemark/buayar";
|
|
189
|
-
|
|
190
|
-
// Opsi 1: Dari instance buayar
|
|
191
|
-
const client = buayar.getDuitkuClient();
|
|
192
|
-
|
|
193
|
-
// Opsi 2: Inisialisasi mandiri
|
|
194
|
-
// const client = new DuitkuClient({ merchantCode: "DXXXX", apiKey: "...", sandbox: true });
|
|
195
|
-
|
|
196
|
-
// 1. Cek Saldo Merchant
|
|
197
|
-
const balanceResult = await client.checkBalance();
|
|
198
|
-
console.log("Saldo Merchant:", balanceResult.balance);
|
|
199
|
-
|
|
200
|
-
// 2. Daftar Bank yang Didukung Payout
|
|
201
|
-
const banks = await client.listBanks();
|
|
202
|
-
console.log("Daftar Bank:", banks);
|
|
203
|
-
|
|
204
|
-
// 3. Validasi Pemilik Rekening Bank (Inquiry)
|
|
205
|
-
const accountInfo = await client.inquiryBankAccount("BCA", "1234567890");
|
|
206
|
-
console.log("Nama Pemilik:", accountInfo.accountName);
|
|
207
|
-
|
|
208
|
-
// 4. Eksekusi Transfer Dana (Disbursement)
|
|
209
|
-
const disburseResult = await client.disburse({
|
|
210
|
-
merchantOrderId: "DISBURSE-001",
|
|
211
|
-
bankCode: "BCA",
|
|
212
|
-
bankAccount: "1234567890",
|
|
213
|
-
amount: 500000,
|
|
214
|
-
purpose: "Penarikan Saldo Mitra",
|
|
215
|
-
senderName: "PT Bisnis Anda",
|
|
216
|
-
});
|
|
217
|
-
console.log("Status Transfer:", disburseResult);
|
|
218
|
-
```
|
|
219
|
-
|
package/docs/faspay.md
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Faspay (`faspay`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Faspay** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Faspay dapat diperoleh melalui dashboard [merchant.faspay.co.id](https://merchant.faspay.co.id):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=faspay
|
|
14
|
-
FASPAY_MERCHANT_ID=31112
|
|
15
|
-
FASPAY_USER_ID=db31112
|
|
16
|
-
FASPAY_PASSWORD=faspay-password-xxxxxxxx
|
|
17
|
-
FASPAY_MERCHANT_NAME="Toko Saya"
|
|
18
|
-
FASPAY_SANDBOX=true
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Atau inisialisasi manual:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
25
|
-
|
|
26
|
-
const buayarFaspay = new Buayar({
|
|
27
|
-
provider: "faspay",
|
|
28
|
-
merchantCode: "31112", // Merchant ID
|
|
29
|
-
clientKey: "db31112", // User ID
|
|
30
|
-
apiKey: "faspay-password-xxxxxxxx", // Password
|
|
31
|
-
sandbox: true,
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 🛠️ Membuat Transaksi
|
|
38
|
-
|
|
39
|
-
### 1. Semi Integrasi (Faspay Payment Page)
|
|
40
|
-
Kosongkan parameter `paymentMethod`:
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { buayar } from "@crediblemark/buayar";
|
|
44
|
-
|
|
45
|
-
const invoice = await buayar.createInvoice({
|
|
46
|
-
orderId: "ORDER-FASPAY-001",
|
|
47
|
-
amount: 250000,
|
|
48
|
-
productDetails: "Sepatu Olahraga",
|
|
49
|
-
customer: {
|
|
50
|
-
name: "Budi Santoso",
|
|
51
|
-
email: "budi@example.com",
|
|
52
|
-
phone: "081234567890",
|
|
53
|
-
},
|
|
54
|
-
returnUrl: "https://myapp.com/payment/finish",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (invoice.success) {
|
|
58
|
-
// Arahkan user ke URL Pembayaran Faspay
|
|
59
|
-
console.log("Payment URL:", invoice.paymentUrl);
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 2. Full Integrasi (Direct VA / QRIS / Retail)
|
|
64
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `alfamart`, `indomaret`):
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
// Direct Virtual Account (Post Data Transaction)
|
|
68
|
-
const va = await buayar.createInvoice({
|
|
69
|
-
orderId: "ORDER-FASPAY-002",
|
|
70
|
-
amount: 150000,
|
|
71
|
-
paymentMethod: "bca_va",
|
|
72
|
-
productDetails: "Top Up Diamond",
|
|
73
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
console.log("Nomor VA BCA:", va.vaNumber);
|
|
77
|
-
console.log("Payment URL:", va.paymentUrl);
|
|
78
|
-
console.log("Expired At:", va.expiresAt);
|
|
79
|
-
|
|
80
|
-
// Direct QRIS
|
|
81
|
-
const qris = await buayar.createInvoice({
|
|
82
|
-
orderId: "ORDER-FASPAY-003",
|
|
83
|
-
amount: 50000,
|
|
84
|
-
paymentMethod: "qris",
|
|
85
|
-
productDetails: "Kopi Gula Aren",
|
|
86
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
console.log("Raw QRIS (EMVCo):", qris.qrString);
|
|
90
|
-
console.log("QR Image URL:", qris.qrCodeUrl);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## 🏦 Ekstensi `FaspayClient` (Inquiry & Cancel)
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import { buayar } from "@crediblemark/buayar";
|
|
99
|
-
|
|
100
|
-
const faspayClient = buayar.getFaspayClient();
|
|
101
|
-
|
|
102
|
-
// 1. Cek status pembayaran tagihan
|
|
103
|
-
const status = await faspayClient.checkTransaction("ORDER-FASPAY-001");
|
|
104
|
-
console.log("Status Pesanan:", status);
|
|
105
|
-
|
|
106
|
-
// 2. Batalkan tagihan
|
|
107
|
-
const cancel = await faspayClient.cancelTransaction("ORDER-FASPAY-001", "402");
|
|
108
|
-
console.log("Hasil Pembatalan:", cancel);
|
|
109
|
-
```
|
package/docs/finpay.md
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Finpay (`finpay`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Finpay (PT Finnet Indonesia - Telkom Group)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Finpay dapat diperoleh melalui dashboard [dashboard.finpay.id](https://dashboard.finpay.id):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=finpay
|
|
14
|
-
FINPAY_MERCHANT_ID=FINPAY-MERCHANT-001
|
|
15
|
-
FINPAY_MERCHANT_KEY=finpay-secret-key-xxxxxxxxxxxxxxxx
|
|
16
|
-
FINPAY_SANDBOX=true
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Atau inisialisasi manual:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
23
|
-
|
|
24
|
-
const buayarFinpay = new Buayar({
|
|
25
|
-
provider: "finpay",
|
|
26
|
-
merchantCode: "FINPAY-MERCHANT-001", // Merchant ID
|
|
27
|
-
apiKey: "finpay-secret-key-xxxxxxxxxxxxxxxx", // Merchant Key / Signature Key
|
|
28
|
-
sandbox: true,
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🛠️ Membuat Transaksi
|
|
35
|
-
|
|
36
|
-
### 1. Semi Integrasi (Finpay Checkout Link)
|
|
37
|
-
Kosongkan parameter `paymentMethod`:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { buayar } from "@crediblemark/buayar";
|
|
41
|
-
|
|
42
|
-
const invoice = await buayar.createInvoice({
|
|
43
|
-
orderId: "ORDER-FINPAY-001",
|
|
44
|
-
amount: 250000,
|
|
45
|
-
productDetails: "Tagihan Langganan Internet",
|
|
46
|
-
customer: {
|
|
47
|
-
name: "Budi Santoso",
|
|
48
|
-
email: "budi@example.com",
|
|
49
|
-
phone: "081234567890",
|
|
50
|
-
},
|
|
51
|
-
returnUrl: "https://myapp.com/payment/finish",
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (invoice.success) {
|
|
55
|
-
// Arahkan user ke URL Checkout Finpay
|
|
56
|
-
console.log("Payment URL:", invoice.paymentUrl);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 2. Full Integrasi (Direct VA / QRIS / Retail / Pos)
|
|
61
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `pos`, `alfamart`, `indomaret`):
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// Direct Virtual Account
|
|
65
|
-
const va = await buayar.createInvoice({
|
|
66
|
-
orderId: "ORDER-FINPAY-002",
|
|
67
|
-
amount: 150000,
|
|
68
|
-
paymentMethod: "bca_va",
|
|
69
|
-
productDetails: "Top Up Saldo",
|
|
70
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
console.log("Nomor VA BCA:", va.vaNumber);
|
|
74
|
-
console.log("Payment URL:", va.paymentUrl);
|
|
75
|
-
console.log("Expired At:", va.expiresAt);
|
|
76
|
-
|
|
77
|
-
// Direct QRIS
|
|
78
|
-
const qris = await buayar.createInvoice({
|
|
79
|
-
orderId: "ORDER-FINPAY-003",
|
|
80
|
-
amount: 50000,
|
|
81
|
-
paymentMethod: "qris",
|
|
82
|
-
productDetails: "Kopi",
|
|
83
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log("Raw QRIS (EMVCo):", qris.qrString);
|
|
87
|
-
console.log("QR Image URL:", qris.qrCodeUrl);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## 🏦 Ekstensi `FinpayClient` (Cek Status Pembayaran)
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { buayar } from "@crediblemark/buayar";
|
|
96
|
-
|
|
97
|
-
const finpayClient = buayar.getFinpayClient();
|
|
98
|
-
|
|
99
|
-
// Cek status pembayaran
|
|
100
|
-
const status = await finpayClient.checkTransaction("ORDER-FINPAY-001");
|
|
101
|
-
console.log("Status Pesanan:", status);
|
|
102
|
-
```
|
package/docs/ipaymu.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi iPaymu (`ipaymu`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **iPaymu** v2 dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial iPaymu dapat diperoleh melalui menu **Integrasi** pada dashboard [my.ipaymu.com](https://my.ipaymu.com):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=ipaymu
|
|
14
|
-
IPAYMU_VA=0000001411234567
|
|
15
|
-
IPAYMU_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
16
|
-
IPAYMU_SANDBOX=true
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Atau passing konfigurasi manual:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { buayar } from "@crediblemark/buayar";
|
|
23
|
-
|
|
24
|
-
const buayarIpaymu = new Buayar({
|
|
25
|
-
provider: "ipaymu",
|
|
26
|
-
merchantCode: "0000001411234567", // Nomor VA iPaymu
|
|
27
|
-
apiKey: "xxxxxxxxxxxxxxxx",
|
|
28
|
-
sandbox: true,
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🛠️ Membuat Transaksi
|
|
35
|
-
|
|
36
|
-
### 1. Semi Integrasi (Redirect Checkout)
|
|
37
|
-
Kosongkan parameter `paymentMethod`:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { buayar } from "@crediblemark/buayar";
|
|
41
|
-
|
|
42
|
-
const invoice = await buayar.createInvoice({
|
|
43
|
-
orderId: "ORDER-IPAYMU-001",
|
|
44
|
-
amount: 150000,
|
|
45
|
-
productDetails: "Pembelian Domain & Hosting",
|
|
46
|
-
customer: {
|
|
47
|
-
name: "Budi Santoso",
|
|
48
|
-
email: "budi@example.com",
|
|
49
|
-
phone: "081234567890",
|
|
50
|
-
},
|
|
51
|
-
returnUrl: "https://myapp.com/payment/finish",
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (invoice.success) {
|
|
55
|
-
// Arahkan pelanggan ke URL Checkout iPaymu
|
|
56
|
-
console.log("Redirect URL:", invoice.paymentUrl);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 2. Full Integrasi (Direct VA / QRIS / Retail)
|
|
61
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `qris`, `alfamart`, `indomaret`):
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// Direct Virtual Account
|
|
65
|
-
const vaInvoice = await buayar.createInvoice({
|
|
66
|
-
orderId: "ORDER-IPAYMU-002",
|
|
67
|
-
amount: 100000,
|
|
68
|
-
paymentMethod: "bca_va", // Canonical ID
|
|
69
|
-
productDetails: "Top Up Game",
|
|
70
|
-
customer: { name: "Budi", email: "budi@example.com", phone: "081234567890" },
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
console.log("Nomor VA:", vaInvoice.vaNumber);
|
|
74
|
-
console.log("Bank:", vaInvoice.vaBank);
|
|
75
|
-
console.log("Expired At:", vaInvoice.expiresAt);
|
|
76
|
-
|
|
77
|
-
// Direct QRIS
|
|
78
|
-
const qrisInvoice = await buayar.createInvoice({
|
|
79
|
-
orderId: "ORDER-IPAYMU-003",
|
|
80
|
-
amount: 50000,
|
|
81
|
-
paymentMethod: "qris",
|
|
82
|
-
productDetails: "Kopi Kenangan",
|
|
83
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log("Raw QRIS String (EMVCo):", qrisInvoice.qrString);
|
|
87
|
-
console.log("QR Image URL:", qrisInvoice.qrCodeUrl);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## 🏦 Ekstensi `IpaymuClient` (Cek Saldo & Detail Transaksi)
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { buayar } from "@crediblemark/buayar";
|
|
96
|
-
|
|
97
|
-
const ipaymuClient = buayar.getIpaymuClient();
|
|
98
|
-
|
|
99
|
-
// Cek Saldo Merchant
|
|
100
|
-
const balance = await ipaymuClient.checkBalance();
|
|
101
|
-
console.log("Saldo iPaymu:", balance.balance);
|
|
102
|
-
|
|
103
|
-
// Cek Detail Transaksi
|
|
104
|
-
const tx = await ipaymuClient.checkTransaction("123456");
|
|
105
|
-
console.log("Detail Transaksi:", tx);
|
|
106
|
-
```
|