@afriex/sdk 1.0.0 → 1.0.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/README.md +109 -0
- package/package.json +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# @afriex/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the Afriex Business API. A unified interface for all Afriex services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @afriex/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @afriex/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { AfriexSDK } from '@afriex/sdk';
|
|
17
|
+
// or use the alias
|
|
18
|
+
import { Afriex } from '@afriex/sdk';
|
|
19
|
+
|
|
20
|
+
const afriex = new AfriexSDK({
|
|
21
|
+
apiKey: 'your-api-key',
|
|
22
|
+
environment: 'production', // or 'staging' (default: 'production')
|
|
23
|
+
webhookPublicKey: '-----BEGIN PUBLIC KEY-----...' // optional
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Customers
|
|
27
|
+
const customer = await afriex.customers.create({
|
|
28
|
+
fullName: 'John Doe',
|
|
29
|
+
email: 'john@example.com',
|
|
30
|
+
phone: '+1234567890',
|
|
31
|
+
countryCode: 'US'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Payment Methods
|
|
35
|
+
const paymentMethod = await afriex.paymentMethods.create({
|
|
36
|
+
customerId: customer.customerId,
|
|
37
|
+
channel: 'BANK_ACCOUNT',
|
|
38
|
+
accountName: 'John Doe',
|
|
39
|
+
accountNumber: '1234567890',
|
|
40
|
+
countryCode: 'NG',
|
|
41
|
+
institution: {
|
|
42
|
+
institutionCode: '058',
|
|
43
|
+
institutionName: 'GTBank'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Transactions
|
|
48
|
+
const transaction = await afriex.transactions.create({
|
|
49
|
+
customerId: customer.customerId,
|
|
50
|
+
destinationAmount: 50000,
|
|
51
|
+
sourceCurrency: 'USD',
|
|
52
|
+
destinationCurrency: 'NGN',
|
|
53
|
+
destinationId: paymentMethod.paymentMethodId
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Rates
|
|
57
|
+
const rate = await afriex.rates.getRate('USD', 'NGN');
|
|
58
|
+
|
|
59
|
+
// Balance
|
|
60
|
+
const balances = await afriex.balance.getBalance({ currencies: ['USD', 'NGN'] });
|
|
61
|
+
|
|
62
|
+
// Webhook Verification (only if webhookPublicKey provided)
|
|
63
|
+
if (afriex.webhooks) {
|
|
64
|
+
const isValid = afriex.webhooks.verify(payload, signature);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Available Services
|
|
69
|
+
|
|
70
|
+
| Service | Description |
|
|
71
|
+
| ----------------------- | -------------------------------------------- |
|
|
72
|
+
| `afriex.customers` | Customer CRUD and KYC management |
|
|
73
|
+
| `afriex.transactions` | Create and track transactions |
|
|
74
|
+
| `afriex.paymentMethods` | Bank, mobile money, crypto, virtual accounts |
|
|
75
|
+
| `afriex.balance` | Organization wallet balances |
|
|
76
|
+
| `afriex.rates` | Exchange rates and conversions |
|
|
77
|
+
| `afriex.webhooks` | Webhook signature verification (optional) |
|
|
78
|
+
|
|
79
|
+
## Configuration
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
interface AfriexSDKConfig {
|
|
83
|
+
apiKey: string; // Required - Your Afriex API key
|
|
84
|
+
environment?: 'staging' | 'production'; // Default: 'production'
|
|
85
|
+
webhookPublicKey?: string; // Optional - Afriex's public key for webhooks
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Individual Packages
|
|
90
|
+
|
|
91
|
+
For smaller bundle sizes, install packages individually:
|
|
92
|
+
|
|
93
|
+
| Package | Description |
|
|
94
|
+
| ------------------------- | ----------------------------- |
|
|
95
|
+
| `@afriex/core` | Base client and configuration |
|
|
96
|
+
| `@afriex/customers` | Customer management |
|
|
97
|
+
| `@afriex/transactions` | Transaction handling |
|
|
98
|
+
| `@afriex/payment-methods` | Payment methods |
|
|
99
|
+
| `@afriex/balance` | Balance queries |
|
|
100
|
+
| `@afriex/rates` | Exchange rates |
|
|
101
|
+
| `@afriex/webhooks` | Webhook verification |
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
104
|
+
|
|
105
|
+
Full documentation available at [afriex-sdk-docs.vercel.app](https://afriex-sdk-docs.vercel.app)
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@afriex/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Official TypeScript SDK for the Afriex Business API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@afriex/customers": "1.0.
|
|
22
|
-
"@afriex/transactions": "1.0.
|
|
23
|
-
"@afriex/core": "1.0.
|
|
24
|
-
"@afriex/
|
|
25
|
-
"@afriex/
|
|
26
|
-
"@afriex/
|
|
27
|
-
"@afriex/webhooks": "1.0.
|
|
21
|
+
"@afriex/customers": "1.0.1",
|
|
22
|
+
"@afriex/transactions": "1.0.1",
|
|
23
|
+
"@afriex/core": "1.0.1",
|
|
24
|
+
"@afriex/balance": "1.0.1",
|
|
25
|
+
"@afriex/rates": "1.0.1",
|
|
26
|
+
"@afriex/payment-methods": "1.0.1",
|
|
27
|
+
"@afriex/webhooks": "1.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"rimraf": "^5.0.5",
|