@blazium/sdk 1.0.1 → 1.0.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/README.md +37 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,36 +16,49 @@ Official Node.js SDK for BlaziumPay - Production-ready crypto payment infrastruc
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install @blazium/sdk
|
|
19
|
+
npm install @blazium/sdk dotenv
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Configuration
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
import { BlaziumPayClient } from '@blazium/sdk';
|
|
24
|
+
Create a `.env` file in your project root:
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
26
|
+
```env
|
|
27
|
+
BLAZIUM_API_KEY=bz_test_...
|
|
28
|
+
BLAZIUM_WEBHOOK_SECRET=whsec_...
|
|
29
|
+
```
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import 'dotenv/config'; // Load environment variables
|
|
35
|
+
import { BlaziumPayClient, BlaziumEnvironment, BlaziumFiat } from '@blazium/sdk';
|
|
36
|
+
|
|
37
|
+
// Wrap in async function to allow await
|
|
38
|
+
(async () => {
|
|
39
|
+
const client = new BlaziumPayClient({
|
|
40
|
+
apiKey: process.env.BLAZIUM_API_KEY as string,
|
|
41
|
+
webhookSecret: process.env.BLAZIUM_WEBHOOK_SECRET,
|
|
42
|
+
environment: BlaziumEnvironment.PRODUCTION
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Create payment with locked reward
|
|
46
|
+
const payment = await client.createPayment(
|
|
47
|
+
{
|
|
48
|
+
amount: 10.00,
|
|
49
|
+
currency: BlaziumFiat.USD,
|
|
50
|
+
description: 'Premium Pack',
|
|
51
|
+
rewardAmount: 400,
|
|
52
|
+
rewardCurrency: 'coins'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
idempotencyKey: 'order_12345'
|
|
56
|
+
}
|
|
57
|
+
);
|
|
46
58
|
|
|
47
|
-
console.log('Checkout URL:', payment.checkoutUrl);
|
|
48
|
-
console.log('Reward (LOCKED):', payment.rewardAmount); // Always 400
|
|
59
|
+
console.log('Checkout URL:', payment.checkoutUrl);
|
|
60
|
+
console.log('Reward (LOCKED):', payment.rewardAmount); // Always 400
|
|
61
|
+
})();
|
|
49
62
|
```
|
|
50
63
|
|
|
51
64
|
## Core Concepts
|
package/package.json
CHANGED