@bcc-code/payment-client 1.0.5 → 1.0.6

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
@@ -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
@@ -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
@@ -105,6 +105,29 @@ var PaymentClient = class {
105
105
  }
106
106
  return await response.json();
107
107
  }
108
+ async getTotalAmountByPrefix(prefix) {
109
+ const token = await this.getAuthToken();
110
+ const controller = new AbortController();
111
+ if (this.timeout) {
112
+ setTimeout(() => controller.abort(), this.timeout);
113
+ }
114
+ const response = await fetch(
115
+ `${this.baseUrl}/api/v1/payments/stats/total?prefix=${encodeURIComponent(prefix)}`,
116
+ {
117
+ headers: {
118
+ "Authorization": `Bearer ${token}`
119
+ },
120
+ signal: controller.signal
121
+ }
122
+ );
123
+ if (!response.ok) {
124
+ const errorText = await response.text();
125
+ throw new Error(
126
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
127
+ );
128
+ }
129
+ return await response.json();
130
+ }
108
131
  };
109
132
  // Annotate the CommonJS export names for ESM import in node:
110
133
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -79,6 +79,29 @@ var PaymentClient = class {
79
79
  }
80
80
  return await response.json();
81
81
  }
82
+ async getTotalAmountByPrefix(prefix) {
83
+ const token = await this.getAuthToken();
84
+ const controller = new AbortController();
85
+ if (this.timeout) {
86
+ setTimeout(() => controller.abort(), this.timeout);
87
+ }
88
+ const response = await fetch(
89
+ `${this.baseUrl}/api/v1/payments/stats/total?prefix=${encodeURIComponent(prefix)}`,
90
+ {
91
+ headers: {
92
+ "Authorization": `Bearer ${token}`
93
+ },
94
+ signal: controller.signal
95
+ }
96
+ );
97
+ if (!response.ok) {
98
+ const errorText = await response.text();
99
+ throw new Error(
100
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
101
+ );
102
+ }
103
+ return await response.json();
104
+ }
82
105
  };
83
106
  export {
84
107
  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.6",
4
4
  "description": "Client SDK for BCC Payment Orchestrator API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",