@bcc-code/payment-client 1.2.7 → 1.2.9

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 +1 @@
1
- "use strict";var N=Object.create;var S=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var A=(c,d,l,t)=>{if(d&&typeof d=="object"||typeof d=="function")for(let n of B(d))!U.call(c,n)&&n!==l&&S(c,n,{get:()=>d[n],enumerable:!(t=w(d,n))||t.enumerable});return c};var E=(c,d,l)=>(l=c!=null?N(K(c)):{},A(d||!c||!c.__esModule?S(l,"default",{value:c,enumerable:!0}):l,c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),R={class:"stripe-elements"},F={key:0,class:"elements-loading"},V={key:1,class:"elements-error"},I={key:2,class:"payment-button-container"},x=["disabled"],M=e.defineComponent({__name:"StripePayment",props:{paymentId:{},clientData:{default:void 0},clientKey:{default:void 0},amount:{},currency:{},publishableKey:{default:void 0},appearance:{default:void 0},showPayButton:{type:Boolean,default:!0},locale:{default:"en"},loader:{default:"auto"},returnUrl:{default:void 0}},emits:["submit","success","error","ready"],setup(c,{expose:d,emit:l}){const t=c,n=l,b=e.ref(),m=e.ref(!0),o=e.ref(!1),u=e.ref("");let p=null,g=null,f=null;const k=e.computed(()=>({EUR:"€",USD:"$",GBP:"£",CHF:"CHF",NOK:"kr",SEK:"kr",DKK:"kr",PLN:"zł",CZK:"Kč",HUF:"Ft"})[t.currency]||t.currency),C=e.computed(()=>t.amount.toFixed(2)),i=e.computed(()=>{if(t.clientData)try{const s=JSON.parse(t.clientData);return s.clientSecret||s.client_secret}catch{return}}),y=async()=>{if(!b.value)return;let s=t.publishableKey;if(!s&&t.clientData)try{const a=JSON.parse(t.clientData);s=a.publishableKey||a.publishable_key}catch{}if(!s){u.value="Publishable key is required",m.value=!1;return}try{m.value=!0,u.value="";const{loadStripe:a}=await import("@stripe/stripe-js");if(p=await a(s),!p)throw new Error("Failed to load Stripe");const v=i.value,r={appearance:t.appearance||{theme:"stripe",variables:{colorPrimary:"#0570de",colorBackground:"#ffffff",colorText:"#30313d",colorDanger:"#df1b41",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',spacingUnit:"4px",borderRadius:"4px"}},loader:t.loader,locale:t.locale};v&&(r.clientSecret=v),g=p.elements(r),f=g.create("payment",{layout:"tabs",defaultValues:{billingDetails:{name:"",email:"",phone:""}}}),f.mount(b.value),f.on("ready",()=>{m.value=!1,n("ready")}),f.on("change",P=>{P.error?(u.value=P.error.message,n("error",P.error)):u.value=""})}catch(a){u.value=a instanceof Error?a.message:"Failed to initialize payment form",m.value=!1,n("error",a)}},D=async()=>{if(!(!p||!f)){o.value=!0,u.value="";try{const s=t.returnUrl||`${window.location.origin}/payment/return`,{error:a,paymentIntent:v}=await p.confirmPayment({elements:g,confirmParams:{return_url:s},redirect:"if_required"});a?(u.value=a.message||"Payment failed",n("error",a)):v?v.status==="succeeded"?n("success",{paymentIntent:v,status:"succeeded",message:"Payment completed successfully!"}):v.status==="processing"?n("success",{paymentIntent:v,status:"processing",message:"Payment is being processed..."}):n("submit",{paymentIntent:v,status:v.status}):n("submit",f)}catch(s){u.value=s instanceof Error?s.message:"Payment failed",n("error",s)}finally{o.value=!1}}},h=()=>{f&&(f.destroy(),f=null),g&&(g=null),p&&(p=null)};return e.onMounted(()=>{y()}),e.onUnmounted(()=>{h()}),e.watch(()=>t.currency,()=>{h(),y()}),e.watch([()=>t.publishableKey,()=>t.clientData],()=>{(t.publishableKey||t.clientData)&&(h(),y())}),d({destroyElements:h}),(s,a)=>(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("div",{ref_key:"elementsContainer",ref:b,class:"elements-container"},null,512),m.value?(e.openBlock(),e.createElementBlock("div",F,[...a[0]||(a[0]=[e.createElementVNode("div",{class:"loading-spinner"},null,-1),e.createElementVNode("p",null,"Loading payment form...",-1)])])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",V,[a[1]||(a[1]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(u.value),1),e.createElementVNode("button",{class:"retry-btn",onClick:y}," Retry ")])):e.createCommentVNode("",!0),c.showPayButton&&!m.value&&!u.value?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("button",{disabled:o.value,class:"payment-button",onClick:D},e.toDisplayString(o.value?"Processing...":`Pay ${k.value}${C.value}`),9,x)])):e.createCommentVNode("",!0)]))}}),_=(c,d)=>{const l=c.__vccOpts||c;for(const[t,n]of d)l[t]=n;return l},$=_(M,[["__scopeId","data-v-adbdf3c5"]]),O=e.defineComponent({__name:"AdyenPayment",props:{paymentId:{},clientData:{},clientKey:{},environment:{},amount:{},currency:{},paymentData:{},onCancel:{type:Function}},emits:["submit","additionalDetails","error","ready","success"],setup(c,{emit:d}){const l=c,t=d,n=e.ref(null),b=()=>{if(!l.clientData)return console.error("No clientData provided"),null;try{const o=JSON.parse(l.clientData);return console.log("Parsed Adyen session data:",o),{id:o.id,sessionData:o.sessionData,amount:o.amount,reference:o.reference,returnUrl:o.returnUrl,merchantAccount:o.merchantAccount}}catch(o){return console.error("Failed to parse clientData:",o),null}},m=async()=>{var u;if(!l.clientKey||!n.value){console.error("Initialization failed: Missing clientKey or container.");return}const o=b();if(!o){console.error("Failed to parse session data"),t("error",new Error("Failed to parse session data"));return}try{const{AdyenCheckout:p,Card:g,ApplePay:f,GooglePay:k,Klarna:C,Blik:i,Redirect:y,Dropin:D}=await import("@adyen/adyen-web"),h={environment:l.environment||"test",clientKey:l.clientKey,session:o,onPaymentCompleted:(r,P)=>{console.info("Payment Completed:",r,P),t("submit",r),r.resultCode==="Authorised"||r.resultCode==="Received"?(console.info("Payment Successful:",r),t("success",{status:"succeeded",message:"Payment completed successfully",resultCode:r.resultCode,pspReference:r.pspReference,paymentData:r})):r.resultCode==="Pending"?(console.info("Payment Pending:",r),t("success",{status:"processing",message:"Payment is being processed",resultCode:r.resultCode,pspReference:r.pspReference,paymentData:r})):(r.resultCode==="Refused"||r.resultCode==="Error")&&(console.error("Payment Failed:",r),t("error",{message:r.refusalReason||"Payment was declined",resultCode:r.resultCode,paymentData:r}))},onError:(r,P)=>{console.error("Adyen Error:",r.name,r.message,r.stack,P),t("error",r)}},s={showPayButton:!0,paymentMethodComponents:[g,f,k,C,i,y],paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,billingAddressRequired:!1,enableStoreDetails:!1},applePay:{showPayButton:!0},googlePay:{showPayButton:!0},klarna:{useKlarnaWidget:!0},blik:{}}},a=await p(h);console.log("Adyen Checkout created:",a),console.log("Available payment methods from session:",(u=a.paymentMethodsResponse)==null?void 0:u.paymentMethods);const v=new D(a,s);console.log("Adyen Drop-in created with session payment methods"),n.value&&(v.mount(n.value),console.log("Adyen Drop-in mounted successfully"),t("ready"))}catch(p){console.error("Error creating Adyen Drop-in:",p),t("error",p)}};return e.onMounted(()=>{m()}),e.watch(()=>l.clientData,()=>{n.value&&(n.value.innerHTML="",m())}),(o,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dropinContainer",ref:n,class:"payment-dropin"},null,512))}}),H=_(O,[["__scopeId","data-v-f0b79c68"]]),T={class:"delayed-payment-card"},j=["disabled"],z={key:0,class:"mt-2 text-sm text-red-600"},q=e.defineComponent({__name:"DelayedPayment",props:{paymentId:{default:void 0},clientData:{default:void 0},amount:{},currency:{},tenantId:{default:void 0}},emits:["submit","success","error","ready"],setup(c,{expose:d,emit:l}){const t=c,n=l,b=e.ref(!1),m=e.ref(""),o=e.ref({}),u=e.computed(()=>({EUR:"€",USD:"$",GBP:"£",CHF:"CHF",NOK:"kr",SEK:"kr",DKK:"kr",PLN:"zł"})[t.currency]||t.currency),p=e.computed(()=>t.amount.toFixed(2)),g=e.computed(()=>o.value.transactionNumber&&o.value.confirmationUrl),f=()=>{if(!t.clientData){console.error("No clientData provided for delayed payment");return}try{const i=JSON.parse(t.clientData);o.value={transactionNumber:i.transactionNumber,merchantReference:i.merchantReference,providerUid:i.providerUid,paymentUid:i.paymentUid,confirmationUrl:i.confirmationUrl},n("ready")}catch(i){m.value="Invalid session data",n("error",i)}},k=async()=>{if(!(!g.value||b.value)){b.value=!0,m.value="";try{const i={provider:"delayed-payment",amount:t.amount,currency:t.currency,transactionNumber:o.value.transactionNumber,merchantReference:o.value.merchantReference,timestamp:new Date().toISOString()};n("submit",i);const y={"Content-Type":"application/json",Accept:"application/json"};t.tenantId&&(y["X-Tenant-ID"]=t.tenantId);const D=await fetch(o.value.confirmationUrl,{method:"POST",headers:y,credentials:"include"});if(!D.ok){let s="Failed to confirm payment";try{const a=await D.json();a&&typeof a=="object"&&"message"in a&&(s=a.message||s)}catch{try{const a=await D.text();a&&(s=a)}catch{}}throw new Error(s)}const h=await D.json();n("success",{status:"succeeded",message:h.message,paymentId:h.paymentId,transactionNumber:o.value.transactionNumber})}catch(i){m.value=i instanceof Error?i.message:"Failed to confirm payment",n("error",i)}finally{b.value=!1}}},C=()=>{m.value=""};return e.onMounted(()=>{f()}),d({clearError:C}),(i,y)=>(e.openBlock(),e.createElementBlock("div",T,[y[0]||(y[0]=e.createElementVNode("div",{class:"header-row"},[e.createElementVNode("span",{class:"header-icon"},"💳"),e.createElementVNode("span",{class:"header-title"},"Delayed payment")],-1)),y[1]||(y[1]=e.createElementVNode("div",{class:"header-description"}," Payment will be processed manually via invoice or bank transfer ",-1)),e.createElementVNode("button",{disabled:b.value||!g.value,class:"confirm-btn",onClick:k},e.toDisplayString(b.value?"Processing...":`Confirm payment ${p.value}${u.value}`),9,j),m.value?(e.openBlock(),e.createElementBlock("p",z,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0)]))}}),L=_(q,[["__scopeId","data-v-469f1c48"]]);exports.AdyenPayment=H;exports.DelayedPayment=L;exports.StripePayment=$;
1
+ "use strict";var w=Object.create;var E=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var R=(c,d,l,t)=>{if(d&&typeof d=="object"||typeof d=="function")for(let n of K(d))!A.call(c,n)&&n!==l&&E(c,n,{get:()=>d[n],enumerable:!(t=B(d,n))||t.enumerable});return c};var N=(c,d,l)=>(l=c!=null?w(U(c)):{},R(d||!c||!c.__esModule?E(l,"default",{value:c,enumerable:!0}):l,c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F={class:"stripe-elements"},V={key:0,class:"elements-loading"},I={key:1,class:"elements-error"},x={key:2,class:"payment-button-container"},M=["disabled"],$=e.defineComponent({__name:"StripePayment",props:{paymentId:{},clientData:{default:void 0},clientKey:{default:void 0},amount:{},currency:{},publishableKey:{default:void 0},appearance:{default:void 0},showPayButton:{type:Boolean,default:!0},locale:{default:"en"},loader:{default:"auto"},returnUrl:{default:void 0}},emits:["submit","success","error","ready"],setup(c,{expose:d,emit:l}){const t=c,n=l,b=e.ref(),m=e.ref(!0),o=e.ref(!1),u=e.ref("");let p=null,h=null,v=null;const P=e.computed(()=>({EUR:"€",USD:"$",GBP:"£",CHF:"CHF",NOK:"kr",SEK:"kr",DKK:"kr",PLN:"zł",CZK:"Kč",HUF:"Ft"})[t.currency]||t.currency),k=e.computed(()=>t.amount.toFixed(2)),i=e.computed(()=>{if(t.clientData)try{const s=JSON.parse(t.clientData);return s.clientSecret||s.client_secret}catch{return}}),y=async()=>{if(!b.value)return;let s=t.publishableKey;if(!s&&t.clientData)try{const r=JSON.parse(t.clientData);s=r.publishableKey||r.publishable_key}catch{}if(!s){u.value="Publishable key is required",m.value=!1;return}try{m.value=!0,u.value="";const{loadStripe:r}=await import("@stripe/stripe-js");if(p=await r(s),!p)throw new Error("Failed to load Stripe");const f=i.value,C={appearance:t.appearance||{theme:"stripe",variables:{colorPrimary:"#0570de",colorBackground:"#ffffff",colorText:"#30313d",colorDanger:"#df1b41",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',spacingUnit:"4px",borderRadius:"4px"}},loader:t.loader,locale:t.locale};f&&(C.clientSecret=f),h=p.elements(C),v=h.create("payment",{layout:"tabs",defaultValues:{billingDetails:{name:"",email:"",phone:""}}}),v.mount(b.value),v.on("ready",()=>{m.value=!1,n("ready")}),v.on("change",a=>{a.error?(u.value=a.error.message,n("error",a.error)):u.value=""})}catch(r){u.value=r instanceof Error?r.message:"Failed to initialize payment form",m.value=!1,n("error",r)}},D=async()=>{if(!(!p||!v)){o.value=!0,u.value="";try{const s=t.returnUrl||`${window.location.origin}/payment/return`,{error:r,paymentIntent:f}=await p.confirmPayment({elements:h,confirmParams:{return_url:s},redirect:"if_required"});r?(u.value=r.message||"Payment failed",n("error",r)):f?f.status==="succeeded"?n("success",{paymentIntent:f,status:"succeeded",message:"Payment completed successfully!"}):f.status==="processing"?n("success",{paymentIntent:f,status:"processing",message:"Payment is being processed..."}):n("submit",{paymentIntent:f,status:f.status}):n("submit",v)}catch(s){u.value=s instanceof Error?s.message:"Payment failed",n("error",s)}finally{o.value=!1}}},g=()=>{v&&(v.destroy(),v=null),h&&(h=null),p&&(p=null)};return e.onMounted(()=>{y()}),e.onUnmounted(()=>{g()}),e.watch(()=>t.currency,()=>{g(),y()}),e.watch([()=>t.publishableKey,()=>t.clientData],()=>{(t.publishableKey||t.clientData)&&(g(),y())}),d({destroyElements:g}),(s,r)=>(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("div",{ref_key:"elementsContainer",ref:b,class:"elements-container"},null,512),m.value?(e.openBlock(),e.createElementBlock("div",V,[...r[0]||(r[0]=[e.createElementVNode("div",{class:"loading-spinner"},null,-1),e.createElementVNode("p",null,"Loading payment form...",-1)])])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",I,[r[1]||(r[1]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(u.value),1),e.createElementVNode("button",{class:"retry-btn",onClick:y}," Retry ")])):e.createCommentVNode("",!0),c.showPayButton&&!m.value&&!u.value?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("button",{disabled:o.value,class:"payment-button",onClick:D},e.toDisplayString(o.value?"Processing...":`Pay ${P.value}${k.value}`),9,M)])):e.createCommentVNode("",!0)]))}}),S=(c,d)=>{const l=c.__vccOpts||c;for(const[t,n]of d)l[t]=n;return l},O=S($,[["__scopeId","data-v-adbdf3c5"]]),H=e.defineComponent({__name:"AdyenPayment",props:{paymentId:{},clientData:{},clientKey:{},environment:{},amount:{},currency:{},paymentData:{},onCancel:{type:Function}},emits:["submit","additionalDetails","error","ready","success"],setup(c,{emit:d}){const l=c,t=d,n=e.ref(null),b=()=>{if(!l.clientData)return console.error("No clientData provided"),null;try{const o=JSON.parse(l.clientData);return console.log("Parsed Adyen session data:",o),{id:o.id,sessionData:o.sessionData,amount:o.amount,reference:o.reference,returnUrl:o.returnUrl,merchantAccount:o.merchantAccount}}catch(o){return console.error("Failed to parse clientData:",o),null}},m=async()=>{var u;if(!l.clientKey||!n.value){console.error("Initialization failed: Missing clientKey or container.");return}const o=b();if(!o){console.error("Failed to parse session data"),t("error",new Error("Failed to parse session data"));return}try{const{AdyenCheckout:p,Card:h,ApplePay:v,GooglePay:P,Klarna:k,Blik:i,Redirect:y,Dropin:D,Vipps:g}=await import("@adyen/adyen-web"),s={environment:l.environment||"test",clientKey:l.clientKey,session:o,onPaymentCompleted:(a,_)=>{console.info("Payment Completed:",a,_),t("submit",a),a.resultCode==="Authorised"||a.resultCode==="Received"?(console.info("Payment Successful:",a),t("success",{status:"succeeded",message:"Payment completed successfully",resultCode:a.resultCode,pspReference:a.pspReference,paymentData:a})):a.resultCode==="Pending"?(console.info("Payment Pending:",a),t("success",{status:"processing",message:"Payment is being processed",resultCode:a.resultCode,pspReference:a.pspReference,paymentData:a})):(a.resultCode==="Refused"||a.resultCode==="Error")&&(console.error("Payment Failed:",a),t("error",{message:a.refusalReason||"Payment was declined",resultCode:a.resultCode,paymentData:a}))},onError:(a,_)=>{console.error("Adyen Error:",a.name,a.message,a.stack,_),t("error",a)}},r={showPayButton:!0,paymentMethodComponents:[h,v,P,k,i,y,g],paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,billingAddressRequired:!1,enableStoreDetails:!1},applePay:{showPayButton:!0},googlePay:{showPayButton:!0},klarna:{useKlarnaWidget:!0},blik:{},vipps:{showPayButton:!0}}},f=await p(s);console.log("Adyen Checkout created:",f),console.log("Available payment methods from session:",(u=f.paymentMethodsResponse)==null?void 0:u.paymentMethods);const C=new D(f,r);console.log("Adyen Drop-in created with session payment methods"),n.value&&(C.mount(n.value),console.log("Adyen Drop-in mounted successfully"),t("ready"))}catch(p){console.error("Error creating Adyen Drop-in:",p),t("error",p)}};return e.onMounted(()=>{m()}),e.watch(()=>l.clientData,()=>{n.value&&(n.value.innerHTML="",m())}),(o,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dropinContainer",ref:n,class:"payment-dropin"},null,512))}}),T=S(H,[["__scopeId","data-v-2bf1eb85"]]),j={class:"delayed-payment-card"},z=["disabled"],q={key:0,class:"mt-2 text-sm text-red-600"},L=e.defineComponent({__name:"DelayedPayment",props:{paymentId:{default:void 0},clientData:{default:void 0},amount:{},currency:{},tenantId:{default:void 0}},emits:["submit","success","error","ready"],setup(c,{expose:d,emit:l}){const t=c,n=l,b=e.ref(!1),m=e.ref(""),o=e.ref({}),u=e.computed(()=>({EUR:"€",USD:"$",GBP:"£",CHF:"CHF",NOK:"kr",SEK:"kr",DKK:"kr",PLN:"zł"})[t.currency]||t.currency),p=e.computed(()=>t.amount.toFixed(2)),h=e.computed(()=>o.value.transactionNumber&&o.value.confirmationUrl),v=()=>{if(!t.clientData){console.error("No clientData provided for delayed payment");return}try{const i=JSON.parse(t.clientData);o.value={transactionNumber:i.transactionNumber,merchantReference:i.merchantReference,providerUid:i.providerUid,paymentUid:i.paymentUid,confirmationUrl:i.confirmationUrl},n("ready")}catch(i){m.value="Invalid session data",n("error",i)}},P=async()=>{if(!(!h.value||b.value)){b.value=!0,m.value="";try{const i={provider:"delayed-payment",amount:t.amount,currency:t.currency,transactionNumber:o.value.transactionNumber,merchantReference:o.value.merchantReference,timestamp:new Date().toISOString()};n("submit",i);const y={"Content-Type":"application/json",Accept:"application/json"};t.tenantId&&(y["X-Tenant-ID"]=t.tenantId);const D=await fetch(o.value.confirmationUrl,{method:"POST",headers:y,credentials:"include"});if(!D.ok){let s="Failed to confirm payment";try{const r=await D.json();r&&typeof r=="object"&&"message"in r&&(s=r.message||s)}catch{try{const r=await D.text();r&&(s=r)}catch{}}throw new Error(s)}const g=await D.json();n("success",{status:"succeeded",message:g.message,paymentId:g.paymentId,transactionNumber:o.value.transactionNumber})}catch(i){m.value=i instanceof Error?i.message:"Failed to confirm payment",n("error",i)}finally{b.value=!1}}},k=()=>{m.value=""};return e.onMounted(()=>{v()}),d({clearError:k}),(i,y)=>(e.openBlock(),e.createElementBlock("div",j,[y[0]||(y[0]=e.createElementVNode("div",{class:"header-row"},[e.createElementVNode("span",{class:"header-icon"},"💳"),e.createElementVNode("span",{class:"header-title"},"Delayed payment")],-1)),y[1]||(y[1]=e.createElementVNode("div",{class:"header-description"}," Payment will be processed manually via invoice or bank transfer ",-1)),e.createElementVNode("button",{disabled:b.value||!h.value,class:"confirm-btn",onClick:P},e.toDisplayString(b.value?"Processing...":`Confirm payment ${p.value}${u.value}`),9,z),m.value?(e.openBlock(),e.createElementBlock("p",q,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0)]))}}),J=S(L,[["__scopeId","data-v-469f1c48"]]);exports.AdyenPayment=T;exports.DelayedPayment=J;exports.StripePayment=O;
@@ -1,14 +1,14 @@
1
- import { defineComponent as R, ref as D, computed as k, onMounted as A, onUnmounted as I, watch as U, createElementBlock as C, openBlock as S, createElementVNode as p, createCommentVNode as E, toDisplayString as N } from "vue";
2
- const x = { class: "stripe-elements" }, B = {
1
+ import { defineComponent as A, ref as D, computed as S, onMounted as F, onUnmounted as x, watch as R, createElementBlock as _, openBlock as C, createElementVNode as p, createCommentVNode as E, toDisplayString as N } from "vue";
2
+ const B = { class: "stripe-elements" }, $ = {
3
3
  key: 0,
4
4
  class: "elements-loading"
5
- }, $ = {
5
+ }, M = {
6
6
  key: 1,
7
7
  class: "elements-error"
8
- }, M = {
8
+ }, O = {
9
9
  key: 2,
10
10
  class: "payment-button-container"
11
- }, O = ["disabled"], H = /* @__PURE__ */ R({
11
+ }, H = ["disabled"], z = /* @__PURE__ */ A({
12
12
  __name: "StripePayment",
13
13
  props: {
14
14
  paymentId: {},
@@ -24,10 +24,10 @@ const x = { class: "stripe-elements" }, B = {
24
24
  returnUrl: { default: void 0 }
25
25
  },
26
26
  emits: ["submit", "success", "error", "ready"],
27
- setup(b, { expose: P, emit: d }) {
28
- const e = b, r = d, f = D(), l = D(!0), a = D(!1), i = D("");
29
- let c = null, v = null, m = null;
30
- const w = k(() => ({
27
+ setup(b, { expose: P, emit: m }) {
28
+ const e = b, r = m, f = D(), l = D(!0), a = D(!1), i = D("");
29
+ let c = null, v = null, y = null;
30
+ const k = S(() => ({
31
31
  EUR: "€",
32
32
  USD: "$",
33
33
  GBP: "£",
@@ -38,33 +38,33 @@ const x = { class: "stripe-elements" }, B = {
38
38
  PLN: "zł",
39
39
  CZK: "Kč",
40
40
  HUF: "Ft"
41
- })[e.currency] || e.currency), K = k(() => e.amount.toFixed(2)), s = k(() => {
41
+ })[e.currency] || e.currency), w = S(() => e.amount.toFixed(2)), o = S(() => {
42
42
  if (e.clientData)
43
43
  try {
44
- const o = JSON.parse(e.clientData);
45
- return o.clientSecret || o.client_secret;
44
+ const s = JSON.parse(e.clientData);
45
+ return s.clientSecret || s.client_secret;
46
46
  } catch {
47
47
  return;
48
48
  }
49
49
  }), u = async () => {
50
50
  if (!f.value) return;
51
- let o = e.publishableKey;
52
- if (!o && e.clientData)
51
+ let s = e.publishableKey;
52
+ if (!s && e.clientData)
53
53
  try {
54
- const t = JSON.parse(e.clientData);
55
- o = t.publishableKey || t.publishable_key;
54
+ const n = JSON.parse(e.clientData);
55
+ s = n.publishableKey || n.publishable_key;
56
56
  } catch {
57
57
  }
58
- if (!o) {
58
+ if (!s) {
59
59
  i.value = "Publishable key is required", l.value = !1;
60
60
  return;
61
61
  }
62
62
  try {
63
63
  l.value = !0, i.value = "";
64
- const { loadStripe: t } = await import("@stripe/stripe-js");
65
- if (c = await t(o), !c)
64
+ const { loadStripe: n } = await import("@stripe/stripe-js");
65
+ if (c = await n(s), !c)
66
66
  throw new Error("Failed to load Stripe");
67
- const y = s.value, n = {
67
+ const d = o.value, K = {
68
68
  appearance: e.appearance || {
69
69
  theme: "stripe",
70
70
  variables: {
@@ -80,7 +80,7 @@ const x = { class: "stripe-elements" }, B = {
80
80
  loader: e.loader,
81
81
  locale: e.locale
82
82
  };
83
- y && (n.clientSecret = y), v = c.elements(n), m = v.create("payment", {
83
+ d && (K.clientSecret = d), v = c.elements(K), y = v.create("payment", {
84
84
  layout: "tabs",
85
85
  defaultValues: {
86
86
  billingDetails: {
@@ -89,86 +89,86 @@ const x = { class: "stripe-elements" }, B = {
89
89
  phone: ""
90
90
  }
91
91
  }
92
- }), m.mount(f.value), m.on("ready", () => {
92
+ }), y.mount(f.value), y.on("ready", () => {
93
93
  l.value = !1, r("ready");
94
- }), m.on("change", (_) => {
95
- _.error ? (i.value = _.error.message, r("error", _.error)) : i.value = "";
94
+ }), y.on("change", (t) => {
95
+ t.error ? (i.value = t.error.message, r("error", t.error)) : i.value = "";
96
96
  });
97
- } catch (t) {
98
- i.value = t instanceof Error ? t.message : "Failed to initialize payment form", l.value = !1, r("error", t);
97
+ } catch (n) {
98
+ i.value = n instanceof Error ? n.message : "Failed to initialize payment form", l.value = !1, r("error", n);
99
99
  }
100
100
  }, g = async () => {
101
- if (!(!c || !m)) {
101
+ if (!(!c || !y)) {
102
102
  a.value = !0, i.value = "";
103
103
  try {
104
- const o = e.returnUrl || `${window.location.origin}/payment/return`, { error: t, paymentIntent: y } = await c.confirmPayment({
104
+ const s = e.returnUrl || `${window.location.origin}/payment/return`, { error: n, paymentIntent: d } = await c.confirmPayment({
105
105
  elements: v,
106
106
  confirmParams: {
107
- return_url: o
107
+ return_url: s
108
108
  },
109
109
  redirect: "if_required"
110
110
  });
111
- t ? (i.value = t.message || "Payment failed", r("error", t)) : y ? y.status === "succeeded" ? r("success", {
112
- paymentIntent: y,
111
+ n ? (i.value = n.message || "Payment failed", r("error", n)) : d ? d.status === "succeeded" ? r("success", {
112
+ paymentIntent: d,
113
113
  status: "succeeded",
114
114
  message: "Payment completed successfully!"
115
- }) : y.status === "processing" ? r("success", {
116
- paymentIntent: y,
115
+ }) : d.status === "processing" ? r("success", {
116
+ paymentIntent: d,
117
117
  status: "processing",
118
118
  message: "Payment is being processed..."
119
- }) : r("submit", { paymentIntent: y, status: y.status }) : r("submit", m);
120
- } catch (o) {
121
- i.value = o instanceof Error ? o.message : "Payment failed", r("error", o);
119
+ }) : r("submit", { paymentIntent: d, status: d.status }) : r("submit", y);
120
+ } catch (s) {
121
+ i.value = s instanceof Error ? s.message : "Payment failed", r("error", s);
122
122
  } finally {
123
123
  a.value = !1;
124
124
  }
125
125
  }
126
126
  }, h = () => {
127
- m && (m.destroy(), m = null), v && (v = null), c && (c = null);
127
+ y && (y.destroy(), y = null), v && (v = null), c && (c = null);
128
128
  };
129
- return A(() => {
129
+ return F(() => {
130
130
  u();
131
- }), I(() => {
131
+ }), x(() => {
132
132
  h();
133
- }), U(() => e.currency, () => {
133
+ }), R(() => e.currency, () => {
134
134
  h(), u();
135
- }), U([() => e.publishableKey, () => e.clientData], () => {
135
+ }), R([() => e.publishableKey, () => e.clientData], () => {
136
136
  (e.publishableKey || e.clientData) && (h(), u());
137
137
  }), P({
138
138
  destroyElements: h
139
- }), (o, t) => (S(), C("div", x, [
139
+ }), (s, n) => (C(), _("div", B, [
140
140
  p("div", {
141
141
  ref_key: "elementsContainer",
142
142
  ref: f,
143
143
  class: "elements-container"
144
144
  }, null, 512),
145
- l.value ? (S(), C("div", B, [...t[0] || (t[0] = [
145
+ l.value ? (C(), _("div", $, [...n[0] || (n[0] = [
146
146
  p("div", { class: "loading-spinner" }, null, -1),
147
147
  p("p", null, "Loading payment form...", -1)
148
148
  ])])) : E("", !0),
149
- i.value ? (S(), C("div", $, [
150
- t[1] || (t[1] = p("div", { class: "error-icon" }, " ⚠️ ", -1)),
149
+ i.value ? (C(), _("div", M, [
150
+ n[1] || (n[1] = p("div", { class: "error-icon" }, " ⚠️ ", -1)),
151
151
  p("p", null, N(i.value), 1),
152
152
  p("button", {
153
153
  class: "retry-btn",
154
154
  onClick: u
155
155
  }, " Retry ")
156
156
  ])) : E("", !0),
157
- b.showPayButton && !l.value && !i.value ? (S(), C("div", M, [
157
+ b.showPayButton && !l.value && !i.value ? (C(), _("div", O, [
158
158
  p("button", {
159
159
  disabled: a.value,
160
160
  class: "payment-button",
161
161
  onClick: g
162
- }, N(a.value ? "Processing..." : `Pay ${w.value}${K.value}`), 9, O)
162
+ }, N(a.value ? "Processing..." : `Pay ${k.value}${w.value}`), 9, H)
163
163
  ])) : E("", !0)
164
164
  ]));
165
165
  }
166
- }), F = (b, P) => {
167
- const d = b.__vccOpts || b;
166
+ }), I = (b, P) => {
167
+ const m = b.__vccOpts || b;
168
168
  for (const [e, r] of P)
169
- d[e] = r;
170
- return d;
171
- }, V = /* @__PURE__ */ F(H, [["__scopeId", "data-v-adbdf3c5"]]), z = /* @__PURE__ */ R({
169
+ m[e] = r;
170
+ return m;
171
+ }, G = /* @__PURE__ */ I(z, [["__scopeId", "data-v-adbdf3c5"]]), T = /* @__PURE__ */ A({
172
172
  __name: "AdyenPayment",
173
173
  props: {
174
174
  paymentId: {},
@@ -182,11 +182,11 @@ const x = { class: "stripe-elements" }, B = {
182
182
  },
183
183
  emits: ["submit", "additionalDetails", "error", "ready", "success"],
184
184
  setup(b, { emit: P }) {
185
- const d = b, e = P, r = D(null), f = () => {
186
- if (!d.clientData)
185
+ const m = b, e = P, r = D(null), f = () => {
186
+ if (!m.clientData)
187
187
  return console.error("No clientData provided"), null;
188
188
  try {
189
- const a = JSON.parse(d.clientData);
189
+ const a = JSON.parse(m.clientData);
190
190
  return console.log("Parsed Adyen session data:", a), {
191
191
  id: a.id,
192
192
  sessionData: a.sessionData,
@@ -200,7 +200,7 @@ const x = { class: "stripe-elements" }, B = {
200
200
  }
201
201
  }, l = async () => {
202
202
  var i;
203
- if (!d.clientKey || !r.value) {
203
+ if (!m.clientKey || !r.value) {
204
204
  console.error("Initialization failed: Missing clientKey or container.");
205
205
  return;
206
206
  }
@@ -210,35 +210,35 @@ const x = { class: "stripe-elements" }, B = {
210
210
  return;
211
211
  }
212
212
  try {
213
- const { AdyenCheckout: c, Card: v, ApplePay: m, GooglePay: w, Klarna: K, Blik: s, Redirect: u, Dropin: g } = await import("@adyen/adyen-web"), h = {
214
- environment: d.environment || "test",
215
- clientKey: d.clientKey,
213
+ const { AdyenCheckout: c, Card: v, ApplePay: y, GooglePay: k, Klarna: w, Blik: o, Redirect: u, Dropin: g, Vipps: h } = await import("@adyen/adyen-web"), s = {
214
+ environment: m.environment || "test",
215
+ clientKey: m.clientKey,
216
216
  session: a,
217
- onPaymentCompleted: (n, _) => {
218
- console.info("Payment Completed:", n, _), e("submit", n), n.resultCode === "Authorised" || n.resultCode === "Received" ? (console.info("Payment Successful:", n), e("success", {
217
+ onPaymentCompleted: (t, U) => {
218
+ console.info("Payment Completed:", t, U), 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: n.resultCode,
222
- pspReference: n.pspReference,
223
- paymentData: n
224
- })) : n.resultCode === "Pending" ? (console.info("Payment Pending:", n), e("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: n.resultCode,
228
- pspReference: n.pspReference,
229
- paymentData: n
230
- })) : (n.resultCode === "Refused" || n.resultCode === "Error") && (console.error("Payment Failed:", n), e("error", {
231
- message: n.refusalReason || "Payment was declined",
232
- resultCode: n.resultCode,
233
- paymentData: n
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: (n, _) => {
237
- console.error("Adyen Error:", n.name, n.message, n.stack, _), e("error", n);
236
+ onError: (t, U) => {
237
+ console.error("Adyen Error:", t.name, t.message, t.stack, U), e("error", t);
238
238
  }
239
- }, o = {
239
+ }, n = {
240
240
  showPayButton: !0,
241
- paymentMethodComponents: [v, m, w, K, s, u],
241
+ paymentMethodComponents: [v, y, k, w, o, u, h],
242
242
  paymentMethodsConfiguration: {
243
243
  card: {
244
244
  hasHolderName: !0,
@@ -257,30 +257,33 @@ const x = { class: "stripe-elements" }, B = {
257
257
  },
258
258
  blik: {
259
259
  // BLIK configuration for Polish market
260
+ },
261
+ vipps: {
262
+ showPayButton: !0
260
263
  }
261
264
  }
262
- }, t = await c(h);
263
- console.log("Adyen Checkout created:", t), console.log("Available payment methods from session:", (i = t.paymentMethodsResponse) == null ? void 0 : i.paymentMethods);
264
- const y = new g(t, o);
265
- console.log("Adyen Drop-in created with session payment methods"), r.value && (y.mount(r.value), console.log("Adyen Drop-in mounted successfully"), e("ready"));
265
+ }, d = await c(s);
266
+ console.log("Adyen Checkout created:", d), console.log("Available payment methods from session:", (i = d.paymentMethodsResponse) == null ? void 0 : i.paymentMethods);
267
+ const K = new g(d, n);
268
+ console.log("Adyen Drop-in created with session payment methods"), r.value && (K.mount(r.value), console.log("Adyen Drop-in mounted successfully"), e("ready"));
266
269
  } catch (c) {
267
270
  console.error("Error creating Adyen Drop-in:", c), e("error", c);
268
271
  }
269
272
  };
270
- return A(() => {
273
+ return F(() => {
271
274
  l();
272
- }), U(() => d.clientData, () => {
275
+ }), R(() => m.clientData, () => {
273
276
  r.value && (r.value.innerHTML = "", l());
274
- }), (a, i) => (S(), C("div", {
277
+ }), (a, i) => (C(), _("div", {
275
278
  ref_key: "dropinContainer",
276
279
  ref: r,
277
280
  class: "payment-dropin"
278
281
  }, null, 512));
279
282
  }
280
- }), G = /* @__PURE__ */ F(z, [["__scopeId", "data-v-f0b79c68"]]), T = { class: "delayed-payment-card" }, j = ["disabled"], L = {
283
+ }), W = /* @__PURE__ */ I(T, [["__scopeId", "data-v-2bf1eb85"]]), j = { class: "delayed-payment-card" }, L = ["disabled"], V = {
281
284
  key: 0,
282
285
  class: "mt-2 text-sm text-red-600"
283
- }, q = /* @__PURE__ */ R({
286
+ }, q = /* @__PURE__ */ A({
284
287
  __name: "DelayedPayment",
285
288
  props: {
286
289
  paymentId: { default: void 0 },
@@ -290,8 +293,8 @@ const x = { class: "stripe-elements" }, B = {
290
293
  tenantId: { default: void 0 }
291
294
  },
292
295
  emits: ["submit", "success", "error", "ready"],
293
- setup(b, { expose: P, emit: d }) {
294
- const e = b, r = d, f = D(!1), l = D(""), a = D({}), i = k(() => ({
296
+ setup(b, { expose: P, emit: m }) {
297
+ const e = b, r = m, f = D(!1), l = D(""), a = D({}), i = S(() => ({
295
298
  EUR: "€",
296
299
  USD: "$",
297
300
  GBP: "£",
@@ -300,28 +303,28 @@ const x = { class: "stripe-elements" }, B = {
300
303
  SEK: "kr",
301
304
  DKK: "kr",
302
305
  PLN: "zł"
303
- })[e.currency] || e.currency), c = k(() => e.amount.toFixed(2)), v = k(() => a.value.transactionNumber && a.value.confirmationUrl), m = () => {
306
+ })[e.currency] || e.currency), c = S(() => e.amount.toFixed(2)), v = S(() => a.value.transactionNumber && a.value.confirmationUrl), y = () => {
304
307
  if (!e.clientData) {
305
308
  console.error("No clientData provided for delayed payment");
306
309
  return;
307
310
  }
308
311
  try {
309
- const s = JSON.parse(e.clientData);
312
+ const o = JSON.parse(e.clientData);
310
313
  a.value = {
311
- transactionNumber: s.transactionNumber,
312
- merchantReference: s.merchantReference,
313
- providerUid: s.providerUid,
314
- paymentUid: s.paymentUid,
315
- confirmationUrl: s.confirmationUrl
314
+ transactionNumber: o.transactionNumber,
315
+ merchantReference: o.merchantReference,
316
+ providerUid: o.providerUid,
317
+ paymentUid: o.paymentUid,
318
+ confirmationUrl: o.confirmationUrl
316
319
  }, r("ready");
317
- } catch (s) {
318
- l.value = "Invalid session data", r("error", s);
320
+ } catch (o) {
321
+ l.value = "Invalid session data", r("error", o);
319
322
  }
320
- }, w = async () => {
323
+ }, k = async () => {
321
324
  if (!(!v.value || f.value)) {
322
325
  f.value = !0, l.value = "";
323
326
  try {
324
- const s = {
327
+ const o = {
325
328
  provider: "delayed-payment",
326
329
  amount: e.amount,
327
330
  currency: e.currency,
@@ -329,7 +332,7 @@ const x = { class: "stripe-elements" }, B = {
329
332
  merchantReference: a.value.merchantReference,
330
333
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
331
334
  };
332
- r("submit", s);
335
+ r("submit", o);
333
336
  const u = {
334
337
  "Content-Type": "application/json",
335
338
  Accept: "application/json"
@@ -341,18 +344,18 @@ const x = { class: "stripe-elements" }, B = {
341
344
  credentials: "include"
342
345
  });
343
346
  if (!g.ok) {
344
- let o = "Failed to confirm payment";
347
+ let s = "Failed to confirm payment";
345
348
  try {
346
- const t = await g.json();
347
- t && typeof t == "object" && "message" in t && (o = t.message || o);
349
+ const n = await g.json();
350
+ n && typeof n == "object" && "message" in n && (s = n.message || s);
348
351
  } catch {
349
352
  try {
350
- const t = await g.text();
351
- t && (o = t);
353
+ const n = await g.text();
354
+ n && (s = n);
352
355
  } catch {
353
356
  }
354
357
  }
355
- throw new Error(o);
358
+ throw new Error(s);
356
359
  }
357
360
  const h = await g.json();
358
361
  r("success", {
@@ -361,20 +364,20 @@ const x = { class: "stripe-elements" }, B = {
361
364
  paymentId: h.paymentId,
362
365
  transactionNumber: a.value.transactionNumber
363
366
  });
364
- } catch (s) {
365
- l.value = s instanceof Error ? s.message : "Failed to confirm payment", r("error", s);
367
+ } catch (o) {
368
+ l.value = o instanceof Error ? o.message : "Failed to confirm payment", r("error", o);
366
369
  } finally {
367
370
  f.value = !1;
368
371
  }
369
372
  }
370
- }, K = () => {
373
+ }, w = () => {
371
374
  l.value = "";
372
375
  };
373
- return A(() => {
374
- m();
376
+ return F(() => {
377
+ y();
375
378
  }), P({
376
- clearError: K
377
- }), (s, u) => (S(), C("div", T, [
379
+ clearError: w
380
+ }), (o, u) => (C(), _("div", j, [
378
381
  u[0] || (u[0] = p("div", { class: "header-row" }, [
379
382
  p("span", { class: "header-icon" }, "💳"),
380
383
  p("span", { class: "header-title" }, "Delayed payment")
@@ -383,14 +386,14 @@ const x = { class: "stripe-elements" }, B = {
383
386
  p("button", {
384
387
  disabled: f.value || !v.value,
385
388
  class: "confirm-btn",
386
- onClick: w
387
- }, N(f.value ? "Processing..." : `Confirm payment ${c.value}${i.value}`), 9, j),
388
- l.value ? (S(), C("p", L, N(l.value), 1)) : E("", !0)
389
+ onClick: k
390
+ }, N(f.value ? "Processing..." : `Confirm payment ${c.value}${i.value}`), 9, L),
391
+ l.value ? (C(), _("p", V, N(l.value), 1)) : E("", !0)
389
392
  ]));
390
393
  }
391
- }), W = /* @__PURE__ */ F(q, [["__scopeId", "data-v-469f1c48"]]);
394
+ }), X = /* @__PURE__ */ I(q, [["__scopeId", "data-v-469f1c48"]]);
392
395
  export {
393
- G as AdyenPayment,
394
- W as DelayedPayment,
395
- V as StripePayment
396
+ W as AdyenPayment,
397
+ X as DelayedPayment,
398
+ G as StripePayment
396
399
  };
package/dist/index.d.mts CHANGED
@@ -24,6 +24,11 @@ interface CreatePaymentRequest {
24
24
  tripletexProjectId?: number;
25
25
  tripletexProductId?: number;
26
26
  tripletexInvoiceComment?: string;
27
+ payerChurchId?: number;
28
+ payerIdInt?: number;
29
+ payerFirstName?: string;
30
+ payerLastName?: string;
31
+ payerEmail?: string;
27
32
  }
28
33
  interface PersonInfoRequest {
29
34
  payerUid: string;
@@ -69,6 +74,11 @@ interface PaymentResponse {
69
74
  tripletexProjectId?: number | null;
70
75
  tripletexProductId?: number | null;
71
76
  tripletexInvoiceComment?: string | null;
77
+ payerChurchId?: number | null;
78
+ payerId?: number | null;
79
+ payerFirstName?: string | null;
80
+ payerLastName?: string | null;
81
+ payerEmail?: string | null;
72
82
  }
73
83
  interface LineItemResponse {
74
84
  id: string;
package/dist/index.d.ts CHANGED
@@ -24,6 +24,11 @@ interface CreatePaymentRequest {
24
24
  tripletexProjectId?: number;
25
25
  tripletexProductId?: number;
26
26
  tripletexInvoiceComment?: string;
27
+ payerChurchId?: number;
28
+ payerIdInt?: number;
29
+ payerFirstName?: string;
30
+ payerLastName?: string;
31
+ payerEmail?: string;
27
32
  }
28
33
  interface PersonInfoRequest {
29
34
  payerUid: string;
@@ -69,6 +74,11 @@ interface PaymentResponse {
69
74
  tripletexProjectId?: number | null;
70
75
  tripletexProductId?: number | null;
71
76
  tripletexInvoiceComment?: string | null;
77
+ payerChurchId?: number | null;
78
+ payerId?: number | null;
79
+ payerFirstName?: string | null;
80
+ payerLastName?: string | null;
81
+ payerEmail?: string | null;
72
82
  }
73
83
  interface LineItemResponse {
74
84
  id: string;