@crediblemark/buayar 0.3.1 → 0.3.2
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/docs/adyen.md +60 -0
- package/docs/braintree.md +57 -0
- package/docs/checkoutcom.md +59 -0
- package/docs/doku.md +102 -0
- package/docs/duitku.md +219 -0
- package/docs/faspay.md +109 -0
- package/docs/finpay.md +102 -0
- package/docs/ipaymu.md +106 -0
- package/docs/midtrans.md +207 -0
- package/docs/nicepay.md +106 -0
- package/docs/oy.md +115 -0
- package/docs/paypal.md +73 -0
- package/docs/payu.md +61 -0
- package/docs/prismalink.md +101 -0
- package/docs/razorpay.md +77 -0
- package/docs/square.md +61 -0
- package/docs/stripe.md +103 -0
- package/docs/twocheckout.md +59 -0
- package/docs/xendit.md +112 -0
- package/package.json +2 -1
package/docs/adyen.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# 💳 Integrasi Adyen (`adyen`)
|
|
2
|
+
|
|
3
|
+
Panduan lengkap integrasi Payment Gateway **Adyen Checkout Sessions API v71** dengan `@crediblemark/buayar`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚙️ Konfigurasi Kredensial
|
|
8
|
+
|
|
9
|
+
Kredensial Adyen dapat diperoleh melalui [ca-test.adyen.com](https://ca-test.adyen.com):
|
|
10
|
+
|
|
11
|
+
```env
|
|
12
|
+
# Menggunakan .env (Direkomendasikan)
|
|
13
|
+
PROVIDER_PG=adyen
|
|
14
|
+
ADYEN_API_KEY=AQE...
|
|
15
|
+
ADYEN_MERCHANT_ACCOUNT=YourMerchantAccount
|
|
16
|
+
ADYEN_CLIENT_KEY=test_...
|
|
17
|
+
ADYEN_HMAC_KEY=4A6...
|
|
18
|
+
ADYEN_SANDBOX=true
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Atau inisialisasi manual:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Buayar } from "@crediblemark/buayar";
|
|
25
|
+
|
|
26
|
+
const buayarAdyen = new Buayar({
|
|
27
|
+
provider: "adyen",
|
|
28
|
+
apiKey: "AQE...",
|
|
29
|
+
merchantCode: "YourMerchantAccount",
|
|
30
|
+
extra: {
|
|
31
|
+
hmacKey: "4A6...",
|
|
32
|
+
},
|
|
33
|
+
sandbox: true,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🛠️ Membuat Transaksi
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { buayar } from "@crediblemark/buayar";
|
|
43
|
+
|
|
44
|
+
const invoice = await buayar.createInvoice({
|
|
45
|
+
orderId: "ORDER-ADYEN-001",
|
|
46
|
+
amount: 150000,
|
|
47
|
+
currency: "IDR",
|
|
48
|
+
productDetails: "Annual Cloud Hosting",
|
|
49
|
+
customer: {
|
|
50
|
+
name: "Alex",
|
|
51
|
+
email: "alex@example.com",
|
|
52
|
+
},
|
|
53
|
+
returnUrl: "https://myapp.com/payment/return",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (invoice.success) {
|
|
57
|
+
console.log("Checkout URL:", invoice.paymentUrl);
|
|
58
|
+
console.log("Session ID:", invoice.reference);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 💳 Integrasi Braintree (`braintree`)
|
|
2
|
+
|
|
3
|
+
Panduan lengkap integrasi Payment Gateway **Braintree (PayPal Service)** dengan `@crediblemark/buayar`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚙️ Konfigurasi Kredensial
|
|
8
|
+
|
|
9
|
+
Kredensial Braintree dapat diperoleh melalui dashboard [sandbox.braintreegateway.com](https://sandbox.braintreegateway.com):
|
|
10
|
+
|
|
11
|
+
```env
|
|
12
|
+
# Menggunakan .env (Direkomendasikan)
|
|
13
|
+
PROVIDER_PG=braintree
|
|
14
|
+
BRAINTREE_MERCHANT_ID=...
|
|
15
|
+
BRAINTREE_PUBLIC_KEY=...
|
|
16
|
+
BRAINTREE_PRIVATE_KEY=...
|
|
17
|
+
BRAINTREE_SANDBOX=true
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Atau inisialisasi manual:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
+
|
|
25
|
+
const buayarBraintree = new Buayar({
|
|
26
|
+
provider: "braintree",
|
|
27
|
+
merchantCode: "...", // Merchant ID
|
|
28
|
+
clientKey: "...", // Public Key
|
|
29
|
+
apiKey: "...", // Private Key
|
|
30
|
+
sandbox: true,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🛠️ Membuat Transaksi
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { buayar } from "@crediblemark/buayar";
|
|
40
|
+
|
|
41
|
+
// Menghasilkan client token untuk Braintree Drop-in UI
|
|
42
|
+
const invoice = await buayar.createInvoice({
|
|
43
|
+
orderId: "ORDER-BT-001",
|
|
44
|
+
amount: 2000, // minor units ($20.00)
|
|
45
|
+
currency: "USD",
|
|
46
|
+
productDetails: "Annual Premium Tier",
|
|
47
|
+
customer: {
|
|
48
|
+
name: "Bruce Wayne",
|
|
49
|
+
email: "bruce@example.com",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (invoice.success) {
|
|
54
|
+
// Client token untuk dioper ke Drop-in UI Braintree di frontend
|
|
55
|
+
console.log("Client Token:", invoice.paymentUrl || invoice.reference);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# 💳 Integrasi Checkout.com (`checkoutcom`)
|
|
2
|
+
|
|
3
|
+
Panduan lengkap integrasi Payment Gateway **Checkout.com (Payment Links API)** dengan `@crediblemark/buayar`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚙️ Konfigurasi Kredensial
|
|
8
|
+
|
|
9
|
+
Kredensial Checkout.com dapat diperoleh melalui [dashboard.checkout.com](https://dashboard.checkout.com):
|
|
10
|
+
|
|
11
|
+
```env
|
|
12
|
+
# Menggunakan .env (Direkomendasikan)
|
|
13
|
+
PROVIDER_PG=checkoutcom
|
|
14
|
+
CHECKOUTCOM_SECRET_KEY=sk_sbox_...
|
|
15
|
+
CHECKOUTCOM_PUBLIC_KEY=pk_sbox_...
|
|
16
|
+
CHECKOUTCOM_WEBHOOK_SECRET=...
|
|
17
|
+
CHECKOUTCOM_SANDBOX=true
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Atau inisialisasi manual:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
+
|
|
25
|
+
const buayarCko = new Buayar({
|
|
26
|
+
provider: "checkoutcom",
|
|
27
|
+
apiKey: "sk_sbox_...",
|
|
28
|
+
clientKey: "pk_sbox_...",
|
|
29
|
+
extra: {
|
|
30
|
+
webhookSecret: "...",
|
|
31
|
+
},
|
|
32
|
+
sandbox: true,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🛠️ Membuat Transaksi
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { buayar } from "@crediblemark/buayar";
|
|
42
|
+
|
|
43
|
+
const invoice = await buayar.createInvoice({
|
|
44
|
+
orderId: "ORDER-CKO-001",
|
|
45
|
+
amount: 5000, // minor units (misal $50.00 / GBP 50.00)
|
|
46
|
+
currency: "GBP",
|
|
47
|
+
productDetails: "Design Consultation Fee",
|
|
48
|
+
customer: {
|
|
49
|
+
name: "Oliver Twist",
|
|
50
|
+
email: "oliver@example.com",
|
|
51
|
+
},
|
|
52
|
+
returnUrl: "https://myapp.com/payment/success",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (invoice.success) {
|
|
56
|
+
console.log("Hosted Payment Link:", invoice.paymentUrl);
|
|
57
|
+
console.log("Payment Reference:", invoice.reference);
|
|
58
|
+
}
|
|
59
|
+
```
|
package/docs/doku.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# 💳 Integrasi DOKU Jokul (`doku`)
|
|
2
|
+
|
|
3
|
+
Panduan lengkap integrasi Payment Gateway **DOKU (Jokul v2)** dengan `@crediblemark/buayar`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚙️ Konfigurasi Kredensial
|
|
8
|
+
|
|
9
|
+
Kredensial DOKU dapat diperoleh melalui dashboard [jokul.doku.com](https://jokul.doku.com):
|
|
10
|
+
|
|
11
|
+
```env
|
|
12
|
+
# Menggunakan .env (Direkomendasikan)
|
|
13
|
+
PROVIDER_PG=doku
|
|
14
|
+
DOKU_CLIENT_ID=MALL-ID-xxxxxxxx
|
|
15
|
+
DOKU_SECRET_KEY=SK-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
16
|
+
DOKU_SANDBOX=true
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Atau inisialisasi manual:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Buayar } from "@crediblemark/buayar";
|
|
23
|
+
|
|
24
|
+
const buayarDoku = new Buayar({
|
|
25
|
+
provider: "doku",
|
|
26
|
+
merchantCode: "MALL-ID-xxxxxxxx", // Client ID
|
|
27
|
+
apiKey: "SK-xxxxxxxxxxxxxxxxxxxxxxxxxxxx", // Secret Key
|
|
28
|
+
sandbox: true,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🛠️ Membuat Transaksi
|
|
35
|
+
|
|
36
|
+
### 1. Semi Integrasi (Jokul Checkout Page)
|
|
37
|
+
Kosongkan parameter `paymentMethod`:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { buayar } from "@crediblemark/buayar";
|
|
41
|
+
|
|
42
|
+
const invoice = await buayar.createInvoice({
|
|
43
|
+
orderId: "ORDER-DOKU-001",
|
|
44
|
+
amount: 250000,
|
|
45
|
+
productDetails: "Sepatu Olahraga Pria",
|
|
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 Jokul DOKU
|
|
56
|
+
console.log("Checkout URL:", invoice.paymentUrl);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Full Integrasi (Direct VA / QRIS / Retail / E-Wallet)
|
|
61
|
+
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `alfamart`, `indomaret`, `ovo`, `dana`):
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Direct Virtual Account (Jokul v2)
|
|
65
|
+
const va = await buayar.createInvoice({
|
|
66
|
+
orderId: "ORDER-DOKU-002",
|
|
67
|
+
amount: 150000,
|
|
68
|
+
paymentMethod: "bca_va",
|
|
69
|
+
productDetails: "Top Up Game",
|
|
70
|
+
customer: { name: "Budi", email: "budi@example.com" },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
console.log("Nomor VA BCA:", va.vaNumber);
|
|
74
|
+
console.log("Panduan Bayar:", va.paymentUrl);
|
|
75
|
+
console.log("Expired At:", va.expiresAt);
|
|
76
|
+
|
|
77
|
+
// Direct QRIS
|
|
78
|
+
const qris = await buayar.createInvoice({
|
|
79
|
+
orderId: "ORDER-DOKU-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 `DokuClient` (Cek Status Pesanan)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { buayar } from "@crediblemark/buayar";
|
|
96
|
+
|
|
97
|
+
const dokuClient = buayar.getDokuClient();
|
|
98
|
+
|
|
99
|
+
// Cek status pesanan via Invoice Number
|
|
100
|
+
const orderStatus = await dokuClient.checkTransaction("ORDER-DOKU-001");
|
|
101
|
+
console.log("Status Pesanan:", orderStatus);
|
|
102
|
+
```
|
package/docs/duitku.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
```
|