@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/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
- ```
@@ -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
- ```