@bcc-code/payment-client 1.0.8 → 1.1.1

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.
@@ -1,14 +1,14 @@
1
- import { defineComponent as R, ref as h, computed as w, onMounted as B, onUnmounted as N, watch as E, createElementBlock as P, openBlock as C, createElementVNode as y, createCommentVNode as A, toDisplayString as F } from "vue";
2
- const x = { class: "stripe-elements" }, M = {
1
+ import { defineComponent as R, ref as D, computed as S, onMounted as A, onUnmounted as I, watch as E, createElementBlock as v, openBlock as b, createElementVNode as o, createCommentVNode as C, toDisplayString as _ } from "vue";
2
+ const $ = { class: "stripe-elements" }, x = {
3
3
  key: 0,
4
4
  class: "elements-loading"
5
- }, I = {
5
+ }, B = {
6
6
  key: 1,
7
7
  class: "elements-error"
8
- }, z = {
8
+ }, O = {
9
9
  key: 2,
10
10
  class: "payment-button-container"
11
- }, H = ["disabled"], O = /* @__PURE__ */ R({
11
+ }, M = ["disabled"], H = /* @__PURE__ */ R({
12
12
  __name: "StripePayment",
13
13
  props: {
14
14
  paymentId: {},
@@ -24,10 +24,10 @@ const x = { class: "stripe-elements" }, M = {
24
24
  returnUrl: { default: void 0 }
25
25
  },
26
26
  emits: ["submit", "success", "error", "ready"],
27
- setup(d, { expose: g, emit: i }) {
28
- const t = d, o = i, b = h(), u = h(!0), r = h(!1), s = h("");
29
- let l = null, m = null, c = null;
30
- const D = w(() => ({
27
+ setup(h, { expose: P, emit: m }) {
28
+ const e = h, a = m, p = D(), u = D(!0), n = D(!1), c = D("");
29
+ let d = null, f = null, y = null;
30
+ const K = S(() => ({
31
31
  EUR: "€",
32
32
  USD: "$",
33
33
  GBP: "£",
@@ -38,34 +38,34 @@ const x = { class: "stripe-elements" }, M = {
38
38
  PLN: "zł",
39
39
  CZK: "Kč",
40
40
  HUF: "Ft"
41
- })[t.currency] || t.currency), _ = w(() => t.amount.toFixed(2)), k = w(() => {
42
- if (t.clientData)
41
+ })[e.currency] || e.currency), N = S(() => e.amount.toFixed(2)), s = S(() => {
42
+ if (e.clientData)
43
43
  try {
44
- const n = JSON.parse(t.clientData);
45
- return n.clientSecret || n.client_secret;
44
+ const r = JSON.parse(e.clientData);
45
+ return r.clientSecret || r.client_secret;
46
46
  } catch {
47
47
  return;
48
48
  }
49
- }), p = async () => {
50
- if (!b.value) return;
51
- let n = t.publishableKey;
52
- if (!n && t.clientData)
49
+ }), i = async () => {
50
+ if (!p.value) return;
51
+ let r = e.publishableKey;
52
+ if (!r && e.clientData)
53
53
  try {
54
- const a = JSON.parse(t.clientData);
55
- n = a.publishableKey || a.publishable_key;
54
+ const l = JSON.parse(e.clientData);
55
+ r = l.publishableKey || l.publishable_key;
56
56
  } catch {
57
57
  }
58
- if (!n) {
59
- s.value = "Publishable key is required", u.value = !1;
58
+ if (!r) {
59
+ c.value = "Publishable key is required", u.value = !1;
60
60
  return;
61
61
  }
62
62
  try {
63
- u.value = !0, s.value = "";
64
- const { loadStripe: a } = await import("@stripe/stripe-js");
65
- if (l = await a(n), !l)
63
+ u.value = !0, c.value = "";
64
+ const { loadStripe: l } = await import("@stripe/stripe-js");
65
+ if (d = await l(r), !d)
66
66
  throw new Error("Failed to load Stripe");
67
- const e = k.value, v = {
68
- appearance: t.appearance || {
67
+ const t = s.value, w = {
68
+ appearance: e.appearance || {
69
69
  theme: "stripe",
70
70
  variables: {
71
71
  colorPrimary: "#0570de",
@@ -77,10 +77,10 @@ const x = { class: "stripe-elements" }, M = {
77
77
  borderRadius: "4px"
78
78
  }
79
79
  },
80
- loader: t.loader,
81
- locale: t.locale
80
+ loader: e.loader,
81
+ locale: e.locale
82
82
  };
83
- e && (v.clientSecret = e), m = l.elements(v), c = m.create("payment", {
83
+ t && (w.clientSecret = t), f = d.elements(w), y = f.create("payment", {
84
84
  layout: "tabs",
85
85
  defaultValues: {
86
86
  billingDetails: {
@@ -89,86 +89,86 @@ const x = { class: "stripe-elements" }, M = {
89
89
  phone: ""
90
90
  }
91
91
  }
92
- }), c.mount(b.value), c.on("ready", () => {
93
- u.value = !1, o("ready");
94
- }), c.on("change", (K) => {
95
- K.error ? (s.value = K.error.message, o("error", K.error)) : s.value = "";
92
+ }), y.mount(p.value), y.on("ready", () => {
93
+ u.value = !1, a("ready");
94
+ }), y.on("change", (U) => {
95
+ U.error ? (c.value = U.error.message, a("error", U.error)) : c.value = "";
96
96
  });
97
- } catch (a) {
98
- s.value = a instanceof Error ? a.message : "Failed to initialize payment form", u.value = !1, o("error", a);
97
+ } catch (l) {
98
+ c.value = l instanceof Error ? l.message : "Failed to initialize payment form", u.value = !1, a("error", l);
99
99
  }
100
- }, S = async () => {
101
- if (!(!l || !c)) {
102
- r.value = !0, s.value = "";
100
+ }, k = async () => {
101
+ if (!(!d || !y)) {
102
+ n.value = !0, c.value = "";
103
103
  try {
104
- const n = t.returnUrl || `${window.location.origin}/payment/return`, { error: a, paymentIntent: e } = await l.confirmPayment({
105
- elements: m,
104
+ const r = e.returnUrl || `${window.location.origin}/payment/return`, { error: l, paymentIntent: t } = await d.confirmPayment({
105
+ elements: f,
106
106
  confirmParams: {
107
- return_url: n
107
+ return_url: r
108
108
  },
109
109
  redirect: "if_required"
110
110
  });
111
- a ? (s.value = a.message || "Payment failed", o("error", a)) : e ? e.status === "succeeded" ? o("success", {
112
- paymentIntent: e,
111
+ l ? (c.value = l.message || "Payment failed", a("error", l)) : t ? t.status === "succeeded" ? a("success", {
112
+ paymentIntent: t,
113
113
  status: "succeeded",
114
114
  message: "Payment completed successfully!"
115
- }) : e.status === "processing" ? o("success", {
116
- paymentIntent: e,
115
+ }) : t.status === "processing" ? a("success", {
116
+ paymentIntent: t,
117
117
  status: "processing",
118
118
  message: "Payment is being processed..."
119
- }) : o("submit", { paymentIntent: e, status: e.status }) : o("submit", c);
120
- } catch (n) {
121
- s.value = n instanceof Error ? n.message : "Payment failed", o("error", n);
119
+ }) : a("submit", { paymentIntent: t, status: t.status }) : a("submit", y);
120
+ } catch (r) {
121
+ c.value = r instanceof Error ? r.message : "Payment failed", a("error", r);
122
122
  } finally {
123
- r.value = !1;
123
+ n.value = !1;
124
124
  }
125
125
  }
126
- }, f = () => {
127
- c && (c.destroy(), c = null), m && (m = null), l && (l = null);
126
+ }, g = () => {
127
+ y && (y.destroy(), y = null), f && (f = null), d && (d = null);
128
128
  };
129
- return B(() => {
130
- p();
131
- }), N(() => {
132
- f();
133
- }), E(() => t.currency, () => {
134
- f(), p();
135
- }), E([() => t.publishableKey, () => t.clientData], () => {
136
- (t.publishableKey || t.clientData) && (f(), p());
137
- }), g({
138
- destroyElements: f
139
- }), (n, a) => (C(), P("div", x, [
140
- y("div", {
129
+ return A(() => {
130
+ i();
131
+ }), I(() => {
132
+ g();
133
+ }), E(() => e.currency, () => {
134
+ g(), i();
135
+ }), E([() => e.publishableKey, () => e.clientData], () => {
136
+ (e.publishableKey || e.clientData) && (g(), i());
137
+ }), P({
138
+ destroyElements: g
139
+ }), (r, l) => (b(), v("div", $, [
140
+ o("div", {
141
141
  ref_key: "elementsContainer",
142
- ref: b,
142
+ ref: p,
143
143
  class: "elements-container"
144
144
  }, null, 512),
145
- u.value ? (C(), P("div", M, [...a[0] || (a[0] = [
146
- y("div", { class: "loading-spinner" }, null, -1),
147
- y("p", null, "Loading payment form...", -1)
148
- ])])) : A("", !0),
149
- s.value ? (C(), P("div", I, [
150
- a[1] || (a[1] = y("div", { class: "error-icon" }, " ⚠️ ", -1)),
151
- y("p", null, F(s.value), 1),
152
- y("button", {
145
+ u.value ? (b(), v("div", x, [...l[0] || (l[0] = [
146
+ o("div", { class: "loading-spinner" }, null, -1),
147
+ o("p", null, "Loading payment form...", -1)
148
+ ])])) : C("", !0),
149
+ c.value ? (b(), v("div", B, [
150
+ l[1] || (l[1] = o("div", { class: "error-icon" }, " ⚠️ ", -1)),
151
+ o("p", null, _(c.value), 1),
152
+ o("button", {
153
153
  class: "retry-btn",
154
- onClick: p
154
+ onClick: i
155
155
  }, " Retry ")
156
- ])) : A("", !0),
157
- d.showPayButton && !u.value && !s.value ? (C(), P("div", z, [
158
- y("button", {
159
- disabled: r.value,
156
+ ])) : C("", !0),
157
+ h.showPayButton && !u.value && !c.value ? (b(), v("div", O, [
158
+ o("button", {
159
+ disabled: n.value,
160
160
  class: "payment-button",
161
- onClick: S
162
- }, F(r.value ? "Processing..." : `Pay ${D.value}${_.value}`), 9, H)
163
- ])) : A("", !0)
161
+ onClick: k
162
+ }, _(n.value ? "Processing..." : `Pay ${K.value}${N.value}`), 9, M)
163
+ ])) : C("", !0)
164
164
  ]));
165
165
  }
166
- }), U = (d, g) => {
167
- const i = d.__vccOpts || d;
168
- for (const [t, o] of g)
169
- i[t] = o;
170
- return i;
171
- }, L = /* @__PURE__ */ U(O, [["__scopeId", "data-v-adbdf3c5"]]), $ = /* @__PURE__ */ R({
166
+ }), F = (h, P) => {
167
+ const m = h.__vccOpts || h;
168
+ for (const [e, a] of P)
169
+ m[e] = a;
170
+ return m;
171
+ }, ne = /* @__PURE__ */ F(H, [["__scopeId", "data-v-adbdf3c5"]]), z = /* @__PURE__ */ R({
172
172
  __name: "AdyenPayment",
173
173
  props: {
174
174
  paymentId: {},
@@ -181,64 +181,64 @@ const x = { class: "stripe-elements" }, M = {
181
181
  onCancel: { type: Function }
182
182
  },
183
183
  emits: ["submit", "additionalDetails", "error", "ready", "success"],
184
- setup(d, { emit: g }) {
185
- const i = d, t = g, o = h(null), b = () => {
186
- if (!i.clientData)
184
+ setup(h, { emit: P }) {
185
+ const m = h, e = P, a = D(null), p = () => {
186
+ if (!m.clientData)
187
187
  return console.error("No clientData provided"), null;
188
188
  try {
189
- const r = JSON.parse(i.clientData);
190
- return console.log("Parsed Adyen session data:", r), {
191
- id: r.id,
192
- sessionData: r.sessionData,
193
- amount: r.amount,
194
- reference: r.reference,
195
- returnUrl: r.returnUrl,
196
- merchantAccount: r.merchantAccount
189
+ const n = JSON.parse(m.clientData);
190
+ return console.log("Parsed Adyen session data:", n), {
191
+ id: n.id,
192
+ sessionData: n.sessionData,
193
+ amount: n.amount,
194
+ reference: n.reference,
195
+ returnUrl: n.returnUrl,
196
+ merchantAccount: n.merchantAccount
197
197
  };
198
- } catch (r) {
199
- return console.error("Failed to parse clientData:", r), null;
198
+ } catch (n) {
199
+ return console.error("Failed to parse clientData:", n), null;
200
200
  }
201
201
  }, u = async () => {
202
- var s;
203
- if (!i.clientKey || !o.value) {
202
+ var c;
203
+ if (!m.clientKey || !a.value) {
204
204
  console.error("Initialization failed: Missing clientKey or container.");
205
205
  return;
206
206
  }
207
- const r = b();
208
- if (!r) {
209
- console.error("Failed to parse session data"), t("error", new Error("Failed to parse session data"));
207
+ const n = p();
208
+ if (!n) {
209
+ console.error("Failed to parse session data"), e("error", new Error("Failed to parse session data"));
210
210
  return;
211
211
  }
212
212
  try {
213
- const { AdyenCheckout: l, Card: m, ApplePay: c, GooglePay: D, Klarna: _, Blik: k, Dropin: p } = await import("@adyen/adyen-web"), S = {
214
- environment: i.environment || "test",
215
- clientKey: i.clientKey,
216
- session: r,
217
- onPaymentCompleted: (e, v) => {
218
- console.info("Payment Completed:", e, v), t("submit", e), e.resultCode === "Authorised" || e.resultCode === "Received" ? (console.info("Payment Successful:", e), t("success", {
213
+ const { AdyenCheckout: d, Card: f, ApplePay: y, GooglePay: K, Klarna: N, Blik: s, Dropin: i } = await import("@adyen/adyen-web"), k = {
214
+ environment: m.environment || "test",
215
+ clientKey: m.clientKey,
216
+ session: n,
217
+ onPaymentCompleted: (t, w) => {
218
+ console.info("Payment Completed:", t, w), e("submit", t), t.resultCode === "Authorised" || t.resultCode === "Received" ? (console.info("Payment Successful:", t), e("success", {
219
219
  status: "succeeded",
220
220
  message: "Payment completed successfully",
221
- resultCode: e.resultCode,
222
- pspReference: e.pspReference,
223
- paymentData: e
224
- })) : e.resultCode === "Pending" ? (console.info("Payment Pending:", e), t("success", {
221
+ resultCode: t.resultCode,
222
+ pspReference: t.pspReference,
223
+ paymentData: t
224
+ })) : t.resultCode === "Pending" ? (console.info("Payment Pending:", t), e("success", {
225
225
  status: "processing",
226
226
  message: "Payment is being processed",
227
- resultCode: e.resultCode,
228
- pspReference: e.pspReference,
229
- paymentData: e
230
- })) : (e.resultCode === "Refused" || e.resultCode === "Error") && (console.error("Payment Failed:", e), t("error", {
231
- message: e.refusalReason || "Payment was declined",
232
- resultCode: e.resultCode,
233
- paymentData: e
227
+ resultCode: t.resultCode,
228
+ pspReference: t.pspReference,
229
+ paymentData: t
230
+ })) : (t.resultCode === "Refused" || t.resultCode === "Error") && (console.error("Payment Failed:", t), e("error", {
231
+ message: t.refusalReason || "Payment was declined",
232
+ resultCode: t.resultCode,
233
+ paymentData: t
234
234
  }));
235
235
  },
236
- onError: (e, v) => {
237
- console.error("Adyen Error:", e.name, e.message, e.stack, v), t("error", e);
236
+ onError: (t, w) => {
237
+ console.error("Adyen Error:", t.name, t.message, t.stack, w), e("error", t);
238
238
  }
239
- }, f = {
239
+ }, g = {
240
240
  showPayButton: !0,
241
- paymentMethodComponents: [m, c, D, _, k],
241
+ paymentMethodComponents: [f, y, K, N, s],
242
242
  paymentMethodsConfiguration: {
243
243
  card: {
244
244
  hasHolderName: !0,
@@ -259,26 +259,161 @@ const x = { class: "stripe-elements" }, M = {
259
259
  // BLIK configuration for Polish market
260
260
  }
261
261
  }
262
- }, n = await l(S);
263
- console.log("Adyen Checkout created:", n), console.log("Available payment methods from session:", (s = n.paymentMethodsResponse) == null ? void 0 : s.paymentMethods);
264
- const a = new p(n, f);
265
- console.log("Adyen Drop-in created with session payment methods"), o.value && (a.mount(o.value), console.log("Adyen Drop-in mounted successfully"), t("ready"));
266
- } catch (l) {
267
- console.error("Error creating Adyen Drop-in:", l), t("error", l);
262
+ }, r = await d(k);
263
+ console.log("Adyen Checkout created:", r), console.log("Available payment methods from session:", (c = r.paymentMethodsResponse) == null ? void 0 : c.paymentMethods);
264
+ const l = new i(r, g);
265
+ console.log("Adyen Drop-in created with session payment methods"), a.value && (l.mount(a.value), console.log("Adyen Drop-in mounted successfully"), e("ready"));
266
+ } catch (d) {
267
+ console.error("Error creating Adyen Drop-in:", d), e("error", d);
268
268
  }
269
269
  };
270
- return B(() => {
270
+ return A(() => {
271
271
  u();
272
- }), E(() => i.clientData, () => {
273
- o.value && (o.value.innerHTML = "", u());
274
- }), (r, s) => (C(), P("div", {
272
+ }), E(() => m.clientData, () => {
273
+ a.value && (a.value.innerHTML = "", u());
274
+ }), (n, c) => (b(), v("div", {
275
275
  ref_key: "dropinContainer",
276
- ref: o,
276
+ ref: a,
277
277
  class: "payment-dropin"
278
278
  }, null, 512));
279
279
  }
280
- }), J = /* @__PURE__ */ U($, [["__scopeId", "data-v-ef2ec054"]]);
280
+ }), ae = /* @__PURE__ */ F(z, [["__scopeId", "data-v-ef2ec054"]]), T = { class: "delayed-payment" }, L = { class: "payment-form" }, q = { class: "amount-display" }, J = { class: "amount-value" }, V = {
281
+ key: 0,
282
+ class: "session-info"
283
+ }, G = {
284
+ key: 0,
285
+ class: "info-row"
286
+ }, j = { class: "value" }, W = {
287
+ key: 1,
288
+ class: "info-row"
289
+ }, X = { class: "value" }, Y = {
290
+ key: 1,
291
+ class: "error-message"
292
+ }, Z = { class: "button-container" }, Q = ["disabled"], ee = /* @__PURE__ */ R({
293
+ __name: "DelayedPayment",
294
+ props: {
295
+ paymentId: { default: void 0 },
296
+ clientData: { default: void 0 },
297
+ amount: {},
298
+ currency: {},
299
+ tenantId: { default: void 0 }
300
+ },
301
+ emits: ["submit", "success", "error", "ready"],
302
+ setup(h, { expose: P, emit: m }) {
303
+ const e = h, a = m, p = D(!1), u = D(""), n = D({}), c = S(() => ({
304
+ EUR: "€",
305
+ USD: "$",
306
+ GBP: "£",
307
+ CHF: "CHF",
308
+ NOK: "kr",
309
+ SEK: "kr",
310
+ DKK: "kr",
311
+ PLN: "zł"
312
+ })[e.currency] || e.currency), d = S(() => e.amount.toFixed(2)), f = S(() => n.value.invoiceNumber && n.value.providerUid), y = () => {
313
+ if (!e.clientData) {
314
+ console.error("No clientData provided for delayed payment");
315
+ return;
316
+ }
317
+ try {
318
+ const s = JSON.parse(e.clientData);
319
+ console.log("Parsed delayed payment session data:", s), n.value = {
320
+ invoiceNumber: s.invoiceNumber,
321
+ merchantReference: s.merchantReference,
322
+ providerUid: s.providerUid,
323
+ paymentUid: s.paymentUid
324
+ }, a("ready");
325
+ } catch (s) {
326
+ console.error("Failed to parse clientData:", s), u.value = "Invalid session data", a("error", s);
327
+ }
328
+ }, K = async () => {
329
+ if (!(!f.value || p.value)) {
330
+ p.value = !0, u.value = "";
331
+ try {
332
+ const s = {
333
+ provider: "delayed-payment",
334
+ amount: e.amount,
335
+ currency: e.currency,
336
+ invoiceNumber: n.value.invoiceNumber,
337
+ merchantReference: n.value.merchantReference,
338
+ providerUid: n.value.providerUid,
339
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
340
+ };
341
+ if (a("submit", s), !e.paymentId)
342
+ throw new Error("Payment ID not provided");
343
+ const i = window.location.origin, k = {
344
+ "Content-Type": "application/json"
345
+ };
346
+ e.tenantId && (k["X-Tenant-ID"] = e.tenantId);
347
+ const g = await fetch(
348
+ `${i}/api/v1/webhooks/delayed-payments/confirm/${e.paymentId}`,
349
+ {
350
+ method: "POST",
351
+ headers: k
352
+ }
353
+ );
354
+ if (!g.ok) {
355
+ const r = await g.text();
356
+ throw new Error(`Failed to confirm payment: ${r}`);
357
+ }
358
+ a("success", {
359
+ status: "succeeded",
360
+ message: "Payment confirmed successfully. You will receive a receipt shortly.",
361
+ resultCode: "Authorised",
362
+ invoiceNumber: n.value.invoiceNumber,
363
+ providerUid: n.value.providerUid,
364
+ paymentData: s
365
+ });
366
+ } catch (s) {
367
+ u.value = s instanceof Error ? s.message : "Failed to confirm payment", a("error", s);
368
+ } finally {
369
+ p.value = !1;
370
+ }
371
+ }
372
+ }, N = () => {
373
+ u.value = "";
374
+ };
375
+ return A(() => {
376
+ y();
377
+ }), P({
378
+ clearError: N
379
+ }), (s, i) => (b(), v("div", T, [
380
+ o("div", L, [
381
+ i[4] || (i[4] = o("div", { class: "info-section" }, [
382
+ o("div", { class: "info-icon" }, " 📄 "),
383
+ o("h3", { class: "info-title" }, " Delayed Payment "),
384
+ o("p", { class: "info-description" }, " Payment will be processed manually via invoice or bank transfer ")
385
+ ], -1)),
386
+ o("div", q, [
387
+ i[0] || (i[0] = o("span", { class: "amount-label" }, "Amount to pay:", -1)),
388
+ o("span", J, _(c.value) + _(d.value), 1)
389
+ ]),
390
+ f.value ? (b(), v("div", V, [
391
+ n.value.invoiceNumber ? (b(), v("div", G, [
392
+ i[1] || (i[1] = o("span", { class: "label" }, "Invoice Number:", -1)),
393
+ o("span", j, _(n.value.invoiceNumber), 1)
394
+ ])) : C("", !0),
395
+ n.value.merchantReference ? (b(), v("div", W, [
396
+ i[2] || (i[2] = o("span", { class: "label" }, "Reference:", -1)),
397
+ o("span", X, _(n.value.merchantReference), 1)
398
+ ])) : C("", !0)
399
+ ])) : C("", !0),
400
+ u.value ? (b(), v("div", Y, [
401
+ i[3] || (i[3] = o("div", { class: "error-icon" }, " ⚠️ ", -1)),
402
+ o("p", null, _(u.value), 1)
403
+ ])) : C("", !0),
404
+ o("div", Z, [
405
+ o("button", {
406
+ disabled: p.value || !f.value,
407
+ class: "submit-button",
408
+ onClick: K
409
+ }, _(p.value ? "Processing..." : `Confirm Payment ${c.value}${d.value}`), 9, Q)
410
+ ])
411
+ ])
412
+ ]));
413
+ }
414
+ }), oe = /* @__PURE__ */ F(ee, [["__scopeId", "data-v-4d12cc1a"]]);
281
415
  export {
282
- J as AdyenPayment,
283
- L as StripePayment
416
+ ae as AdyenPayment,
417
+ oe as DelayedPayment,
418
+ ne as StripePayment
284
419
  };
package/dist/index.d.mts CHANGED
@@ -115,6 +115,13 @@ interface PaymentSucceededNotification {
115
115
  status: string;
116
116
  timestamp: string;
117
117
  }
118
+ interface GetPaymentMethodsOptions {
119
+ provider?: string;
120
+ currency?: string;
121
+ amount?: number;
122
+ churchId?: string;
123
+ isCompany?: boolean;
124
+ }
118
125
 
119
126
  interface PaymentClientOptions {
120
127
  baseUrl: string;
@@ -133,6 +140,7 @@ declare class PaymentClient {
133
140
  getPayment(paymentId: string): Promise<PaymentResponse | null>;
134
141
  getReceipt(paymentId: string): Promise<PaymentReceiptResponse | null>;
135
142
  getTotalAmountByPrefix(prefix: string): Promise<number>;
143
+ getPaymentMethods(options?: GetPaymentMethodsOptions): Promise<unknown>;
136
144
  }
137
145
 
138
146
  interface StripePaymentProps {
@@ -158,4 +166,4 @@ interface AdyenPaymentProps {
158
166
  onCancel?: () => void;
159
167
  }
160
168
 
161
- export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type InvoiceRecipientRequest, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
169
+ export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type GetPaymentMethodsOptions, type InvoiceRecipientRequest, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
package/dist/index.d.ts CHANGED
@@ -115,6 +115,13 @@ interface PaymentSucceededNotification {
115
115
  status: string;
116
116
  timestamp: string;
117
117
  }
118
+ interface GetPaymentMethodsOptions {
119
+ provider?: string;
120
+ currency?: string;
121
+ amount?: number;
122
+ churchId?: string;
123
+ isCompany?: boolean;
124
+ }
118
125
 
119
126
  interface PaymentClientOptions {
120
127
  baseUrl: string;
@@ -133,6 +140,7 @@ declare class PaymentClient {
133
140
  getPayment(paymentId: string): Promise<PaymentResponse | null>;
134
141
  getReceipt(paymentId: string): Promise<PaymentReceiptResponse | null>;
135
142
  getTotalAmountByPrefix(prefix: string): Promise<number>;
143
+ getPaymentMethods(options?: GetPaymentMethodsOptions): Promise<unknown>;
136
144
  }
137
145
 
138
146
  interface StripePaymentProps {
@@ -158,4 +166,4 @@ interface AdyenPaymentProps {
158
166
  onCancel?: () => void;
159
167
  }
160
168
 
161
- export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type InvoiceRecipientRequest, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
169
+ export { type AdyenPaymentProps, type CreatePaymentRequest, type CreatePaymentResponse, type GetPaymentMethodsOptions, type InvoiceRecipientRequest, type LineItemRequest, type LineItemResponse, PaymentClient, type PaymentClientOptions, type PaymentReceiptResponse, type PaymentResponse, type PaymentSucceededNotification, type PersonInfoRequest, type StripePaymentProps };
package/dist/index.js CHANGED
@@ -131,6 +131,36 @@ var PaymentClient = class {
131
131
  }
132
132
  return await response.json();
133
133
  }
134
+ async getPaymentMethods(options = {}) {
135
+ const token = await this.getAuthToken();
136
+ const params = new URLSearchParams();
137
+ if (options.provider) params.set("provider", options.provider);
138
+ if (options.currency) params.set("currency", options.currency);
139
+ if (options.amount != null) params.set("amount", options.amount.toString());
140
+ if (options.churchId) params.set("churchId", options.churchId);
141
+ if (options.isCompany != null) params.set("isCompany", options.isCompany.toString());
142
+ const controller = new AbortController();
143
+ if (this.timeout) {
144
+ setTimeout(() => controller.abort(), this.timeout);
145
+ }
146
+ const response = await fetch(
147
+ `${this.baseUrl}/api/v1/configuration/payment-methods?${params.toString()}`,
148
+ {
149
+ headers: {
150
+ "Authorization": `Bearer ${token}`,
151
+ "X-Tenant-ID": this.tenantId
152
+ },
153
+ signal: controller.signal
154
+ }
155
+ );
156
+ if (!response.ok) {
157
+ const errorText = await response.text();
158
+ throw new Error(
159
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
160
+ );
161
+ }
162
+ return await response.json();
163
+ }
134
164
  };
135
165
  // Annotate the CommonJS export names for ESM import in node:
136
166
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -105,6 +105,36 @@ var PaymentClient = class {
105
105
  }
106
106
  return await response.json();
107
107
  }
108
+ async getPaymentMethods(options = {}) {
109
+ const token = await this.getAuthToken();
110
+ const params = new URLSearchParams();
111
+ if (options.provider) params.set("provider", options.provider);
112
+ if (options.currency) params.set("currency", options.currency);
113
+ if (options.amount != null) params.set("amount", options.amount.toString());
114
+ if (options.churchId) params.set("churchId", options.churchId);
115
+ if (options.isCompany != null) params.set("isCompany", options.isCompany.toString());
116
+ const controller = new AbortController();
117
+ if (this.timeout) {
118
+ setTimeout(() => controller.abort(), this.timeout);
119
+ }
120
+ const response = await fetch(
121
+ `${this.baseUrl}/api/v1/configuration/payment-methods?${params.toString()}`,
122
+ {
123
+ headers: {
124
+ "Authorization": `Bearer ${token}`,
125
+ "X-Tenant-ID": this.tenantId
126
+ },
127
+ signal: controller.signal
128
+ }
129
+ );
130
+ if (!response.ok) {
131
+ const errorText = await response.text();
132
+ throw new Error(
133
+ `Payment API request failed: ${response.status} ${response.statusText}. ${errorText}`
134
+ );
135
+ }
136
+ return await response.json();
137
+ }
108
138
  };
109
139
  export {
110
140
  PaymentClient