@afriex/sdk 1.3.0 → 2.0.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/README.md CHANGED
@@ -13,55 +13,62 @@ pnpm add @afriex/sdk
13
13
  ## Quick Start
14
14
 
15
15
  ```typescript
16
- import { AfriexSDK } from '@afriex/sdk';
16
+ import { AfriexSDK } from "@afriex/sdk";
17
17
  // or use the alias
18
- import { Afriex } from '@afriex/sdk';
18
+ import { Afriex } from "@afriex/sdk";
19
19
 
20
20
  const afriex = new AfriexSDK({
21
- apiKey: 'your-api-key',
22
- environment: 'production', // or 'staging' (default: 'production')
23
- webhookPublicKey: '-----BEGIN PUBLIC KEY-----...' // optional
21
+ apiKey: "your-api-key",
22
+ environment: "production", // or 'staging' (default: 'production')
23
+ webhookPublicKey: "-----BEGIN PUBLIC KEY-----...", // optional
24
24
  });
25
25
 
26
26
  // Customers
27
27
  const customer = await afriex.customers.create({
28
- fullName: 'John Doe',
29
- email: 'john@example.com',
30
- phone: '+1234567890',
31
- countryCode: 'US'
28
+ fullName: "John Doe",
29
+ email: "john@example.com",
30
+ phone: "+1234567890",
31
+ countryCode: "US",
32
32
  });
33
33
 
34
34
  // Payment Methods
35
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
- }
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
45
  });
46
46
 
47
47
  // Transactions
48
48
  const transaction = await afriex.transactions.create({
49
- customerId: customer.customerId,
50
- destinationAmount: 50000,
51
- sourceCurrency: 'USD',
52
- destinationCurrency: 'NGN',
53
- destinationId: paymentMethod.paymentMethodId
49
+ customerId: customer.customerId,
50
+ sourceAmount: "100",
51
+ destinationAmount: "50000",
52
+ sourceCurrency: "USD",
53
+ destinationCurrency: "NGN",
54
+ destinationId: paymentMethod.paymentMethodId,
55
+ meta: {
56
+ idempotencyKey: "quick-start-transaction-1",
57
+ reference: "order-123",
58
+ },
54
59
  });
55
60
 
56
61
  // Rates
57
- const rate = await afriex.rates.getRate('USD', 'NGN');
62
+ const rate = await afriex.rates.getRate("USD", "NGN");
58
63
 
59
64
  // Balance
60
- const balances = await afriex.balance.getBalance({ currencies: ['USD', 'NGN'] });
65
+ const balances = await afriex.balance.getBalance({
66
+ currencies: ["USD", "NGN"],
67
+ });
61
68
 
62
69
  // Webhook Verification (only if webhookPublicKey provided)
63
70
  if (afriex.webhooks) {
64
- const isValid = afriex.webhooks.verify(payload, signature);
71
+ const isValid = afriex.webhooks.verify(payload, signature);
65
72
  }
66
73
  ```
67
74
 
