@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/docs/guide.md ADDED
@@ -0,0 +1,356 @@
1
+ # 💳 Panduan Unified `@crediblemark/buayar`
2
+
3
+ Panduan ini adalah **satu-satunya** panduan yang Anda butuhkan untuk mengintegrasikan **semua** payment gateway yang didukung Buayar (19 provider: 10 Indonesia + 9 Internasional). Anda **tidak perlu** membaca dokumentasi masing-masing PG — kode yang Anda tulis **identik** untuk semua provider.
4
+
5
+ > 🎯 **Prinsip "mata tertutup":** Anda 100% tidak tahu (dan tidak perlu tahu) provider mana yang sedang aktif. Yang Anda tahu hanya: "Buaya mendukung PG A, PG B, PG C". Cukup ubah kredensial di `.env`, semuanya jalan.
6
+
7
+ ---
8
+
9
+ ## 📑 Daftar Isi
10
+
11
+ 1. [Filosofi Unified](#-filosofi-unified)
12
+ 2. [Inisialisasi & Konfigurasi](#-inisialisasi--konfigurasi)
13
+ 3. [Membuat Transaksi (Semi & Full)](#-membuat-transaksi)
14
+ 4. [Ambil Metode Pembayaran (Accordion-Ready)](#-ambil-metode-pembayaran)
15
+ 5. [Cek Status Transaksi](#-cek-status-transaksi)
16
+ 6. [Webhook Universal](#-webhook-universal)
17
+ 7. [Refund / Saldo / Payout Unified](#-refund--saldo--payout-unified)
18
+ 8. [Zero-Code PG Switch](#-zero-code-pg-switch)
19
+ 9. [Fitur Khusus Provider (`<X>Client`)](#-fitur-khusus-provider-xclient)
20
+ 10. [Kamus Variabel `.env` per Provider](#-kamus-variabel-env-per-provider)
21
+
22
+ ---
23
+
24
+ ## 🧠 Filosofi Unified
25
+
26
+ Seluruh provider mengimplementasikan **satu kontrak API** yang sama. Artinya:
27
+
28
+ | Kebutuhan Anda | API yang Anda gunakan |
29
+ | :--- | :--- |
30
+ | Checkout (redirect / direct) | `buayar.createInvoice()` |
31
+ | Daftar channel pembayaran | `buayar.getPaymentMethods()` |
32
+ | Cek status transaksi | `buayar.checkTransaction()` |
33
+ | Verifikasi callback | `buayar.verifyWebhook()` |
34
+ | Refund | `buayar.refund()` |
35
+ | Cek saldo merchant | `buayar.checkBalance()` |
36
+ | Transfer dana / payout | `buayar.disburse()` |
37
+ | Fitur benar-benar eksklusif per PG | `buayar.get<X>Client()` |
38
+
39
+ Semua metode pembayaran memakai **kode canonical universal** (`bca_va`, `qris`, `gopay`, `alfamart`, dst.) yang dipetakan otomatis ke format internal provider aktif. Anda tidak pernah menyentuh format internal siapa pun.
40
+
41
+ ---
42
+
43
+ ## ⚙️ Inisialisasi & Konfigurasi
44
+
45
+ ### 1. Zero-Config (baca dari `.env`) — **Direkomendasikan**
46
+
47
+ ```env
48
+ # Pilih provider aktif: midtrans, duitku, ipaymu, xendit, doku, prismalink,
49
+ # faspay, finpay, nicepay, oy, stripe, paypal, adyen, checkoutcom,
50
+ # razorpay, square, payu, braintree, twocheckout
51
+ PROVIDER_PG=midtrans
52
+
53
+ # Kredensial Universal (dipetakan otomatis per provider)
54
+ BUAYAR_API_KEY=your-server-key-atau-secret
55
+ BUAYAR_MERCHANT_CODE=merchant-id-atau-username
56
+ BUAYAR_SANDBOX=true
57
+
58
+ # Callback & Return URL
59
+ BUAYAR_CALLBACK_URL=https://myapp.com/api/payment/webhook
60
+ BUAYAR_RETURN_URL=https://myapp.com/payment/finish
61
+ ```
62
+
63
+ ```typescript
64
+ import { buayar } from "@crediblemark/buayar";
65
+ // Konfigurasi ter-baca otomatis dari process.env. Selesai.
66
+ ```
67
+
68
+ ### 2. Inisialisasi Manual (programatik)
69
+
70
+ ```typescript
71
+ import { Buayar } from "@crediblemark/buayar";
72
+
73
+ const buayar = new Buayar({
74
+ provider: "xendit",
75
+ apiKey: "xnd_development_xxxx",
76
+ merchantCode: "", // jika dibutuhkan (mis. Midtrans boleh kosong)
77
+ sandbox: true,
78
+ extra: { webhookSecret: "whsec_..." }, // untuk provider yang butuh secret tambahan
79
+ });
80
+ ```
81
+
82
+ > 💡 Banyak `get<X>Client()` juga bisa dipakai dengan meneruskan `provider` di `configOverride` agar menargetkan provider tertentu dari satu instance `buayar`.
83
+
84
+ ---
85
+
86
+ ## 🛠️ Membuat Transaksi
87
+
88
+ ### Semi Integrasi (Redirect / Hosted Checkout)
89
+
90
+ Tanpa `paymentMethod`, SDK mengembalikan `paymentUrl` untuk mengarahkan pelanggan ke halaman checkout PG.
91
+
92
+ ```typescript
93
+ import { buayar } from "@crediblemark/buayar";
94
+
95
+ const invoice = await buayar.createInvoice({
96
+ orderId: "ORDER-1001",
97
+ amount: 250000,
98
+ currency: "IDR", // wajib untuk PG internasional (USD, EUR, dll)
99
+ productDetails: "Pembelian Lisensi Software Premium",
100
+ customer: { name: "Budi", email: "budi@example.com", phone: "081234567890" },
101
+ returnUrl: "https://myapp.com/payment/success",
102
+ });
103
+
104
+ if (invoice.success) {
105
+ redirect(invoice.paymentUrl!); // redirect pelanggan ke sini
106
+ }
107
+ ```
108
+
109
+ ### Full Integrasi (Custom Native UI)
110
+
111
+ Sertakan `paymentMethod` dengan **kode canonical**. SDK mengembalikan data mentah (`vaNumber`, `qrString` EMVCo, `paymentCode`, `deeplink`) untuk dirender di UI Anda sendiri.
112
+
113
+ ```typescript
114
+ // Virtual Account
115
+ const va = await buayar.createInvoice({
116
+ orderId: "ORDER-1002",
117
+ amount: 150000,
118
+ paymentMethod: "bca_va", // canonical — berlaku di semua provider
119
+ productDetails: "Top Up Saldo",
120
+ customer: { name: "Budi", email: "budi@example.com" },
121
+ });
122
+ console.log("Nomor VA:", va.vaNumber); // "123456789012"
123
+ console.log("Bank:", va.vaBank); // "bca"
124
+
125
+ // QRIS
126
+ const qris = await buayar.createInvoice({
127
+ orderId: "ORDER-1003",
128
+ amount: 50000,
129
+ paymentMethod: "qris",
130
+ productDetails: "Kopi",
131
+ customer: { name: "Budi", email: "budi@example.com" },
132
+ });
133
+ console.log("Raw QRIS (EMVCo):", qris.qrString); // untuk dirender
134
+ console.log("QR Image URL:", qris.qrCodeUrl);
135
+ ```
136
+
137
+ ### Menargetkan Provider Tertentu (opsional)
138
+
139
+ Jika satu instance `buayar` dipakai untuk beberapa provider sekaligus, lewatkan `provider` pada `configOverride`:
140
+
141
+ ```typescript
142
+ const stripeInvoice = await buayar.createInvoice(
143
+ { orderId: "ORDER-2001", amount: 50000, paymentMethod: "credit_card" },
144
+ { provider: "stripe", apiKey: "sk_test_..." } // override provider & kredensial
145
+ );
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 📋 Ambil Metode Pembayaran
151
+
152
+ Dapatkan daftar channel aktif yang sudah dikelompokkan per kategori (accordion-ready), lengkap dengan fee dan icon URL.
153
+
154
+ ```typescript
155
+ const { categories } = await buayar.getPaymentMethods({ amount: 150000 });
156
+ // categories: { "Virtual Account": [...], "QRIS": [...], "E-Wallet": [...], ... }
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🔍 Cek Status Transaksi
162
+
163
+ ```typescript
164
+ const result = await buayar.checkTransaction({ merchantOrderId: "ORDER-1001" });
165
+
166
+ if (result.success) {
167
+ console.log("Status:", result.status); // "paid" | "pending" | "failed"
168
+ console.log("Pesan:", result.statusMessage);
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 🪝 Webhook Universal
175
+
176
+ Satu endpoint untuk semua provider. Provider **terdeteksi otomatis** dari struktur payload — tidak ada routing manual.
177
+
178
+ ```typescript
179
+ import { buayar } from "@crediblemark/buayar";
180
+
181
+ // Bekerja dengan Express, Elysia, Hono, Next.js App Router, dll.
182
+ app.post("/api/payment/webhook", async (req, res) => {
183
+ const result = await buayar.verifyWebhook(req.body, req.headers);
184
+ // header signature otomatis diekstrak sesuai provider (Stripe-Signature,
185
+ // Cko-Signature, X-Razorpay-Signature, dll.)
186
+
187
+ if (!result.isValid) return res.status(400).json({ error: "Invalid signature" });
188
+
189
+ if (result.isPaid) {
190
+ console.log(`✅ Order ${result.orderId} senilai ${result.amount} LUNAS!`);
191
+ // Aktifkan langganan / kirim produk
192
+ }
193
+
194
+ return res.status(200).json({ status: "OK" });
195
+ });
196
+ ```
197
+
198
+ > `buayar.handleWebhook(payload, headers)` adalah alias dari `verifyWebhook`.
199
+
200
+ ---
201
+
202
+ ## 💸 Refund / Saldo / Payout Unified
203
+
204
+ Selain alur transaksi inti, Buayar menyediakan **operasi lanjutan unified** untuk hal-hal yang paling sering dipakai: **refund**, **cek saldo**, dan **payout** (disbursement).
205
+
206
+ Sama seperti operasi lainnya — kode Anda **tidak bergantung provider**. Setiap operasi otomatis diarahkan ke provider aktif.
207
+
208
+ > 🧊 **Provider tanpa fitur** mengembalikan `{ supported: false }` — bukan error. Anda bisa cek `result.supported` untuk menangani fallback.
209
+
210
+ ### 1. Refund
211
+
212
+ ```typescript
213
+ const refund = await buayar.refund({
214
+ transactionId: "pi_3MtwBwLkdIwHu7ix28a3tqPa", // ID transaksi/capture/payment
215
+ amount: 50000, // opsional — default full refund
216
+ reason: "Produk cacat", // opsional, bila didukung provider
217
+ currency: "IDR", // opsional, untuk provider internasional
218
+ });
219
+
220
+ if (refund.success) {
221
+ console.log("Refund diproses:", refund.reference);
222
+ } else if (!refund.supported) {
223
+ console.log("Provider aktif tidak mendukung refund!");
224
+ }
225
+ ```
226
+
227
+ Mendukung: **Midtrans, Stripe, PayPal, Adyen, Checkout.com, Razorpay, Square, PayU, Braintree, 2Checkout**.
228
+
229
+ ### 2. Cek Saldo Merchant
230
+
231
+ ```typescript
232
+ const balance = await buayar.checkBalance();
233
+
234
+ if (balance.success) {
235
+ console.log("Saldo:", balance.balance, balance.currency);
236
+ }
237
+ ```
238
+
239
+ Mendukung: **Midtrans, Duitku, iPaymu, Xendit, OY!, Stripe, PayPal, Checkout.com, Razorpay, Square**.
240
+
241
+ ### 3. Payout / Transfer Dana (Disbursement)
242
+
243
+ ```typescript
244
+ const payout = await buayar.disburse({
245
+ externalId: "DISB-001", // ID unik merchant untuk transfer ini
246
+ bankCode: "BCA", // kode bank tujuan (ikuti aturan provider aktif)
247
+ accountHolderName: "Budi Santoso", // wajib untuk beberapa provider
248
+ accountNumber: "1234567890",
249
+ amount: 500000,
250
+ description: "Penarikan saldo mitra",
251
+ });
252
+
253
+ if (payout.success) {
254
+ console.log("Transfer diproses:", payout.reference);
255
+ }
256
+ ```
257
+
258
+ Mendukung: **Duitku, Xendit, OY!**.
259
+
260
+ ---
261
+
262
+ ## 🔄 Zero-Code PG Switch
263
+
264
+ Beralih provider **tanpa mengubah satu baris pun** di controller/service Anda — cukup ubah kredensial di `.env`:
265
+
266
+ ```env
267
+ # Sebelum: Midtrans
268
+ PROVIDER_PG=midtrans
269
+ MIDTRANS_SERVER_KEY=SB-Mid-server-xxxx
270
+
271
+ # Sesudah: Stripe — kode aplikasi TIDAK berubah
272
+ PROVIDER_PG=stripe
273
+ STRIPE_SECRET_KEY=sk_test_51...
274
+ STRIPE_WEBHOOK_SECRET=whsec_...
275
+ ```
276
+
277
+ ---
278
+
279
+ ## 🏦 Fitur Khusus Provider (`<X>Client`)
280
+
281
+ Refund, saldo, dan payout sudah tersedia secara **unified** di atas. Namun untuk **fitur yang benar-benar eksklusif** tiap PG yang tidak masuk interface umum (subscription, payment link, tokenisasi GoPay, billing invoice, dsb.), pakai getter client per provider:
282
+
283
+ ```typescript
284
+ const xendit = buayar.getXenditClient();
285
+ const balance = await xendit.checkBalance("CASH");
286
+ ```
287
+
288
+ Rangkuman kemampuan ekstra tiap provider:
289
+
290
+ | Provider | Getter | Kemampuan ekstra |
291
+ | :--- | :--- | :--- |
292
+ | Midtrans | `getMidtransClient()` | cancel/refund/expire/approve/deny/capture, GoPay tokenization, Subscription, Payment Link, IRIS balance |
293
+ | Duitku | `getDuitkuClient()` | balance, listBanks, inquiryBankAccount, disburse, checkDisbursementStatus |
294
+ | iPaymu | `getIpaymuClient()` | balance, checkTransaction |
295
+ | Xendit | `getXenditClient()` | balance, expireInvoice, createDisbursement |
296
+ | DOKU | `getDokuClient()` | checkTransaction |
297
+ | PrismaLink | `getPrismalinkClient()` | checkTransaction |
298
+ | Faspay | `getFaspayClient()` | cancelTransaction, checkTransaction |
299
+ | Finpay | `getFinpayClient()` | checkTransaction |
300
+ | Nicepay | `getNicepayClient()` | cancelTransaction, checkTransaction |
301
+ | OY! Bisnis | `getOyClient()` | checkTransaction, balance, remit (transfer dana) |
302
+ | Stripe | `getStripeClient()` | balance, createRefund, retrieveCheckoutSession, retrievePaymentIntent |
303
+ | PayPal | `getPaypalClient()` | captureOrder, getOrder, refundCapture, checkBalance, verifyWebhookSignature |
304
+ | Adyen | `getAdyenClient()` | capturePayment, cancelPayment, refundPayment, getPaymentDetails, getAvailablePaymentMethods |
305
+ | Checkout.com | `getCheckoutComClient()` | balance, refundPayment, voidPayment, getPaymentDetails, listPaymentLinks |
306
+ | Razorpay | `getRazorpayClient()` | capturePayment, createRefund, checkBalance, fetchPayment, listPayments |
307
+ | Square | `getSquareClient()` | retrieveBalance, refundPayment, cancelPayment, getPayment, listLocations |
308
+ | PayU | `getPayuClient()` | cancelOrder, getOrder, refundOrder |
309
+ | Braintree | `getBraintreeClient()` | getClientToken, findTransaction, refundTransaction, voidTransaction |
310
+ | 2Checkout | `getTwoCheckoutClient()` | getOrder, listOrders, getSubscription, refundOrder |
311
+
312
+ ---
313
+
314
+ ## 📚 Kamus Variabel `.env` per Provider
315
+
316
+ Anda hanya perlu mengisi kredensial provider yang **sedang aktif**. Gunakan variabel universal (`BUAYAR_*`) bila ingin kode benar-benar provider-agnostic, atau variabel spesifik di bawah.
317
+
318
+ | Provider | Variabel `.env` |
319
+ | :--- | :--- |
320
+ | Midtrans | `MIDTRANS_SERVER_KEY`, `MIDTRANS_CLIENT_KEY` |
321
+ | Duitku | `DUITKU_API_KEY`, `DUITKU_MERCHANT_CODE` |
322
+ | iPaymu | `IPAYMU_API_KEY`, `IPAYMU_VA` |
323
+ | Xendit | `XENDIT_SECRET_KEY`, `XENDIT_WEBHOOK_TOKEN` |
324
+ | DOKU | `DOKU_CLIENT_ID`, `DOKU_SECRET_KEY` |
325
+ | PrismaLink | `PRISMALINK_MERCHANT_ID`, `PRISMALINK_SECRET_KEY` |
326
+ | Faspay | `FASPAY_MERCHANT_ID`, `FASPAY_USER_ID`, `FASPAY_PASSWORD`, `FASPAY_MERCHANT_NAME` |
327
+ | Finpay | `FINPAY_MERCHANT_ID`, `FINPAY_MERCHANT_KEY` |
328
+ | Nicepay | `NICEPAY_IMID`, `NICEPAY_KEY` |
329
+ | OY! Bisnis | `OY_USERNAME`, `OY_API_KEY` |
330
+ | Stripe | `STRIPE_SECRET_KEY`, `STRIPE_PUBLIC_KEY`, `STRIPE_WEBHOOK_SECRET` |
331
+ | PayPal | `PAYPAL_CLIENT_ID`, `PAYPAL_CLIENT_SECRET`, `PAYPAL_WEBHOOK_ID` |
332
+ | Adyen | `ADYEN_API_KEY`, `ADYEN_MERCHANT_ACCOUNT`, `ADYEN_CLIENT_KEY`, `ADYEN_HMAC_KEY`, `ADYEN_LIVE_URL_PREFIX` |
333
+ | Checkout.com | `CHECKOUTCOM_SECRET_KEY`, `CHECKOUTCOM_PUBLIC_KEY`, `CHECKOUTCOM_WEBHOOK_SECRET` |
334
+ | Razorpay | `RAZORPAY_KEY_ID`, `RAZORPAY_KEY_SECRET`, `RAZORPAY_WEBHOOK_SECRET` |
335
+ | Square | `SQUARE_ACCESS_TOKEN`, `SQUARE_APPLICATION_ID`, `SQUARE_LOCATION_ID`, `SQUARE_WEBHOOK_SIGNATURE_KEY` |
336
+ | PayU | `PAYU_POS_ID`, `PAYU_MD5_KEY`, `PAYU_OAUTH_CLIENT_ID`, `PAYU_OAUTH_CLIENT_SECRET` |
337
+ | Braintree | `BRAINTREE_MERCHANT_ID`, `BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY` |
338
+ | 2Checkout | `TWOCHECKOUT_MERCHANT_CODE`, `TWOCHECKOUT_SECRET_KEY`, `TWOCHECKOUT_SECRET_WORD` |
339
+
340
+ Sandbox: otomatis terdeteksi dari `BUAYAR_SANDBOX`/`NODE_ENV`, atau set per-provider (mis. `STRIPE_SANDBOX=true`, `MIDTRANS_SANDBOX=true`).
341
+
342
+ ---
343
+
344
+ ## 🏷️ Daftar Canonical Payment Methods
345
+
346
+ | Kategori | Canonical Code |
347
+ | :--- | :--- |
348
+ | **Virtual Account** | `bca_va`, `mandiri_va`, `bni_va`, `bri_va`, `permata_va`, `cimb_va`, `danamon_va`, `bsi_va`, `seabank_va` |
349
+ | **QRIS** | `qris`, `gopay_qris`, `shopeepay_qris`, `nobu_qris` |
350
+ | **E-Wallet** | `gopay`, `shopeepay`, `ovo`, `dana`, `linkaja`, `jenius` |
351
+ | **Retail** | `alfamart`, `indomaret`, `pos` |
352
+ | **Kartu Kredit** | `credit_card` |
353
+ | **Paylater** | `kredivo`, `akulaku`, `indodana` |
354
+ | **International** | `apple_pay`, `google_pay`, `paypal`, `klarna`, `sepa` |
355
+
356
+ > Tidak semua canonical code tersedia di semua provider. Selalu gunakan `getPaymentMethods()` untuk memfilter channel yang benar-benar aktif pada provider Anda.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crediblemark/buayar",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Unified Payment Gateway SDK for Node.js & TypeScript — 19 providers (Midtrans, Xendit, Duitku, Stripe, PayPal, Adyen, Razorpay, Square, Checkout.com, PayU, Braintree, 2Checkout, DOKU, iPaymu, PrismaLink, Faspay, Finpay, Nicepay, OY!) with zero-code switching via .env",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/docs/adyen.md DELETED
@@ -1,60 +0,0 @@
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
- ```
package/docs/braintree.md DELETED
@@ -1,57 +0,0 @@
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
- ```
@@ -1,59 +0,0 @@
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 DELETED
@@ -1,102 +0,0 @@
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
- ```