@vulog/aima-billing 1.1.93 → 1.1.96

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
@@ -72,15 +72,65 @@ type Credit = {
72
72
  usage: 'TRIP' | 'REGISTRATION' | 'PRODUCTS' | 'ALL';
73
73
  [key: string]: any;
74
74
  };
75
+ type Receipt = {
76
+ id: string;
77
+ pspName: string;
78
+ pspReference: string;
79
+ pspPublishableKey: string;
80
+ amount: number;
81
+ currency: string;
82
+ date: string;
83
+ status: string;
84
+ paymentMethodType: string;
85
+ paymentMethodPspReference: string;
86
+ paymentIntentPspReference: string;
87
+ number: number;
88
+ code: string;
89
+ declineCode: string;
90
+ pspClientSecret: string;
91
+ reason: string;
92
+ note: string;
93
+ nextAction: {
94
+ nextActionRedirectUrl: {
95
+ url: string;
96
+ method: string;
97
+ data: {
98
+ [key: string]: unknown;
99
+ };
100
+ };
101
+ type: string;
102
+ };
103
+ metadatas: {
104
+ [key: string]: unknown;
105
+ };
106
+ };
107
+ type RefundableAmount = {
108
+ invoiceId: string;
109
+ fleetId: string;
110
+ refundableAmount: number;
111
+ currency: string;
112
+ refundablePaymentReceipts: Receipt[];
113
+ refundedPaymentReceipts: Receipt[];
114
+ };
75
115
 
76
116
  declare const chargeProduct: (client: Client, info: ChargeProductInfo) => Promise<Invoice>;
77
117
 
78
118
  declare const getUserCreditsByEntityId: (client: Client, id: string) => Promise<Credit>;
79
119
 
