@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/prismalink.md
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi PrismaLink (`prismalink`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **PrismaLink** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial PrismaLink dapat diperoleh melalui dashboard [docs.prismalink.co.id](https://docs.prismalink.co.id):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=prismalink
|
|
14
|
-
PRISMALINK_MERCHANT_ID=PRISMA-MERCHANT-001
|
|
15
|
-
PRISMALINK_SECRET_KEY=prisma-secret-xxxxxxxxxxxxxxxx
|
|
16
|
-
PRISMALINK_SANDBOX=true
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Atau inisialisasi manual:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
23
|
-
|
|
24
|
-
const buayarPrisma = new Buayar({
|
|
25
|
-
provider: "prismalink",
|
|
26
|
-
merchantCode: "PRISMA-MERCHANT-001", // Merchant ID
|
|
27
|
-
apiKey: "prisma-secret-xxxxxxxxxxxxxxxx", // Secret Key
|
|
28
|
-
sandbox: true,
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🛠️ Membuat Transaksi
|
|
35
|
-
|
|
36
|
-
### 1. Semi Integrasi (PrismaLink 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-PRISMA-001",
|
|
44
|
-
amount: 250000,
|
|
45
|
-
productDetails: "Paket Cloud Server Pro",
|
|
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 PrismaLink
|
|
56
|
-
console.log("Checkout URL:", invoice.paymentUrl);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 2. Full Integrasi (Direct VA / QRIS / Retail)
|
|
61
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `alfamart`, `indomaret`):
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// Direct Virtual Account
|
|
65
|
-
const va = await buayar.createInvoice({
|
|
66
|
-
orderId: "ORDER-PRISMA-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("Expired At:", va.expiresAt);
|
|
75
|
-
|
|
76
|
-
// Direct QRIS
|
|
77
|
-
const qris = await buayar.createInvoice({
|
|
78
|
-
orderId: "ORDER-PRISMA-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 `PrismalinkClient` (Cek Status Transaksi)
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
import { buayar } from "@crediblemark/buayar";
|
|
95
|
-
|
|
96
|
-
const prismaClient = buayar.getPrismalinkClient();
|
|
97
|
-
|
|
98
|
-
// Cek status transaksi via Order ID
|
|
99
|
-
const status = await prismaClient.checkTransaction("ORDER-PRISMA-001");
|
|
100
|
-
console.log("Status Pesanan:", status);
|
|
101
|
-
```
|
package/docs/razorpay.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Razorpay (`razorpay`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Razorpay** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Razorpay dapat diperoleh melalui [dashboard.razorpay.com/app/keys](https://dashboard.razorpay.com/app/keys):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=razorpay
|
|
14
|
-
RAZORPAY_KEY_ID=rzp_test_...
|
|
15
|
-
RAZORPAY_KEY_SECRET=...
|
|
16
|
-
RAZORPAY_WEBHOOK_SECRET=...
|
|
17
|
-
RAZORPAY_SANDBOX=true
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Atau inisialisasi manual:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
-
|
|
25
|
-
const buayarRzp = new Buayar({
|
|
26
|
-
provider: "razorpay",
|
|
27
|
-
clientKey: "rzp_test_...", // Key ID
|
|
28
|
-
apiKey: "...", // Key Secret
|
|
29
|
-
extra: {
|
|
30
|
-
webhookSecret: "...",
|
|
31
|
-
},
|
|
32
|
-
sandbox: true,
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## 🛠️ Membuat Transaksi
|
|
39
|
-
|
|
40
|
-
### 1. Semi Integrasi (Razorpay Standard Hosted Payment Links)
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { buayar } from "@crediblemark/buayar";
|
|
44
|
-
|
|
45
|
-
const invoice = await buayar.createInvoice({
|
|
46
|
-
orderId: "ORDER-RZP-001",
|
|
47
|
-
amount: 50000, // minor units (500.00 INR)
|
|
48
|
-
currency: "INR",
|
|
49
|
-
productDetails: "Online Course Access",
|
|
50
|
-
customer: {
|
|
51
|
-
name: "Aarav Sharma",
|
|
52
|
-
email: "aarav@example.com",
|
|
53
|
-
phone: "+919876543210",
|
|
54
|
-
},
|
|
55
|
-
returnUrl: "https://myapp.com/payment/callback",
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (invoice.success) {
|
|
59
|
-
console.log("Short Payment Link URL:", invoice.paymentUrl);
|
|
60
|
-
console.log("Razorpay Link ID:", invoice.reference);
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 2. Full Integrasi (Razorpay Orders API untuk Checkout.js)
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
const order = await buayar.createInvoice({
|
|
68
|
-
orderId: "ORDER-RZP-002",
|
|
69
|
-
amount: 75000,
|
|
70
|
-
currency: "INR",
|
|
71
|
-
paymentMethod: "upi", // atau "credit_card"
|
|
72
|
-
productDetails: "Course Upgrade",
|
|
73
|
-
customer: { name: "Aarav", email: "aarav@example.com" },
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
console.log("Razorpay Order ID:", order.reference);
|
|
77
|
-
```
|
package/docs/square.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Square (`square`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Square (Payment Links API)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Square dapat diperoleh melalui [developer.squareup.com/apps](https://developer.squareup.com/apps):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=square
|
|
14
|
-
SQUARE_ACCESS_TOKEN=EAAA...
|
|
15
|
-
SQUARE_APPLICATION_ID=sq0idp-...
|
|
16
|
-
SQUARE_LOCATION_ID=L...
|
|
17
|
-
SQUARE_WEBHOOK_SIGNATURE_KEY=...
|
|
18
|
-
SQUARE_SANDBOX=true
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Atau inisialisasi manual:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
25
|
-
|
|
26
|
-
const buayarSquare = new Buayar({
|
|
27
|
-
provider: "square",
|
|
28
|
-
apiKey: "EAAA...", // Access Token
|
|
29
|
-
clientKey: "sq0idp-...", // Application ID
|
|
30
|
-
projectId: "L...", // Location ID
|
|
31
|
-
extra: {
|
|
32
|
-
webhookSignatureKey: "...",
|
|
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-SQ-001",
|
|
47
|
-
amount: 3500, // minor units ($35.00)
|
|
48
|
-
currency: "USD",
|
|
49
|
-
productDetails: "Merchandise Coffee Mug",
|
|
50
|
-
customer: {
|
|
51
|
-
name: "Michael Scott",
|
|
52
|
-
email: "michael@example.com",
|
|
53
|
-
},
|
|
54
|
-
returnUrl: "https://myapp.com/payment/complete",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (invoice.success) {
|
|
58
|
-
console.log("Square Checkout URL:", invoice.paymentUrl);
|
|
59
|
-
console.log("Payment Link ID:", invoice.reference);
|
|
60
|
-
}
|
|
61
|
-
```
|
package/docs/stripe.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Stripe (`stripe`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Stripe** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Stripe dapat diperoleh melalui [dashboard.stripe.com/apikeys](https://dashboard.stripe.com/apikeys):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=stripe
|
|
14
|
-
STRIPE_SECRET_KEY=sk_test_51...
|
|
15
|
-
STRIPE_PUBLIC_KEY=pk_test_51...
|
|
16
|
-
STRIPE_WEBHOOK_SECRET=whsec_...
|
|
17
|
-
STRIPE_SANDBOX=true
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Atau inisialisasi manual:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
-
|
|
25
|
-
const buayarStripe = new Buayar({
|
|
26
|
-
provider: "stripe",
|
|
27
|
-
apiKey: "sk_test_51...", // Secret Key
|
|
28
|
-
clientKey: "pk_test_51...", // Publishable Key
|
|
29
|
-
extra: {
|
|
30
|
-
webhookSecret: "whsec_...",
|
|
31
|
-
},
|
|
32
|
-
sandbox: true,
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## 🛠️ Membuat Transaksi
|
|
39
|
-
|
|
40
|
-
### 1. Semi Integrasi (Stripe Checkout Session)
|
|
41
|
-
Kosongkan parameter `paymentMethod`:
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { buayar } from "@crediblemark/buayar";
|
|
45
|
-
|
|
46
|
-
const invoice = await buayar.createInvoice({
|
|
47
|
-
orderId: "ORDER-STRIPE-001",
|
|
48
|
-
amount: 250000,
|
|
49
|
-
currency: "IDR", // Default 'IDR', atau 'USD', 'SGD', dll
|
|
50
|
-
productDetails: "Pro Subscription",
|
|
51
|
-
customer: {
|
|
52
|
-
name: "John Doe",
|
|
53
|
-
email: "john@example.com",
|
|
54
|
-
},
|
|
55
|
-
returnUrl: "https://myapp.com/payment/success",
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (invoice.success) {
|
|
59
|
-
// Arahkan user ke URL Checkout Stripe
|
|
60
|
-
console.log("Checkout URL:", invoice.paymentUrl);
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 2. Full Integrasi (Stripe Payment Intent)
|
|
65
|
-
Berikan parameter `paymentMethod` (misal: `credit_card`):
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
const direct = await buayar.createInvoice({
|
|
69
|
-
orderId: "ORDER-STRIPE-002",
|
|
70
|
-
amount: 150000,
|
|
71
|
-
paymentMethod: "credit_card",
|
|
72
|
-
productDetails: "Top Up Wallet",
|
|
73
|
-
customer: { name: "John Doe", email: "john@example.com" },
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
console.log("Client Secret / Reference:", direct.reference);
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## 🔔 Verifikasi Webhook
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import { buayar } from "@crediblemark/buayar";
|
|
85
|
-
|
|
86
|
-
// Endpoint: POST /api/payment/webhook
|
|
87
|
-
app.post("/api/payment/webhook", async (req, res) => {
|
|
88
|
-
const payload = req.body;
|
|
89
|
-
const headers = req.headers;
|
|
90
|
-
|
|
91
|
-
const result = await buayar.verifyWebhook(payload, headers);
|
|
92
|
-
|
|
93
|
-
if (!result.isValid) {
|
|
94
|
-
return res.status(400).send("Invalid signature");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (result.isPaid) {
|
|
98
|
-
console.log(`Pesanan ${result.orderId} terbayar sejumlah ${result.amount}!`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return res.json({ received: true });
|
|
102
|
-
});
|
|
103
|
-
```
|
package/docs/twocheckout.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi 2Checkout / Verifone (`twocheckout`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **2Checkout / Verifone (Orders API v6)** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial 2Checkout dapat diperoleh melalui [secure.2checkout.com/cpanel](https://secure.2checkout.com/cpanel):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=twocheckout
|
|
14
|
-
TWOCHECKOUT_MERCHANT_CODE=...
|
|
15
|
-
TWOCHECKOUT_SECRET_KEY=...
|
|
16
|
-
TWOCHECKOUT_SECRET_WORD=...
|
|
17
|
-
TWOCHECKOUT_SANDBOX=true
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Atau inisialisasi manual:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
24
|
-
|
|
25
|
-
const buayar2Co = new Buayar({
|
|
26
|
-
provider: "twocheckout",
|
|
27
|
-
merchantCode: "...", // Merchant Code
|
|
28
|
-
apiKey: "...", // Secret Key
|
|
29
|
-
extra: {
|
|
30
|
-
secretWord: "...",
|
|
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-2CO-001",
|
|
45
|
-
amount: 4900, // minor units ($49.00)
|
|
46
|
-
currency: "USD",
|
|
47
|
-
productDetails: "SaaS Monthly License",
|
|
48
|
-
customer: {
|
|
49
|
-
name: "Tony Stark",
|
|
50
|
-
email: "tony@example.com",
|
|
51
|
-
},
|
|
52
|
-
returnUrl: "https://myapp.com/payment/complete",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (invoice.success) {
|
|
56
|
-
console.log("Hosted Checkout Link:", invoice.paymentUrl);
|
|
57
|
-
console.log("2Checkout Reference:", invoice.reference);
|
|
58
|
-
}
|
|
59
|
-
```
|
package/docs/xendit.md
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
# 💳 Integrasi Xendit (`xendit`)
|
|
2
|
-
|
|
3
|
-
Panduan lengkap integrasi Payment Gateway **Xendit** dengan `@crediblemark/buayar`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## ⚙️ Konfigurasi Kredensial
|
|
8
|
-
|
|
9
|
-
Kredensial Xendit berupa **Secret API Key** yang dapat diambil melalui menu **Settings > API Keys** pada dashboard [dashboard.xendit.co](https://dashboard.xendit.co):
|
|
10
|
-
|
|
11
|
-
```env
|
|
12
|
-
# Menggunakan .env (Direkomendasikan)
|
|
13
|
-
PROVIDER_PG=xendit
|
|
14
|
-
XENDIT_SECRET_KEY=xnd_development_xxxxxxxxxxxxxxxxxxxxxxxx
|
|
15
|
-
XENDIT_WEBHOOK_TOKEN=your_webhook_verification_token
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Atau inisialisasi manual:
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
import { Buayar } from "@crediblemark/buayar";
|
|
22
|
-
|
|
23
|
-
const buayarXendit = new Buayar({
|
|
24
|
-
provider: "xendit",
|
|
25
|
-
apiKey: "xnd_development_xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## 🛠️ Membuat Transaksi
|
|
32
|
-
|
|
33
|
-
### 1. Semi Integrasi (Invoice Checkout / Redirect)
|
|
34
|
-
Kosongkan parameter `paymentMethod`:
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { buayar } from "@crediblemark/buayar";
|
|
38
|
-
|
|
39
|
-
const invoice = await buayar.createInvoice({
|
|
40
|
-
orderId: "ORDER-XND-001",
|
|
41
|
-
amount: 250000,
|
|
42
|
-
productDetails: "Langganan Premium Pro 1 Bulan",
|
|
43
|
-
customer: {
|
|
44
|
-
name: "Budi Santoso",
|
|
45
|
-
email: "budi@example.com",
|
|
46
|
-
phone: "081234567890",
|
|
47
|
-
},
|
|
48
|
-
returnUrl: "https://myapp.com/payment/finish",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (invoice.success) {
|
|
52
|
-
// Arahkan user ke halaman checkout Xendit
|
|
53
|
-
console.log("Invoice URL:", invoice.paymentUrl);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 2. Full Integrasi (Direct VA / QRIS / E-Wallet / Retail)
|
|
58
|
-
Berikan parameter `paymentMethod` (misal: `bca_va`, `mandiri_va`, `bri_va`, `qris`, `gopay`, `shopeepay`, `alfamart`):
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
// Direct Virtual Account (Payment Requests API v3)
|
|
62
|
-
const va = await buayar.createInvoice({
|
|
63
|
-
orderId: "ORDER-XND-002",
|
|
64
|
-
amount: 150000,
|
|
65
|
-
paymentMethod: "bca_va",
|
|
66
|
-
productDetails: "Top Up Wallet",
|
|
67
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
console.log("Nomor VA BCA:", va.vaNumber);
|
|
71
|
-
console.log("Expired At:", va.expiresAt);
|
|
72
|
-
|
|
73
|
-
// Direct QRIS
|
|
74
|
-
const qris = await buayar.createInvoice({
|
|
75
|
-
orderId: "ORDER-XND-003",
|
|
76
|
-
amount: 50000,
|
|
77
|
-
paymentMethod: "qris",
|
|
78
|
-
productDetails: "Menu Makan Siang",
|
|
79
|
-
customer: { name: "Budi", email: "budi@example.com" },
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
console.log("Raw QRIS (EMVCo):", qris.qrString);
|
|
83
|
-
console.log("QR Image:", qris.qrCodeUrl);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## 🏦 Ekstensi `XenditClient` (Cek Saldo, Expire Invoice, Payout)
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { buayar } from "@crediblemark/buayar";
|
|
92
|
-
|
|
93
|
-
const xenditClient = buayar.getXenditClient();
|
|
94
|
-
|
|
95
|
-
// 1. Cek Saldo Merchant
|
|
96
|
-
const balance = await xenditClient.checkBalance("CASH");
|
|
97
|
-
console.log("Saldo Merchant:", balance.balance);
|
|
98
|
-
|
|
99
|
-
// 2. Memaksa Invoice Expired
|
|
100
|
-
await xenditClient.expireInvoice("inv_67890");
|
|
101
|
-
|
|
102
|
-
// 3. Eksekusi Transfer Dana / Payout (Disbursement)
|
|
103
|
-
const disbursement = await xenditClient.createDisbursement({
|
|
104
|
-
externalId: "DISB-001",
|
|
105
|
-
bankCode: "BCA",
|
|
106
|
-
accountHolderName: "BUDI SANTOSO",
|
|
107
|
-
accountNumber: "1234567890",
|
|
108
|
-
description: "Penarikan Dana Affiliate",
|
|
109
|
-
amount: 500000,
|
|
110
|
-
});
|
|
111
|
-
console.log("Status Transfer:", disbursement);
|
|
112
|
-
```
|