@vulog/aima-billing 1.1.96 → 1.1.97

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/index.d.mts CHANGED
@@ -128,7 +128,7 @@ declare const getRefundableAmount: (client: Client, invoiceId: string) => Promis
128
128
  interface Payload {
129
129
  invoiceId: string;
130
130
  amount?: number;
131
- notes?: string | null;
131
+ note?: string | null;
132
132
  paymentIntentPspReference?: string;
133
133
  }
134
134
  declare const refund: (client: Client, payload: Payload) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ declare const getRefundableAmount: (client: Client, invoiceId: string) => Promis
128
128
  interface Payload {
129
129
  invoiceId: string;
130
130
  amount?: number;
131
- notes?: string | null;
131
+ note?: string | null;
132
132
  paymentIntentPspReference?: string;
133
133
  }
134
134
  declare const refund: (client: Client, payload: Payload) => Promise<void>;
package/dist/index.js CHANGED
@@ -129,7 +129,7 @@ var getRefundableAmount = async (client, invoiceId) => {
129
129
  var import_zod6 = __toESM(require("zod"));
130
130
  var schema4 = import_zod6.default.object({
131
131
  amount: import_zod6.default.number().min(0).optional(),
132
- notes: import_zod6.default.string().trim().nullable().optional(),
132
+ note: import_zod6.default.string().trim().nullable().optional(),
133
133
  paymentIntentPspReference: import_zod6.default.string().trim().min(1).optional()
134
134
  });
135
135
  var refund = async (client, payload) => {
package/dist/index.mjs CHANGED
@@ -88,7 +88,7 @@ var getRefundableAmount = async (client, invoiceId) => {
88
88
  import z6 from "zod";
89
89
  var schema4 = z6.object({
90
90
  amount: z6.number().min(0).optional(),
91
- notes: z6.string().trim().nullable().optional(),
91
+ note: z6.string().trim().nullable().optional(),
92
92
  paymentIntentPspReference: z6.string().trim().min(1).optional()
93
93
  });
94
94
  var refund = async (client, payload) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-billing",
3
- "version": "1.1.96",
3
+ "version": "1.1.97",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "author": "Vulog",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.96",
23
- "@vulog/aima-core": "1.1.96"
22
+ "@vulog/aima-client": "1.1.97",
23
+ "@vulog/aima-core": "1.1.97"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.25.76"
@@ -0,0 +1,49 @@
1
+ import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import { refund } from './refund';
3
+ import { Client } from '@vulog/aima-client';
4
+
5
+ describe('refund', () => {
6
+ const postMock = vi.fn();
7
+ const client = {
8
+ post: postMock,
9
+ clientOptions: {
10
+ fleetId: 'FLEET_ID',
11
+ },
12
+ } as unknown as Client;
13
+
14
+ beforeEach(() => {
15
+ vi.clearAllMocks();
16
+ });
17
+
18
+ test('should return invalid args', async () => {
19
+ const payload = {
20
+ invoiceId: 'INVOICE_ID',
21
+ amount: -10, // Invalid amount
22
+ };
23
+
24
+ // expect to throw error if invalid args are provided
25
+ await expect(refund(client, payload)).rejects.toThrow('Invalid args');
26
+ });
27
+
28
+ test('should process refund successfully', async () => {
29
+ const payload = {
30
+ invoiceId: 'INVOICE_ID',
31
+ amount: 50,
32
+ notes: 'Customer requested refund',
33
+ };
34
+
35
+ postMock.mockResolvedValueOnce({
36
+ data: undefined,
37
+ });
38
+
39
+ const result = await refund(client, payload);
40
+ expect(result).toBeUndefined();
41
+ expect(postMock).toHaveBeenCalledWith(
42
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${payload.invoiceId}/refund`,
43
+ {
44
+ amount: 50,
45
+ note: 'Customer requested refund',
46
+ }
47
+ );
48
+ });
49
+ });
package/src/refund.ts CHANGED
@@ -5,13 +5,13 @@ import z from 'zod';
5
5
  interface Payload {
6
6
  invoiceId: string;
7
7
  amount?: number;
8
- notes?: string | null;
8
+ note?: string | null;
9
9
  paymentIntentPspReference?: string;
10
10
  }
11
11
 
12
12
  const schema = z.object({
13
13
  amount: z.number().min(0).optional(),
14
- notes: z.string().trim().nullable().optional(),
14
+ note: z.string().trim().nullable().optional(),
15
15
  paymentIntentPspReference: z.string().trim().min(1).optional(),
16
16
  });
17
17