@bcc-code/payment-client 1.0.5 → 1.0.7

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
@@ -6,7 +6,7 @@ interface CreatePaymentRequest {
6
6
  paymentMethodType: string;
7
7
  merchantReference?: string;
8
8
  returnUrl: string;
9
- paymentMethodDetails?: Record<string, any>;
9
+ paymentMethodDetails?: Record<string, unknown>;
10
10
  person?: PersonInfoRequest;
11
11
  lineItems?: LineItemRequest[];
12
12
  }
@@ -88,6 +88,14 @@ interface PaymentReceiptResponse {
88
88
  discountAmount?: number;
89
89
  amountFormatted?: string;
90
90
  }
91
+ interface PaymentSucceededNotification {
92
+ paymentId: string;
93
+ reference?: string;
94
+ amount: number;
95
+ currency: string;
96
+ status: string;
97
+ timestamp: string;
98
+ }
91
99
 
92
100
  interface PaymentClientOptions {
93
101
  baseUrl: string;
@@ -105,6 +113,7 @@ declare class PaymentClient {
105
113
  createPayment(request: CreatePaymentRequest): Promise<CreatePaymentResponse>;
106
114
  getPayment(paymentId: string): Promise<PaymentResponse | null>;
107
115
  getReceipt(paymentId: string): Promise<PaymentReceiptResponse | null>;
116
+ getTotalAmountByPrefix(prefix: string): Promise<number>;
108
117
  }
109
118
 
110
119
  interface StripePaymentProps {
@@ -130,4 +139,4 @@ interface AdyenPaymentProps {
130
139
  onCancel?: () => void;
131
140
  }
132
141
 
133
- export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PersonInfoRequest, type StripePaymentProps };
142
+ export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ interface CreatePaymentRequest {
6
6
  paymentMethodType: string;
7
7
  merchantReference?: string;
8
8
  returnUrl: string;
9
- paymentMethodDetails?: Record<string, any>;
9
+ paymentMethodDetails?: Record<string, unknown>;
10
10
  person?: PersonInfoRequest;
11
11
  lineItems?: LineItemRequest[];
12
12
  }
@@ -88,6 +88,14 @@ interface PaymentReceiptResponse {
88
88
  discountAmount?: number;
89
89
  amountFormatted?: string;
90
90
  }
91
+ interface PaymentSucceededNotification {
92
+ paymentId: string;
93
+ reference?: string;
94
+ amount: number;
95
+ currency: string;
96
+ status: string;
97
+ timestamp: string;
98
+ }
91
99
 
92
100
  interface PaymentClientOptions {
93
101
  baseUrl: string;
@@ -105,6 +113,7 @@ declare class PaymentClient {
105
113
  createPayment(request: CreatePaymentRequest): Promise<CreatePaymentResponse>;
106
114
  getPayment(paymentId: string): Promise<PaymentResponse | null>;
107
115
  getReceipt(paymentId: string): Promise<PaymentReceiptResponse | null>;
116
+ getTotalAmountByPrefix(prefix: string): Promise<number>;
108
117
  }
109
118
 
110
119
  interface StripePaymentProps {
@@ -130,4 +139,4 @@ interface AdyenPaymentProps {
130
139
  onCancel?: () => void;
131
140
  }
132
141
 
133
- export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PersonInfoRequest, type StripePaymentProps };
142
+ export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
package/dist/index.js CHANGED
@@ -64,7 +64,8 @@ var PaymentClient = class {
64
64
  }
65
65
  const response = await fetch(`${this.baseUrl}/api/v1/payments/${paymentId}`, {
66
66
  headers: {
67
- "Authorization": `Bearer ${token}`
67
+ "Authorization": `Bearer ${token}`,
68
+ "X-Tenant-ID": this.tenantId
68
69
  },
69
70
  signal: controller.signal
70
71
  });
@@ -89,7 +90,8 @@ var PaymentClient = class {
89
90
  `${this.baseUrl}/api/v1/payments/${paymentId}/receipt`,
90
91
  {
91
92
  headers: {
92
- "Authorization": `Bearer ${token}`
93
+ "Authorization": `Bearer ${token}`,
94
+ "X-Tenant-ID": this.tenantId
93
95
  },
94
96
  signal: controller.signal
95
97
  }
@@ -105,6 +107,30 @@ var PaymentClient = class {
105
107
  }
106
108
  return await response.json();
107
109
  }
110
+ async getTotalAmountByPrefix(prefix) {
111
+ const token = await this.getAuthToken();
112
+ const controller = new AbortController();
113
+ if (this.timeout) {
114
+ setTimeout(() => controller.abort(), this.timeout);
115
+ }
116
+ const response = await fetch(
117
+ `${this.baseUrl}/api/v1/payments/stats/total?prefix=${encodeURIComponent(prefix)}`,
118
+ {
119
+ headers: {
120
+ "Authorization": `Bearer ${token}`,
121
+ "X-Tenant-ID": this.tenantId
122
+ },
123
+ signal: controller.signal
124
+ }
125
+ );
126
+ if (!response.ok) {
127
+ const errorText = await response.text();
128
+ throw new Error(
129
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
130
+ );
131
+ }
132
+ return await response.json();
133
+ }
108
134
  };
109
135
  // Annotate the CommonJS export names for ESM import in node:
110
136
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -38,7 +38,8 @@ var PaymentClient = class {
38
38
  }
39
39
  const response = await fetch(`${this.baseUrl}/api/v1/payments/${paymentId}`, {
40
40
  headers: {
41
- "Authorization": `Bearer ${token}`
41
+ "Authorization": `Bearer ${token}`,
42
+ "X-Tenant-ID": this.tenantId
42
43
  },
43
44
  signal: controller.signal
44
45
  });
@@ -63,7 +64,8 @@ var PaymentClient = class {
63
64
  `${this.baseUrl}/api/v1/payments/${paymentId}/receipt`,
64
65
  {
65
66
  headers: {
66
- "Authorization": `Bearer ${token}`
67
+ "Authorization": `Bearer ${token}`,
68
+ "X-Tenant-ID": this.tenantId
67
69
  },
68
70
  signal: controller.signal
69
71
  }
@@ -79,6 +81,30 @@ var PaymentClient = class {
79
81
  }
80
82
  return await response.json();
81
83
  }
84
+ async getTotalAmountByPrefix(prefix) {
85
+ const token = await this.getAuthToken();
86
+ const controller = new AbortController();
87
+ if (this.timeout) {
88
+ setTimeout(() => controller.abort(), this.timeout);
89
+ }
90
+ const response = await fetch(
91
+ `${this.baseUrl}/api/v1/payments/stats/total?prefix=${encodeURIComponent(prefix)}`,
92
+ {
93
+ headers: {
94
+ "Authorization": `Bearer ${token}`,
95
+ "X-Tenant-ID": this.tenantId
96
+ },
97
+ signal: controller.signal
98
+ }
99
+ );
100
+ if (!response.ok) {
101
+ const errorText = await response.text();
102
+ throw new Error(
103
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
104
+ );
105
+ }
106
+ return await response.json();
107
+ }
82
108
  };
83
109
  export {
84
110
  PaymentClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcc-code/payment-client",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Client SDK for BCC Payment Orchestrator API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",