80
- interface Payload extends Omit<Credit, 'id' | 'availableAmount' | 'usedAmount' | 'originId' | 'creditAlreadyUsed' | 'updateDate'> {
120
+ interface Payload$1 extends Omit<Credit, 'id' | 'availableAmount' | 'usedAmount' | 'originId' | 'creditAlreadyUsed' | 'updateDate'> {
81
121
  }
82
- declare const addCredits: (client: Client, payload: Payload) => Promise<Credit>;
122
+ declare const addCredits: (client: Client, payload: Payload$1) => Promise<Credit>;
83
123
 
84
124
  declare const getInvoiceById: (client: Client, id: string) => Promise<Invoice>;
85
125
 
86
- export { type ChargeProductInfo, type Credit, type Invoice, addCredits, chargeProduct, getInvoiceById, getUserCreditsByEntityId };
126
+ declare const getRefundableAmount: (client: Client, invoiceId: string) => Promise<RefundableAmount>;
127
+
128
+ interface Payload {
129
+ invoiceId: string;
130
+ amount?: number;
131
+ notes?: string | null;
132
+ paymentIntentPspReference?: string;
133
+ }
134
+ declare const refund: (client: Client, payload: Payload) => Promise<void>;
135
+
136
+ export { type ChargeProductInfo, type Credit, type Invoice, type Receipt, type RefundableAmount, addCredits, chargeProduct, getInvoiceById, getRefundableAmount, getUserCreditsByEntityId, refund };
package/dist/index.d.ts CHANGED
@@ -72,15 +72,65 @@ type Credit = {
72
72
  usage: 'TRIP' | 'REGISTRATION' | 'PRODUCTS' | 'ALL';
73
73
  [key: string]: any;
74
74
  };
75
+ type Receipt = {
76
+ id: string;
77
+ pspName: string;
78
+ pspReference: string;
79
+ pspPublishableKey: string;
80
+ amount: number;
81
+ currency: string;
82
+ date: string;
83
+ status: string;
84
+ paymentMethodType: string;
85
+ paymentMethodPspReference: string;
86
+ paymentIntentPspReference: string;
87
+ number: number;
88
+ code: string;
89
+ declineCode: string;
90
+ pspClientSecret: string;
91
+ reason: string;
92
+ note: string;
93
+ nextAction: {
94
+ nextActionRedirectUrl: {
95
+ url: string;
96
+ method: string;
97
+ data: {
98
+ [key: string]: unknown;
99
+ };
100
+ };
101
+ type: string;
102
+ };
103
+ metadatas: {
104
+ [key: string]: unknown;
105
+ };
106
+ };
107
+ type RefundableAmount = {
108
+ invoiceId: string;
109
+ fleetId: string;
110
+ refundableAmount: number;
111
+ currency: string;
112
+ refundablePaymentReceipts: Receipt[];
113
+ refundedPaymentReceipts: Receipt[];
114
+ };
75
115
 
76
116
  declare const chargeProduct: (client: Client, info: ChargeProductInfo) => Promise<Invoice>;
77
117
 
78
118
  declare const getUserCreditsByEntityId: (client: Client, id: string) => Promise<Credit>;
79
119
 
80
- interface Payload extends Omit<Credit, 'id' | 'availableAmount' | 'usedAmount' | 'originId' | 'creditAlreadyUsed' | 'updateDate'> {
120
+ interface Payload$1 extends Omit<Credit, 'id' | 'availableAmount' | 'usedAmount' | 'originId' | 'creditAlreadyUsed' | 'updateDate'> {
81
121
  }
82
- declare const addCredits: (client: Client, payload: Payload) => Promise<Credit>;
122
+ declare const addCredits: (client: Client, payload: Payload$1) => Promise<Credit>;
83
123
 
84
124
  declare const getInvoiceById: (client: Client, id: string) => Promise<Invoice>;
85
125
 
86
- export { type ChargeProductInfo, type Credit, type Invoice, addCredits, chargeProduct, getInvoiceById, getUserCreditsByEntityId };
126
+ declare const getRefundableAmount: (client: Client, invoiceId: string) => Promise<RefundableAmount>;
127
+
128
+ interface Payload {
129
+ invoiceId: string;
130
+ amount?: number;
131
+ notes?: string | null;
132
+ paymentIntentPspReference?: string;
133
+ }
134
+ declare const refund: (client: Client, payload: Payload) => Promise<void>;
135
+
136
+ export { type ChargeProductInfo, type Credit, type Invoice, type Receipt, type RefundableAmount, addCredits, chargeProduct, getInvoiceById, getRefundableAmount, getUserCreditsByEntityId, refund };
package/dist/index.js CHANGED
@@ -33,7 +33,9 @@ __export(index_exports, {
33
33
  addCredits: () => addCredits,
34
34
  chargeProduct: () => chargeProduct,
35
35
  getInvoiceById: () => getInvoiceById,
36
- getUserCreditsByEntityId: () => getUserCreditsByEntityId
36
+ getRefundableAmount: () => getRefundableAmount,
37
+ getUserCreditsByEntityId: () => getUserCreditsByEntityId,
38
+ refund: () => refund
37
39
  });
38
40
  module.exports = __toCommonJS(index_exports);
39
41
 
@@ -107,10 +109,47 @@ var getInvoiceById = async (client, id) => {
107
109
  }
108
110
  return client.get(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${id}`).then(({ data }) => data);
109
111
  };
112
+
113
+ // src/getRefundableAmount.ts
114
+ var import_zod5 = __toESM(require("zod"));
115
+ var schema3 = import_zod5.default.string().trim().min(1);
116
+ var getRefundableAmount = async (client, invoiceId) => {
117
+ const result = schema3.safeParse(invoiceId);
118
+ if (!result.success) {
119
+ throw new TypeError("Invalid args", {
120
+ cause: result.error.issues
121
+ });
122
+ }
123
+ return client.get(
124
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/refundableAmount`
125
+ ).then(({ data }) => data);
126
+ };
127
+
128
+ // src/refund.ts
129
+ var import_zod6 = __toESM(require("zod"));
130
+ var schema4 = import_zod6.default.object({
131
+ amount: import_zod6.default.number().min(0).optional(),
132
+ notes: import_zod6.default.string().trim().nullable().optional(),
133
+ paymentIntentPspReference: import_zod6.default.string().trim().min(1).optional()
134
+ });
135
+ var refund = async (client, payload) => {
136
+ const result = schema4.safeParse(payload);
137
+ if (!result.success) {
138
+ throw new TypeError("Invalid args", {
139
+ cause: result.error.issues
140
+ });
141
+ }
142
+ return client.post(
143
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${payload.invoiceId}/refund`,
144
+ result.data
145
+ ).then(({ data }) => data);
146
+ };
110
147
  // Annotate the CommonJS export names for ESM import in node:
111
148
  0 && (module.exports = {
112
149
  addCredits,
113
150
  chargeProduct,
114
151
  getInvoiceById,
115
- getUserCreditsByEntityId
152
+ getRefundableAmount,
153
+ getUserCreditsByEntityId,
154
+ refund
116
155
  });
package/dist/index.mjs CHANGED
@@ -68,9 +68,46 @@ var getInvoiceById = async (client, id) => {
68
68
  }
69
69
  return client.get(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${id}`).then(({ data }) => data);
70
70
  };
71
+
72
+ // src/getRefundableAmount.ts
73
+ import z5 from "zod";
74
+ var schema3 = z5.string().trim().min(1);
75
+ var getRefundableAmount = async (client, invoiceId) => {
76
+ const result = schema3.safeParse(invoiceId);
77
+ if (!result.success) {
78
+ throw new TypeError("Invalid args", {
79
+ cause: result.error.issues
80
+ });
81
+ }
82
+ return client.get(
83
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/refundableAmount`
84
+ ).then(({ data }) => data);
85
+ };
86
+
87
+ // src/refund.ts
88
+ import z6 from "zod";
89
+ var schema4 = z6.object({
90
+ amount: z6.number().min(0).optional(),
91
+ notes: z6.string().trim().nullable().optional(),
92
+ paymentIntentPspReference: z6.string().trim().min(1).optional()
93
+ });
94
+ var refund = async (client, payload) => {
95
+ const result = schema4.safeParse(payload);
96
+ if (!result.success) {
97
+ throw new TypeError("Invalid args", {
98
+ cause: result.error.issues
99
+ });
100
+ }
101
+ return client.post(
102
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${payload.invoiceId}/refund`,
103
+ result.data
104
+ ).then(({ data }) => data);
105
+ };
71
106
  export {
72
107
  addCredits,
73
108
  chargeProduct,
74
109
  getInvoiceById,
75
- getUserCreditsByEntityId
110
+ getRefundableAmount,
111
+ getUserCreditsByEntityId,
112
+ refund
76
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-billing",
3
- "version": "1.1.93",
3
+ "version": "1.1.96",
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.93",
23
- "@vulog/aima-core": "1.1.93"
22
+ "@vulog/aima-client": "1.1.96",
23
+ "@vulog/aima-core": "1.1.96"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.25.76"
@@ -0,0 +1,22 @@
1
+ import { Client } from '@vulog/aima-client';
2
+
3
+ import z from 'zod';
4
+
5
+ import { RefundableAmount } from './types';
6
+
7
+ const schema = z.string().trim().min(1);
8
+
9
+ export const getRefundableAmount = async (client: Client, invoiceId: string): Promise<RefundableAmount> => {
10
+ const result = schema.safeParse(invoiceId);
11
+ if (!result.success) {
12
+ throw new TypeError('Invalid args', {
13
+ cause: result.error.issues,
14
+ });
15
+ }
16
+
17
+ return client
18
+ .get<RefundableAmount>(
19
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/refundableAmount`
20
+ )
21
+ .then(({ data }) => data);
22
+ };
package/src/index.ts CHANGED
@@ -3,3 +3,5 @@ export * from './types';
3
3
  export * from './getUserCreditsByEntityId';
4
4
  export * from './addCredits';
5
5
  export * from './getInvoiceById';
6
+ export * from './getRefundableAmount';
7
+ export * from './refund';
package/src/refund.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { Client } from '@vulog/aima-client';
2
+
3
+ import z from 'zod';
4
+
5
+ interface Payload {
6
+ invoiceId: string;
7
+ amount?: number;
8
+ notes?: string | null;
9
+ paymentIntentPspReference?: string;
10
+ }
11
+
12
+ const schema = z.object({
13
+ amount: z.number().min(0).optional(),
14
+ notes: z.string().trim().nullable().optional(),
15
+ paymentIntentPspReference: z.string().trim().min(1).optional(),
16
+ });
17
+
18
+ export const refund = async (client: Client, payload: Payload): Promise<void> => {
19
+ const result = schema.safeParse(payload);
20
+ if (!result.success) {
21
+ throw new TypeError('Invalid args', {
22
+ cause: result.error.issues,
23
+ });
24
+ }
25
+
26
+ return client
27
+ .post<void>(
28
+ `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${payload.invoiceId}/refund`,
29
+ result.data
30
+ )
31
+ .then(({ data }) => data);
32
+ };
package/src/types.ts CHANGED
@@ -83,3 +83,45 @@ export type Credit = {
83
83
  usage: 'TRIP' | 'REGISTRATION' | 'PRODUCTS' | 'ALL';
84
84
  [key: string]: any;
85
85
  };
86
+
87
+ export type Receipt = {
88
+ id: string;
89
+ pspName: string;
90
+ pspReference: string;
91
+ pspPublishableKey: string;
92
+ amount: number;
93
+ currency: string;
94
+ date: string;
95
+ status: string;
96
+ paymentMethodType: string;
97
+ paymentMethodPspReference: string;
98
+ paymentIntentPspReference: string;
99
+ number: number;
100
+ code: string;
101
+ declineCode: string;
102
+ pspClientSecret: string;
103
+ reason: string;
104
+ note: string;
105
+ nextAction: {
106
+ nextActionRedirectUrl: {
107
+ url: string;
108
+ method: string;
109
+ data: {
110
+ [key: string]: unknown;
111
+ };
112
+ };
113
+ type: string;
114
+ };
115
+ metadatas: {
116
+ [key: string]: unknown;
117
+ };
118
+ };
119
+
120
+ export type RefundableAmount = {
121
+ invoiceId: string;
122
+ fleetId: string;
123
+ refundableAmount: number;
124
+ currency: string;
125
+ refundablePaymentReceipts: Receipt[];
126
+ refundedPaymentReceipts: Receipt[];
127
+ };