@crediblemark/buayar 0.3.2 → 0.5.1
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/cli/index.js +643 -0
- package/dist/index.d.mts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +210 -5
- package/dist/index.mjs +210 -5
- package/docs/guide.md +356 -0
- package/package.json +12 -4
- 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/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
|
-
```
|
package/docs/midtrans.md
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Midtrans (`midtrans`)
|
|
2
|
-
|
|
3
|
-
Halaman ini berisi panduan lengkap untuk menggunakan provider **Midtrans** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
Untuk menggunakan provider Midtrans, Anda perlu menyiapkan objek konfigurasi berikut:
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
const providerConfig = {
|
|
12
|
-
merchantCode: "", // Boleh kosong / diisi string kosong untuk Midtrans
|
|
13
|
-
apiKey: "SB-Mid-server-xxxx", // Server Key Midtrans Anda
|
|
14
|
-
sandbox: true, // Set true untuk Sandbox, false untuk Production
|
|
15
|
-
};
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## 🛠️ Membuat Transaksi (Invoice)
|
|
21
|
-
|
|
22
|
-
### 1. Mode Snap API (Halaman Pembayaran Midtrans / Redirect)
|
|
23
|
-
Jika Anda ingin menggunakan halaman Snap Midtrans yang telah disediakan untuk menyelesaikan transaksi pelanggan:
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { paymentManager } from "@crediblemark/buayar";
|
|
27
|
-
|
|
28
|
-
const invoiceParams = {
|
|
29
|
-
orderId: "ORDER-200350",
|
|
30
|
-
amount: 250000, // Nominal dalam Rupiah (integer)
|
|
31
|
-
productDetails: "Pembelian Lisensi Software 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 checkoutSnap() {
|
|
42
|
-
try {
|
|
43
|
-
const result = await paymentManager.createInvoice(
|
|
44
|
-
"midtrans",
|
|
45
|
-
invoiceParams,
|
|
46
|
-
providerConfig
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (result.success) {
|
|
50
|
-
console.log("Invoice Snap Berhasil Dibuat! 🎉");
|
|
51
|
-
console.log("Redirect URL:", result.paymentUrl); // Redirect pelanggan ke URL ini
|
|
52
|
-
console.log("Snap Token:", result.reference);
|
|
53
|
-
} else {
|
|
54
|
-
console.error("Gagal membuat invoice Snap:", result.error);
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error("Error:", error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 2. Mode Core API / Direct Charge (Dapatkan VA / QRIS Instan)
|
|
63
|
-
Jika Anda ingin mengambil detail pembayaran secara langsung tanpa memunculkan UI Snap Midtrans, sertakan parameter `paymentMethod`:
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
const coreParams = {
|
|
67
|
-
...invoiceParams,
|
|
68
|
-
paymentMethod: "bca_va", // Pilihan: bca_va, bni_va, bri_va, mandiri_va, qris, gopay, dll.
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
async function checkoutDirect() {
|
|
72
|
-
try {
|
|
73
|
-
const result = await paymentManager.createInvoice(
|
|
74
|
-
"midtrans",
|
|
75
|
-
coreParams,
|
|
76
|
-
providerConfig
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (result.success) {
|
|
80
|
-
console.log("Nomor VA BCA:", result.vaNumber);
|
|
81
|
-
console.log("Transaksi Reference ID:", result.reference);
|
|
82
|
-
} else {
|
|
83
|
-
console.error("Gagal memproses Direct Charge:", result.error);
|
|
84
|
-
}
|
|
85
|
-
} catch (error) {
|
|
86
|
-
console.error("Error:", error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
#### Kode `paymentMethod` Core API yang Didukung:
|
|
92
|
-
- **Virtual Account (VA)**: `bca_va`, `bni_va`, `bri_va`, `permata_va`, `cimb_va`, `danamon_va`, `bsi_va`, `seabank_va`, `mandiri_va` (menggunakan echannel).
|
|
93
|
-
- **QRIS & E-Wallet**: `qris`, `gopay`, `shopeepay`, `ovo` (membutuhkan nomor telepon yang terdaftar pada `customer.phone`), `dana`, `linkaja`.
|
|
94
|
-
- **Retail Outlet**: `alfamart`, `indomaret`.
|
|
95
|
-
- **Kartu Kredit & Google Pay**: `credit_card` (memerlukan `token_id` dari browser client pada `providerParams.credit_card.token_id`), `googlepay`.
|
|
96
|
-
- **Paylater / Cicilan**: `kredivo`, `akulaku`.
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## 🔔 Verifikasi Webhook Callback
|
|
101
|
-
Gunakan fungsi ini di endpoint API notifikasi Midtrans untuk memverifikasi keaslian signature SHA-512:
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
import { paymentManager } from "@crediblemark/buayar";
|
|
105
|
-
|
|
106
|
-
async function handleMidtransCallback(req: any, res: any) {
|
|
107
|
-
const callbackPayload = req.body; // Payload POST dari Midtrans
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const verification = await paymentManager.verifyCallback(
|
|
111
|
-
"midtrans",
|
|
112
|
-
callbackPayload,
|
|
113
|
-
providerConfig
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
if (verification.isValid) {
|
|
117
|
-
console.log(`Signature valid untuk Order ID: ${verification.orderId}`);
|
|
118
|
-
|
|
119
|
-
if (verification.status === "paid") {
|
|
120
|
-
console.log("Status: PEMBAYARAN LUNAS! ✅");
|
|
121
|
-
// Update database: Tandai transaksi selesai
|
|
122
|
-
} else if (verification.status === "failed") {
|
|
123
|
-
console.log("Status: PEMBAYARAN GAGAL ❌");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
res.status(200).json({ status: "OK" });
|
|
127
|
-
} else {
|
|
128
|
-
console.warn("Peringatan: Signature callback tidak valid!");
|
|
129
|
-
res.status(400).send("Invalid Signature");
|
|
130
|
-
}
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("Gagal memproses callback:", error);
|
|
133
|
-
res.status(500).send("Internal Server Error");
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## 🔍 Cek Status Transaksi Manual
|
|
141
|
-
```typescript
|
|
142
|
-
async function checkMidtransStatus() {
|
|
143
|
-
const result = await paymentManager.checkTransaction(
|
|
144
|
-
"midtrans",
|
|
145
|
-
{ merchantOrderId: "ORDER-200350" },
|
|
146
|
-
providerConfig
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
if (result.success) {
|
|
150
|
-
console.log("Status Transaksi:", result.status); // "paid" | "pending" | "failed"
|
|
151
|
-
console.log("Pesan Status:", result.statusMessage);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## ⚡ Fitur Khusus: Midtrans Client (`MidtransClient`)
|
|
159
|
-
|
|
160
|
-
Jika Anda memerlukan manipulasi transaksi pasca-pembayaran atau fitur-fitur spesifik Midtrans yang tidak masuk ke dalam interface umum SDK, Anda dapat membuat instance `MidtransClient`:
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
const midtransClient = paymentManager.getMidtransClient(providerConfig);
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### 1. Transaksi & Refund
|
|
167
|
-
* **Membatalkan Transaksi**
|
|
168
|
-
```typescript
|
|
169
|
-
await midtransClient.cancelTransaction("ORDER-200350");
|
|
170
|
-
```
|
|
171
|
-
* **Melakukan Refund**
|
|
172
|
-
```typescript
|
|
173
|
-
await midtransClient.refundTransaction("ORDER-200350", {
|
|
174
|
-
amount: 50000,
|
|
175
|
-
reason: "Pengembalian dana produk cacat",
|
|
176
|
-
});
|
|
177
|
-
```
|
|
178
|
-
* **Mengubah Transaksi Menjadi Kadaluarsa (Force Expire)**
|
|
179
|
-
```typescript
|
|
180
|
-
await midtransClient.expireTransaction("ORDER-200350");
|
|
181
|
-
```
|
|
182
|
-
* **Aksi Lainnya**: `approveTransaction(orderId)`, `denyTransaction(orderId)`, `captureTransaction(transactionId, amount)`.
|
|
183
|
-
|
|
184
|
-
### 2. GoPay Tokenization API
|
|
185
|
-
Digunakan untuk menautkan dan mengelola akun GoPay pengguna di platform Anda:
|
|
186
|
-
- `linkPayAccount(payload)`: Mendaftarkan akun GoPay pengguna.
|
|
187
|
-
- `getPayAccount(accountId)`: Mengambil status tokenisasi akun GoPay.
|
|
188
|
-
- `unbindPayAccount(accountId)`: Memutuskan tautan akun GoPay.
|
|
189
|
-
- `getGoPayPromo(accountId, grossAmount)`: Mengambil promo GoPay yang tersedia untuk akun tersebut.
|
|
190
|
-
|
|
191
|
-
### 3. Subscription (Recurring) API
|
|
192
|
-
Digunakan untuk layanan berlangganan berkala:
|
|
193
|
-
- `createSubscription(payload)`: Membuat paket langganan baru.
|
|
194
|
-
- `getSubscription(subscriptionId)`: Mengambil status langganan.
|
|
195
|
-
- `updateSubscription(subscriptionId, payload)`: Memperbarui paket langganan.
|
|
196
|
-
- `disableSubscription(subscriptionId)`: Menonaktifkan langganan.
|
|
197
|
-
- `enableSubscription(subscriptionId)`: Mengaktifkan kembali langganan.
|
|
198
|
-
|
|
199
|
-
### 4. Payment Link API
|
|
200
|
-
- `createPaymentLink(payload)`: Membuat tautan pembayaran instan Midtrans.
|
|
201
|
-
- `getPaymentLink(paymentLinkId)`: Mengambil detail tautan pembayaran.
|
|
202
|
-
- `deletePaymentLink(paymentLinkId)`: Menghapus tautan pembayaran.
|
|
203
|
-
|
|
204
|
-
### 5. Invoicing & Balance API
|
|
205
|
-
- `createBillingInvoice(payload)`: Membuat e-invoice.
|
|
206
|
-
- `voidBillingInvoice(invoiceId)`: Membatalkan e-invoice.
|
|
207
|
-
- `getBalance()`: Mengambil sisa saldo merchant (Mendukung integrasi IRIS API).
|
package/docs/nicepay.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Nicepay (`nicepay`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Nicepay (IONPAY)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Nicepay dapat diperoleh melalui dashboard [merchant.nicepay.co.id](https://merchant.nicepay.co.id):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=nicepay
|
|
14
|
-
NICEPAY_IMID=IONPAYTEST
|
|
15
|
-
NICEPAY_KEY=nicepay-merchant-key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
16
|
-
NICEPAY_SANDBOX=true
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Atau inisialisasi manual:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
23
|
-
|
|
24
|
-
const buayarNicepay = new Buayar({
|
|
25
|
-
provider: "nicepay",
|
|
26
|
-
merchantCode: "IONPAYTEST", // iMid
|
|
27
|
-
apiKey: "nicepay-merchant-key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // Merchant Key
|
|
28
|
-
sandbox: true,
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🛠️ Membuat Transaksi
|
|
35
|
-
|
|
36
|
-
### 1. Semi Integrasi (Order Regist / Hosted Checkout)
|
|
37
|
-
Kosongkan parameter `paymentMethod`:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { buayar } from "@crediblemark/buayar";
|
|
41
|
-
|
|
42
|
-
const invoice = await buayar.createInvoice({
|
|
43
|
-
orderId: "ORDER-NICE-001",
|
|
44
|
-
amount: 250000,
|
|
45
|
-
productDetails: "Sepatu Olahraga Running",
|
|
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 Nicepay
|
|
56
|
-
console.log("Payment 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 (oneStepVa.do)
|
|
65
|
-
const va = await buayar.createInvoice({
|
|
66
|
-
orderId: "ORDER-NICE-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("Bank Code:", va.vaBank);
|
|
75
|
-
console.log("Expired At:", va.expiresAt);
|
|
76
|
-
|
|
77
|
-
// Direct QRIS (oneStepQris.do)
|
|
78
|
-
const qris = await buayar.createInvoice({
|
|
79
|
-
orderId: "ORDER-NICE-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 `NicepayClient` (Inquiry & Cancel)
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
import { buayar } from "@crediblemark/buayar";
|
|
96
|
-
|
|
97
|
-
const nicepayClient = buayar.getNicepayClient();
|
|
98
|
-
|
|
99
|
-
// 1. Cek status transaksi pembayaran
|
|
100
|
-
const status = await nicepayClient.checkTransaction("ORDER-NICE-001", 250000);
|
|
101
|
-
console.log("Status Transaksi:", status);
|
|
102
|
-
|
|
103
|
-
// 2. Batalkan transaksi
|
|
104
|
-
const cancel = await nicepayClient.cancelTransaction("TX-NICE-123456", "02", "Pembatalan oleh Merchant");
|
|
105
|
-
console.log("Hasil Cancel:", cancel);
|
|
106
|
-
```
|
package/docs/oy.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi OY! Bisnis (`oy`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **OY! Indonesia (OY! Bisnis)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial OY! Bisnis dapat diperoleh melalui dashboard [business.oyindonesia.com](https://business.oyindonesia.com):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=oy
|
|
14
|
-
OY_USERNAME=myusername
|
|
15
|
-
OY_API_KEY=oy-secret-key-xxxxxxxxxxxxxxxxxxxxxxxx
|
|
16
|
-
OY_SANDBOX=true
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Atau inisialisasi manual:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
23
|
-
|
|
24
|
-
const buayarOy = new Buayar({
|
|
25
|
-
provider: "oy",
|
|
26
|
-
merchantCode: "myusername", // OY Username
|
|
27
|
-
apiKey: "oy-secret-key-xxxxxxxxxxxxxxxxxxxxxxxx", // API Key
|
|
28
|
-
sandbox: true,
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🛠️ Membuat Transaksi
|
|
35
|
-
|
|
36
|
-
### 1. Semi Integrasi (Payment Checkout Link v2)
|
|
37
|
-
Kosongkan parameter `paymentMethod`:
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { buayar } from "@crediblemark/buayar";
|
|
41
|
-
|
|
42
|
-
const invoice = await buayar.createInvoice({
|
|
43
|
-
orderId: "ORDER-OY-001",
|
|
44
|
-
amount: 250000,
|
|
45
|
-
productDetails: "Sepatu Olahraga Running",
|
|
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 OY! Bisnis
|
|
56
|
-
console.log("Payment URL:", invoice.paymentUrl);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 2. Full Integrasi (Direct VA / QRIS)
|
|
61
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `alfamart`, `indomaret`):
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// Direct Virtual Account (generate-static-va)
|
|
65
|
-
const va = await buayar.createInvoice({
|
|
66
|
-
orderId: "ORDER-OY-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("Reference:", va.reference);
|
|
75
|
-
|
|
76
|
-
// Direct QRIS (qris/create-transaction)
|
|
77
|
-
const qris = await buayar.createInvoice({
|
|
78
|
-
orderId: "ORDER-OY-003",
|
|
79
|
-
amount: 50000,
|
|
80
|
-
paymentMethod: "qris",
|
|
81
|
-
productDetails: "Kopi",
|
|
82
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
console.log("Raw QRIS (EMVCo):", qris.qrString);
|
|
86
|
-
console.log("QR Image URL:", qris.qrCodeUrl);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## 🏦 Ekstensi `OyClient` (Cek Status, Saldo & Kirim Uang)
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
import { buayar } from "@crediblemark/buayar";
|
|
95
|
-
|
|
96
|
-
const oyClient = buayar.getOyClient();
|
|
97
|
-
|
|
98
|
-
// 1. Cek status pembayaran transaksi
|
|
99
|
-
const status = await oyClient.checkTransaction("ORDER-OY-001");
|
|
100
|
-
console.log("Status Pesanan:", status);
|
|
101
|
-
|
|
102
|
-
// 2. Cek saldo akun OY! Bisnis
|
|
103
|
-
const balance = await oyClient.checkBalance();
|
|
104
|
-
console.log("Saldo Merchant:", balance);
|
|
105
|
-
|
|
106
|
-
// 3. Kirim Uang / Transfer Dana (Disbursement / Remittance)
|
|
107
|
-
const remit = await oyClient.remit({
|
|
108
|
-
recipientBank: "014", // BCA
|
|
109
|
-
recipientAccount: "1234567890",
|
|
110
|
-
amount: 500000,
|
|
111
|
-
note: "Penarikan Dana Mitra",
|
|
112
|
-
partnerTrxId: "DISB-001",
|
|
113
|
-
});
|
|
114
|
-
console.log("Hasil Transfer:", remit);
|
|
115
|
-
```
|
package/docs/paypal.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi PayPal (`paypal`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **PayPal REST API v2** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial PayPal dapat diperoleh melalui [developer.paypal.com/dashboard/applications](https://developer.paypal.com/dashboard/applications):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=paypal
|
|
14
|
-
PAYPAL_CLIENT_ID=Ae...
|
|
15
|
-
PAYPAL_CLIENT_SECRET=EL...
|
|
16
|
-
PAYPAL_WEBHOOK_ID=...
|
|
17
|
-
PAYPAL_SANDBOX=true
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Atau inisialisasi manual:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
-
|
|
25
|
-
const buayarPaypal = new Buayar({
|
|
26
|
-
provider: "paypal",
|
|
27
|
-
clientKey: "Ae...", // Client ID
|
|
28
|
-
apiKey: "EL...", // Client Secret
|
|
29
|
-
sandbox: true,
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 🛠️ Membuat Transaksi
|
|
36
|
-
|
|
37
|
-
### Semi Integrasi (PayPal Hosted Checkout / Orders API)
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { buayar } from "@crediblemark/buayar";
|
|
41
|
-
|
|
42
|
-
const invoice = await buayar.createInvoice({
|
|
43
|
-
orderId: "ORDER-PP-001",
|
|
44
|
-
amount: 2500, // Misal $25.00 (atau dalam satuan mata uang terpilih)
|
|
45
|
-
currency: "USD",
|
|
46
|
-
productDetails: "Digital eBook License",
|
|
47
|
-
customer: {
|
|
48
|
-
name: "Jane Smith",
|
|
49
|
-
email: "jane@example.com",
|
|
50
|
-
},
|
|
51
|
-
returnUrl: "https://myapp.com/payment/success",
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (invoice.success) {
|
|
55
|
-
// Arahkan pembeli ke URL pembayaran PayPal
|
|
56
|
-
console.log("PayPal Approval URL:", invoice.paymentUrl);
|
|
57
|
-
console.log("PayPal Order ID:", invoice.reference);
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## 🏦 Ekstensi `PaypalClient`
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import { buayar } from "@crediblemark/buayar";
|
|
67
|
-
|
|
68
|
-
const paypalClient = buayar.getPaypalClient();
|
|
69
|
-
|
|
70
|
-
// Capture pesanan yang telah disetujui pembeli
|
|
71
|
-
const captureResult = await paypalClient.captureOrder("PAYPAL-ORDER-ID");
|
|
72
|
-
console.log("Capture Result:", captureResult);
|
|
73
|
-
```
|
package/docs/payu.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi PayU (`payu`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **PayU (OpenPayU REST API v2.1)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial PayU dapat diperoleh melalui dashboard merchant PayU:
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=payu
|
|
14
|
-
PAYU_POS_ID=300746
|
|
15
|
-
PAYU_MD5_KEY=...
|
|
16
|
-
PAYU_OAUTH_CLIENT_ID=300746
|
|
17
|
-
PAYU_OAUTH_CLIENT_SECRET=...
|
|
18
|
-
PAYU_SANDBOX=true
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Atau inisialisasi manual:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
25
|
-
|
|
26
|
-
const buayarPayu = new Buayar({
|
|
27
|
-
provider: "payu",
|
|
28
|
-
merchantCode: "300746", // POS ID
|
|
29
|
-
apiKey: "...", // MD5 Key
|
|
30
|
-
extra: {
|
|
31
|
-
oauthClientId: "300746",
|
|
32
|
-
oauthClientSecret: "...",
|
|
33
|
-
},
|
|
34
|
-
sandbox: true,
|
|
35
|
-
});
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 🛠️ Membuat Transaksi
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { buayar } from "@crediblemark/buayar";
|
|
44
|
-
|
|
45
|
-
const invoice = await buayar.createInvoice({
|
|
46
|
-
orderId: "ORDER-PAYU-001",
|
|
47
|
-
amount: 10000, // minor units (100.00 PLN)
|
|
48
|
-
currency: "PLN",
|
|
49
|
-
productDetails: "Online Subscription",
|
|
50
|
-
customer: {
|
|
51
|
-
name: "Jan Kowalski",
|
|
52
|
-
email: "jan@example.pl",
|
|
53
|
-
},
|
|
54
|
-
returnUrl: "https://myapp.com/payment/summary",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (invoice.success) {
|
|
58
|
-
console.log("PayU Redirect URL:", invoice.paymentUrl);
|
|
59
|
-
console.log("PayU Order ID:", invoice.reference);
|
|
60
|
-
}
|
|
61
|
-
```
|