@@ -80,9 +87,9 @@ if (afriex.webhooks) {
80
87
 
81
88
  ```typescript
82
89
  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
90
+ apiKey: string; // Required - Your Afriex API key
91
+ environment?: "staging" | "production"; // Default: 'production'
92
+ webhookPublicKey?: string; // Optional - Afriex's public key for webhooks
86
93
  }
87
94
  ```
88
95
 
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { PaymentMethodService } from "@afriex/payment-methods";
5
5
  import { BalanceService } from "@afriex/balance";
6
6
  import { RateService } from "@afriex/rates";
7
7
  import { CheckoutService } from "@afriex/checkout";
8
- import { WebhookVerifier, WebhookService } from "@afriex/webhooks";
8
+ import { WebhookService } from "@afriex/webhooks";
9
9
  export interface AfriexSDKConfig extends AfriexConfig {
10
10
  webhookPublicKey?: string;
11
11
  }
@@ -16,8 +16,8 @@ export declare class AfriexSDK extends AfriexClient {
16
16
  readonly balance: BalanceService;
17
17
  readonly rates: RateService;
18
18
  readonly checkout: CheckoutService;
19
- readonly webhookVerifier?: WebhookVerifier;
20
19
  readonly webhooks: WebhookService;
20
+ readonly webhookVerifier?: WebhookService;
21
21
  constructor(config: AfriexSDKConfig);
22
22
  }
23
23
  export { AfriexSDK as Afriex };
@@ -30,11 +30,11 @@ export { RateService } from "@afriex/rates";
30
30
  export { CheckoutService } from "@afriex/checkout";
31
31
  export { WebhookVerifier, WebhookService } from "@afriex/webhooks";
32
32
  export type { Customer, CreateCustomerRequest, UpdateCustomerKycRequest, ListCustomersParams, CustomerListResponse, } from "@afriex/customers";
33
- export type { Transaction, CreateTransactionRequest, ListTransactionsParams, TransactionListResponse, TransactionType, TransactionStatus, TransactionMeta, } from "@afriex/transactions";
34
- export type { PaymentMethod, CreatePaymentMethodRequest, ListPaymentMethodsParams, PaymentMethodListResponse, PaymentChannel, Institution, ResolveAccountParams, ResolveAccountResponse, GetInstitutionsParams, CryptoWalletResponse, GetCryptoWalletParams, ListVirtualAccountsParams, CreateVirtualAccountParams, ListPoolAccountsParams, VirtualAccountListResponse, } from "@afriex/payment-methods";
33
+ export type { Transaction, CreateTransactionRequest, ListTransactionsParams, TransactionListResponse, TransactionListType, TransactionChannel, TransactionType, TransactionStatus, TransactionMeta, } from "@afriex/transactions";
34
+ export type { PaymentMethod, CreatePaymentMethodRequest, ListPaymentMethodsParams, PaymentMethodListResponse, PaymentChannel, Institution, ResolveAccountParams, ResolveAccountResponse, GetInstitutionsParams, CryptoWalletResponse, GetCryptoWalletParams, ListVirtualAccountsParams, CreateVirtualAccountParams, ListPoolAccountsParams, VirtualAccountListResponse, PoolAccountResponse, } from "@afriex/payment-methods";
35
35
  export type { BalanceResponse, GetBalanceParams } from "@afriex/balance";
36
36
  export type { RatesResponse, GetRatesParams } from "@afriex/rates";
37
- export type { CheckoutSession, CreateCheckoutSessionRequest, CheckoutCustomer, CheckoutTransaction, } from "@afriex/checkout";
38
- export type { WebhookPayload, CustomerWebhookPayload, CustomerEventType, CustomerWebhookData, PaymentMethodWebhookPayload, PaymentMethodEventType, PaymentMethodWebhookData, TransactionWebhookPayload, TransactionEventType, TransactionWebhookData, TransactionWebhookStatus, TriggerWebhookRequest, WebhookEventType, } from "@afriex/webhooks";
37
+ export type { CheckoutSession, CreateCheckoutSessionRequest, CheckoutCustomer, CheckoutChannel, } from "@afriex/checkout";
38
+ export type { WebhookPayload, CustomerWebhookPayload, CustomerEventType, CustomerWebhookData, PaymentMethodWebhookPayload, PaymentMethodEventType, PaymentMethodWebhookData, TransactionWebhookPayload, TransactionEventType, TransactionWebhookData, TransactionWebhookStatus, CheckoutSessionWebhookPayload, CheckoutSessionEventType, CheckoutSessionWebhookData, TriggerWebhookRequest, WebhookEventType, } from "@afriex/webhooks";
39
39
  export { WEBHOOK_SIGNATURE_HEADER } from "@afriex/webhooks";
40
40
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { PaymentMethodService } from "@afriex/payment-methods";
5
5
  import { BalanceService } from "@afriex/balance";
6
6
  import { RateService } from "@afriex/rates";
7
7
  import { CheckoutService } from "@afriex/checkout";
8
- import { WebhookVerifier, WebhookService } from "@afriex/webhooks";
8
+ import { WebhookService } from "@afriex/webhooks";
9
9
  export class AfriexSDK extends AfriexClient {
10
10
  constructor(config) {
11
11
  super(config);
@@ -16,9 +16,9 @@ export class AfriexSDK extends AfriexClient {
16
16
  this.balance = new BalanceService(httpClient);
17
17
  this.rates = new RateService(httpClient);
18
18
  this.checkout = new CheckoutService(httpClient);
19
- this.webhooks = new WebhookService(httpClient);
19
+ this.webhooks = new WebhookService(httpClient, config.webhookPublicKey);
20
20
  if (config.webhookPublicKey) {
21
- this.webhookVerifier = new WebhookVerifier(config.webhookPublicKey);
21
+ this.webhookVerifier = this.webhooks;
22
22
  }
23
23
  }
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afriex/sdk",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
4
4
  "description": "Official TypeScript SDK for the Afriex Business API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://afriex-sdk-docs.vercel.app",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/codewithveek/afriex_sdk.git",
11
+ "url": "https://github.com/Afri-exchange/afriex-sdk",
12
12
  "directory": "packages/sdk"
13
13
  },
14
14
  "author": "Victory Lucky <luckyvictory54@gmail.com>",
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@afriex/core": "1.3.0",
24
- "@afriex/customers": "1.3.0",
25
- "@afriex/transactions": "1.3.0",
26
- "@afriex/payment-methods": "1.3.0",
24
+ "@afriex/customers": "1.4.0",
25
+ "@afriex/transactions": "1.4.0",
26
+ "@afriex/payment-methods": "2.0.0",
27
27
  "@afriex/balance": "1.3.0",
28
- "@afriex/rates": "1.3.0",
29
- "@afriex/checkout": "1.0.0",
30
- "@afriex/webhooks": "1.3.0"
28
+ "@afriex/rates": "1.4.0",
29
+ "@afriex/checkout": "2.0.0",
30
+ "@afriex/webhooks": "1.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "rimraf": "^5.0.5",