@bcc-code/payment-client 1.1.2 → 1.1.3
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/README.md +18 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.mjs +124 -148
- package/dist/styles/adyen.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,7 +222,7 @@ const payment = await paymentClient.createPayment({
|
|
|
222
222
|
amount: 99.99,
|
|
223
223
|
currency: 'EUR',
|
|
224
224
|
paymentMethodType: 'delayed-payment',
|
|
225
|
-
returnUrl: 'https://
|
|
225
|
+
returnUrl: 'https://clientapp.pl/success' // IMPORTANT: User returns here after confirmation
|
|
226
226
|
})
|
|
227
227
|
|
|
228
228
|
const tenantId = 'your-tenant-uuid'
|
|
@@ -242,6 +242,23 @@ const handleReady = () => {
|
|
|
242
242
|
</script>
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
+
**Important:** When the user clicks "Confirm Payment", they will be redirected to the payment API's confirmation page, then back to your `returnUrl` with query parameters:
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
// Handle return in your success page:
|
|
249
|
+
const urlParams = new URLSearchParams(window.location.search)
|
|
250
|
+
const status = urlParams.get('status') // 'success' or 'error'
|
|
251
|
+
const message = urlParams.get('message') // User-friendly message
|
|
252
|
+
|
|
253
|
+
if (status === 'success') {
|
|
254
|
+
// Payment confirmed successfully
|
|
255
|
+
showSuccessMessage(message)
|
|
256
|
+
} else if (status === 'error') {
|
|
257
|
+
// Payment confirmation failed
|
|
258
|
+
showErrorMessage(message)
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
245
262
|
### Component Props
|
|
246
263
|
|
|
247
264
|
#### StripePayment Props
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=Object.create;var _=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var K=(l,m,i,t)=>{if(m&&typeof m=="object"||typeof m=="function")for(let a of V(m))!U.call(l,a)&&a!==i&&_(l,a,{get:()=>m[a],enumerable:!(t=w(m,a))||t.enumerable});return l};var C=(l,m,i)=>(i=l!=null?S(B(l)):{},K(m||!l||!l.__esModule?_(i,"default",{value:l,enumerable:!0}):i,l));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),R={class:"stripe-elements"},A={key:0,class:"elements-loading"},F={key:1,class:"elements-error"},I={key:2,class:"payment-button-container"},$=["disabled"],x=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(l,{expose:m,emit:i}){const t=l,a=i,v=e.ref(),p=e.ref(!0),o=e.ref(!1),u=e.ref("");let y=null,b=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),E=e.computed(()=>t.amount.toFixed(2)),r=e.computed(()=>{if(t.clientData)try{const s=JSON.parse(t.clientData);return s.clientSecret||s.client_secret}catch{return}}),c=async()=>{if(!v.value)return;let s=t.publishableKey;if(!s&&t.clientData)try{const d=JSON.parse(t.clientData);s=d.publishableKey||d.publishable_key}catch{}if(!s){u.value="Publishable key is required",p.value=!1;return}try{p.value=!0,u.value="";const{loadStripe:d}=await import("@stripe/stripe-js");if(y=await d(s),!y)throw new Error("Failed to load Stripe");const n=r.value,D={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};n&&(D.clientSecret=n),b=y.elements(D),f=b.create("payment",{layout:"tabs",defaultValues:{billingDetails:{name:"",email:"",phone:""}}}),f.mount(v.value),f.on("ready",()=>{p.value=!1,a("ready")}),f.on("change",N=>{N.error?(u.value=N.error.message,a("error",N.error)):u.value=""})}catch(d){u.value=d instanceof Error?d.message:"Failed to initialize payment form",p.value=!1,a("error",d)}},g=async()=>{if(!(!y||!f)){o.value=!0,u.value="";try{const s=t.returnUrl||`${window.location.origin}/payment/return`,{error:d,paymentIntent:n}=await y.confirmPayment({elements:b,confirmParams:{return_url:s},redirect:"if_required"});d?(u.value=d.message||"Payment failed",a("error",d)):n?n.status==="succeeded"?a("success",{paymentIntent:n,status:"succeeded",message:"Payment completed successfully!"}):n.status==="processing"?a("success",{paymentIntent:n,status:"processing",message:"Payment is being processed..."}):a("submit",{paymentIntent:n,status:n.status}):a("submit",f)}catch(s){u.value=s instanceof Error?s.message:"Payment failed",a("error",s)}finally{o.value=!1}}},h=()=>{f&&(f.destroy(),f=null),b&&(b=null),y&&(y=null)};return e.onMounted(()=>{c()}),e.onUnmounted(()=>{h()}),e.watch(()=>t.currency,()=>{h(),c()}),e.watch([()=>t.publishableKey,()=>t.clientData],()=>{(t.publishableKey||t.clientData)&&(h(),c())}),m({destroyElements:h}),(s,d)=>(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("div",{ref_key:"elementsContainer",ref:v,class:"elements-container"},null,512),p.value?(e.openBlock(),e.createElementBlock("div",A,[...d[0]||(d[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",F,[d[1]||(d[1]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(u.value),1),e.createElementVNode("button",{class:"retry-btn",onClick:c}," Retry ")])):e.createCommentVNode("",!0),l.showPayButton&&!p.value&&!u.value?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("button",{disabled:o.value,class:"payment-button",onClick:g},e.toDisplayString(o.value?"Processing...":`Pay ${k.value}${E.value}`),9,$)])):e.createCommentVNode("",!0)]))}}),P=(l,m)=>{const i=l.__vccOpts||l;for(const[t,a]of m)i[t]=a;return i},M=P(x,[["__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(l,{emit:m}){const i=l,t=m,a=e.ref(null),v=()=>{if(!i.clientData)return console.error("No clientData provided"),null;try{const o=JSON.parse(i.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}},p=async()=>{var u;if(!i.clientKey||!a.value){console.error("Initialization failed: Missing clientKey or container.");return}const o=v();if(!o){console.error("Failed to parse session data"),t("error",new Error("Failed to parse session data"));return}try{const{AdyenCheckout:y,Card:b,ApplePay:f,GooglePay:k,Klarna:E,Blik:r,Dropin:c}=await import("@adyen/adyen-web"),g={environment:i.environment||"test",clientKey:i.clientKey,session:o,onPaymentCompleted:(n,D)=>{console.info("Payment Completed:",n,D),t("submit",n),n.resultCode==="Authorised"||n.resultCode==="Received"?(console.info("Payment Successful:",n),t("success",{status:"succeeded",message:"Payment completed successfully",resultCode:n.resultCode,pspReference:n.pspReference,paymentData:n})):n.resultCode==="Pending"?(console.info("Payment Pending:",n),t("success",{status:"processing",message:"Payment is being processed",resultCode:n.resultCode,pspReference:n.pspReference,paymentData:n})):(n.resultCode==="Refused"||n.resultCode==="Error")&&(console.error("Payment Failed:",n),t("error",{message:n.refusalReason||"Payment was declined",resultCode:n.resultCode,paymentData:n}))},onError:(n,D)=>{console.error("Adyen Error:",n.name,n.message,n.stack,D),t("error",n)}},h={showPayButton:!0,paymentMethodComponents:[b,f,k,E,r],paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,billingAddressRequired:!1,enableStoreDetails:!1},applePay:{showPayButton:!0},googlePay:{showPayButton:!0},klarna:{useKlarnaWidget:!0},blik:{}}},s=await y(g);console.log("Adyen Checkout created:",s),console.log("Available payment methods from session:",(u=s.paymentMethodsResponse)==null?void 0:u.paymentMethods);const d=new c(s,h);console.log("Adyen Drop-in created with session payment methods"),a.value&&(d.mount(a.value),console.log("Adyen Drop-in mounted successfully"),t("ready"))}catch(y){console.error("Error creating Adyen Drop-in:",y),t("error",y)}};return e.onMounted(()=>{p()}),e.watch(()=>i.clientData,()=>{a.value&&(a.value.innerHTML="",p())}),(o,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dropinContainer",ref:a,class:"payment-dropin"},null,512))}}),H=P(O,[["__scopeId","data-v-ef2ec054"]]),T={class:"delayed-payment"},z={class:"payment-form"},q={class:"amount-display"},L={class:"amount-value"},J={key:0,class:"session-info"},G={key:0,class:"info-row"},j={class:"value"},W={key:1,class:"info-row"},X={class:"value"},Y={key:1,class:"error-message"},Z={class:"button-container"},Q=["disabled"],ee=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(l,{expose:m,emit:i}){const t=l,a=i,v=e.ref(!1),p=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),y=e.computed(()=>t.amount.toFixed(2)),b=e.computed(()=>o.value.invoiceNumber&&o.value.providerUid),f=()=>{if(!t.clientData){console.error("No clientData provided for delayed payment");return}try{const r=JSON.parse(t.clientData);console.log("Parsed delayed payment session data:",r),o.value={invoiceNumber:r.invoiceNumber,merchantReference:r.merchantReference,providerUid:r.providerUid,paymentUid:r.paymentUid,baseUrl:r.baseUrl},a("ready")}catch(r){console.error("Failed to parse clientData:",r),p.value="Invalid session data",a("error",r)}},k=async()=>{if(!(!b.value||v.value)){v.value=!0,p.value="";try{const r={provider:"delayed-payment",amount:t.amount,currency:t.currency,invoiceNumber:o.value.invoiceNumber,merchantReference:o.value.merchantReference,providerUid:o.value.providerUid,timestamp:new Date().toISOString()};if(a("submit",r),!t.paymentId)throw new Error("Payment ID not provided");const c=o.value.baseUrl||window.location.origin,g={"Content-Type":"application/json"};t.tenantId&&(g["X-Tenant-ID"]=t.tenantId);const h=await fetch(`${c}/api/v1/webhooks/delayed-payments/confirm/${t.paymentId}`,{method:"POST",headers:g});if(!h.ok){const s=await h.text();throw new Error(`Failed to confirm payment: ${s}`)}a("success",{status:"succeeded",message:"Payment confirmed successfully. You will receive a receipt shortly.",resultCode:"Authorised",invoiceNumber:o.value.invoiceNumber,providerUid:o.value.providerUid,paymentData:r})}catch(r){p.value=r instanceof Error?r.message:"Failed to confirm payment",a("error",r)}finally{v.value=!1}}},E=()=>{p.value=""};return e.onMounted(()=>{f()}),m({clearError:E}),(r,c)=>(e.openBlock(),e.createElementBlock("div",T,[e.createElementVNode("div",z,[c[4]||(c[4]=e.createElementVNode("div",{class:"info-section"},[e.createElementVNode("div",{class:"info-icon"}," 📄 "),e.createElementVNode("h3",{class:"info-title"}," Delayed Payment "),e.createElementVNode("p",{class:"info-description"}," Payment will be processed manually via invoice or bank transfer ")],-1)),e.createElementVNode("div",q,[c[0]||(c[0]=e.createElementVNode("span",{class:"amount-label"},"Amount to pay:",-1)),e.createElementVNode("span",L,e.toDisplayString(u.value)+e.toDisplayString(y.value),1)]),b.value?(e.openBlock(),e.createElementBlock("div",J,[o.value.invoiceNumber?(e.openBlock(),e.createElementBlock("div",G,[c[1]||(c[1]=e.createElementVNode("span",{class:"label"},"Invoice Number:",-1)),e.createElementVNode("span",j,e.toDisplayString(o.value.invoiceNumber),1)])):e.createCommentVNode("",!0),o.value.merchantReference?(e.openBlock(),e.createElementBlock("div",W,[c[2]||(c[2]=e.createElementVNode("span",{class:"label"},"Reference:",-1)),e.createElementVNode("span",X,e.toDisplayString(o.value.merchantReference),1)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",Y,[c[3]||(c[3]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(p.value),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Z,[e.createElementVNode("button",{disabled:v.value||!b.value,class:"submit-button",onClick:k},e.toDisplayString(v.value?"Processing...":`Confirm Payment ${u.value}${y.value}`),9,Q)])])]))}}),te=P(ee,[["__scopeId","data-v-cb30346d"]]);exports.AdyenPayment=H;exports.DelayedPayment=te;exports.StripePayment=M;
|
|
1
|
+
"use strict";var S=Object.create;var P=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var R=(s,m,l,t)=>{if(m&&typeof m=="object"||typeof m=="function")for(let a of B(m))!K.call(s,a)&&a!==l&&P(s,a,{get:()=>m[a],enumerable:!(t=V(m,a))||t.enumerable});return s};var C=(s,m,l)=>(l=s!=null?S(w(s)):{},R(m||!s||!s.__esModule?P(l,"default",{value:s,enumerable:!0}):l,s));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),U={class:"stripe-elements"},A={key:0,class:"elements-loading"},F={key:1,class:"elements-error"},I={key:2,class:"payment-button-container"},$=["disabled"],x=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(s,{expose:m,emit:l}){const t=s,a=l,v=e.ref(),p=e.ref(!0),o=e.ref(!1),d=e.ref("");let y=null,b=null,f=null;const D=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)),r=e.computed(()=>{if(t.clientData)try{const i=JSON.parse(t.clientData);return i.clientSecret||i.client_secret}catch{return}}),u=async()=>{if(!v.value)return;let i=t.publishableKey;if(!i&&t.clientData)try{const c=JSON.parse(t.clientData);i=c.publishableKey||c.publishable_key}catch{}if(!i){d.value="Publishable key is required",p.value=!1;return}try{p.value=!0,d.value="";const{loadStripe:c}=await import("@stripe/stripe-js");if(y=await c(i),!y)throw new Error("Failed to load Stripe");const n=r.value,h={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};n&&(h.clientSecret=n),b=y.elements(h),f=b.create("payment",{layout:"tabs",defaultValues:{billingDetails:{name:"",email:"",phone:""}}}),f.mount(v.value),f.on("ready",()=>{p.value=!1,a("ready")}),f.on("change",_=>{_.error?(d.value=_.error.message,a("error",_.error)):d.value=""})}catch(c){d.value=c instanceof Error?c.message:"Failed to initialize payment form",p.value=!1,a("error",c)}},E=async()=>{if(!(!y||!f)){o.value=!0,d.value="";try{const i=t.returnUrl||`${window.location.origin}/payment/return`,{error:c,paymentIntent:n}=await y.confirmPayment({elements:b,confirmParams:{return_url:i},redirect:"if_required"});c?(d.value=c.message||"Payment failed",a("error",c)):n?n.status==="succeeded"?a("success",{paymentIntent:n,status:"succeeded",message:"Payment completed successfully!"}):n.status==="processing"?a("success",{paymentIntent:n,status:"processing",message:"Payment is being processed..."}):a("submit",{paymentIntent:n,status:n.status}):a("submit",f)}catch(i){d.value=i instanceof Error?i.message:"Payment failed",a("error",i)}finally{o.value=!1}}},g=()=>{f&&(f.destroy(),f=null),b&&(b=null),y&&(y=null)};return e.onMounted(()=>{u()}),e.onUnmounted(()=>{g()}),e.watch(()=>t.currency,()=>{g(),u()}),e.watch([()=>t.publishableKey,()=>t.clientData],()=>{(t.publishableKey||t.clientData)&&(g(),u())}),m({destroyElements:g}),(i,c)=>(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",{ref_key:"elementsContainer",ref:v,class:"elements-container"},null,512),p.value?(e.openBlock(),e.createElementBlock("div",A,[...c[0]||(c[0]=[e.createElementVNode("div",{class:"loading-spinner"},null,-1),e.createElementVNode("p",null,"Loading payment form...",-1)])])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",F,[c[1]||(c[1]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{class:"retry-btn",onClick:u}," Retry ")])):e.createCommentVNode("",!0),s.showPayButton&&!p.value&&!d.value?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("button",{disabled:o.value,class:"payment-button",onClick:E},e.toDisplayString(o.value?"Processing...":`Pay ${D.value}${k.value}`),9,$)])):e.createCommentVNode("",!0)]))}}),N=(s,m)=>{const l=s.__vccOpts||s;for(const[t,a]of m)l[t]=a;return l},M=N(x,[["__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(s,{emit:m}){const l=s,t=m,a=e.ref(null),v=()=>{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}},p=async()=>{var d;if(!l.clientKey||!a.value){console.error("Initialization failed: Missing clientKey or container.");return}const o=v();if(!o){console.error("Failed to parse session data"),t("error",new Error("Failed to parse session data"));return}try{const{AdyenCheckout:y,Card:b,ApplePay:f,GooglePay:D,Klarna:k,Blik:r,Dropin:u}=await import("@adyen/adyen-web"),E={environment:l.environment||"test",clientKey:l.clientKey,session:o,onPaymentCompleted:(n,h)=>{console.info("Payment Completed:",n,h),t("submit",n),n.resultCode==="Authorised"||n.resultCode==="Received"?(console.info("Payment Successful:",n),t("success",{status:"succeeded",message:"Payment completed successfully",resultCode:n.resultCode,pspReference:n.pspReference,paymentData:n})):n.resultCode==="Pending"?(console.info("Payment Pending:",n),t("success",{status:"processing",message:"Payment is being processed",resultCode:n.resultCode,pspReference:n.pspReference,paymentData:n})):(n.resultCode==="Refused"||n.resultCode==="Error")&&(console.error("Payment Failed:",n),t("error",{message:n.refusalReason||"Payment was declined",resultCode:n.resultCode,paymentData:n}))},onError:(n,h)=>{console.error("Adyen Error:",n.name,n.message,n.stack,h),t("error",n)}},g={showPayButton:!0,paymentMethodComponents:[b,f,D,k,r],paymentMethodsConfiguration:{card:{hasHolderName:!0,holderNameRequired:!0,billingAddressRequired:!1,enableStoreDetails:!1},applePay:{showPayButton:!0},googlePay:{showPayButton:!0},klarna:{useKlarnaWidget:!0},blik:{}}},i=await y(E);console.log("Adyen Checkout created:",i),console.log("Available payment methods from session:",(d=i.paymentMethodsResponse)==null?void 0:d.paymentMethods);const c=new u(i,g);console.log("Adyen Drop-in created with session payment methods"),a.value&&(c.mount(a.value),console.log("Adyen Drop-in mounted successfully"),t("ready"))}catch(y){console.error("Error creating Adyen Drop-in:",y),t("error",y)}};return e.onMounted(()=>{p()}),e.watch(()=>l.clientData,()=>{a.value&&(a.value.innerHTML="",p())}),(o,d)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dropinContainer",ref:a,class:"payment-dropin"},null,512))}}),H=N(O,[["__scopeId","data-v-ef2ec054"]]),z={class:"delayed-payment"},L={class:"payment-form"},q={class:"amount-display"},J={class:"amount-value"},G={key:0,class:"session-info"},T={key:0,class:"info-row"},j={class:"value"},W={key:1,class:"info-row"},Z={class:"value"},Q={key:1,class:"error-message"},X={class:"button-container"},Y=["disabled"],ee=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(s,{expose:m,emit:l}){const t=s,a=l,v=e.ref(!1),p=e.ref(""),o=e.ref({}),d=e.computed(()=>({EUR:"€",USD:"$",GBP:"£",CHF:"CHF",NOK:"kr",SEK:"kr",DKK:"kr",PLN:"zł"})[t.currency]||t.currency),y=e.computed(()=>t.amount.toFixed(2)),b=e.computed(()=>o.value.invoiceNumber&&o.value.confirmationUrl),f=()=>{if(!t.clientData){console.error("No clientData provided for delayed payment");return}try{const r=JSON.parse(t.clientData);console.log("Parsed delayed payment session data:",r),o.value={invoiceNumber:r.invoiceNumber,merchantReference:r.merchantReference,providerUid:r.providerUid,paymentId:r.paymentId,confirmationUrl:r.confirmationUrl,returnUrl:r.returnUrl},a("ready")}catch(r){console.error("Failed to parse clientData:",r),p.value="Invalid session data",a("error",r)}},D=()=>{if(!(!b.value||v.value)){v.value=!0,p.value="";try{const r={provider:"delayed-payment",amount:t.amount,currency:t.currency,invoiceNumber:o.value.invoiceNumber,merchantReference:o.value.merchantReference,timestamp:new Date().toISOString()};if(a("submit",r),!o.value.confirmationUrl)throw new Error("Confirmation URL not provided");window.location.href=o.value.confirmationUrl}catch(r){p.value=r instanceof Error?r.message:"Failed to confirm payment",a("error",r),v.value=!1}}},k=()=>{p.value=""};return e.onMounted(()=>{f()}),m({clearError:k}),(r,u)=>(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",L,[u[4]||(u[4]=e.createElementVNode("div",{class:"info-section"},[e.createElementVNode("div",{class:"info-icon"}," 📄 "),e.createElementVNode("h3",{class:"info-title"}," Delayed Payment "),e.createElementVNode("p",{class:"info-description"}," Payment will be processed manually via invoice or bank transfer ")],-1)),e.createElementVNode("div",q,[u[0]||(u[0]=e.createElementVNode("span",{class:"amount-label"},"Amount to pay:",-1)),e.createElementVNode("span",J,e.toDisplayString(d.value)+e.toDisplayString(y.value),1)]),b.value?(e.openBlock(),e.createElementBlock("div",G,[o.value.invoiceNumber?(e.openBlock(),e.createElementBlock("div",T,[u[1]||(u[1]=e.createElementVNode("span",{class:"label"},"Invoice Number:",-1)),e.createElementVNode("span",j,e.toDisplayString(o.value.invoiceNumber),1)])):e.createCommentVNode("",!0),o.value.merchantReference?(e.openBlock(),e.createElementBlock("div",W,[u[2]||(u[2]=e.createElementVNode("span",{class:"label"},"Reference:",-1)),e.createElementVNode("span",Z,e.toDisplayString(o.value.merchantReference),1)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",Q,[u[3]||(u[3]=e.createElementVNode("div",{class:"error-icon"}," ⚠️ ",-1)),e.createElementVNode("p",null,e.toDisplayString(p.value),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",X,[e.createElementVNode("button",{disabled:v.value||!b.value,class:"submit-button",onClick:D},e.toDisplayString(v.value?"Processing...":`Confirm Payment ${d.value}${y.value}`),9,Y)])])]))}}),te=N(ee,[["__scopeId","data-v-d0f79a32"]]);exports.AdyenPayment=H;exports.DelayedPayment=te;exports.StripePayment=M;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const $ = { class: "stripe-elements" },
|
|
1
|
+
import { defineComponent as E, ref as _, computed as S, onMounted as A, onUnmounted as I, watch as N, createElementBlock as v, openBlock as b, createElementVNode as o, createCommentVNode as P, toDisplayString as g } from "vue";
|
|
2
|
+
const $ = { class: "stripe-elements" }, B = {
|
|
3
3
|
key: 0,
|
|
4
4
|
class: "elements-loading"
|
|
5
|
-
},
|
|
5
|
+
}, x = {
|
|
6
6
|
key: 1,
|
|
7
7
|
class: "elements-error"
|
|
8
|
-
},
|
|
8
|
+
}, M = {
|
|
9
9
|
key: 2,
|
|
10
10
|
class: "payment-button-container"
|
|
11
|
-
},
|
|
11
|
+
}, O = ["disabled"], H = /* @__PURE__ */ E({
|
|
12
12
|
__name: "StripePayment",
|
|
13
13
|
props: {
|
|
14
14
|
paymentId: {},
|
|
@@ -24,10 +24,10 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
24
24
|
returnUrl: { default: void 0 }
|
|
25
25
|
},
|
|
26
26
|
emits: ["submit", "success", "error", "ready"],
|
|
27
|
-
setup(h, { expose:
|
|
28
|
-
const e = h, a = m, p =
|
|
27
|
+
setup(h, { expose: D, emit: m }) {
|
|
28
|
+
const e = h, a = m, p = _(), u = _(!0), n = _(!1), l = _("");
|
|
29
29
|
let d = null, f = null, y = null;
|
|
30
|
-
const
|
|
30
|
+
const w = S(() => ({
|
|
31
31
|
EUR: "€",
|
|
32
32
|
USD: "$",
|
|
33
33
|
GBP: "£",
|
|
@@ -38,33 +38,33 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
38
38
|
PLN: "zł",
|
|
39
39
|
CZK: "Kč",
|
|
40
40
|
HUF: "Ft"
|
|
41
|
-
})[e.currency] || e.currency), K = S(() => e.amount.toFixed(2)),
|
|
41
|
+
})[e.currency] || e.currency), K = S(() => e.amount.toFixed(2)), r = S(() => {
|
|
42
42
|
if (e.clientData)
|
|
43
43
|
try {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
44
|
+
const s = JSON.parse(e.clientData);
|
|
45
|
+
return s.clientSecret || s.client_secret;
|
|
46
46
|
} catch {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
}),
|
|
49
|
+
}), c = async () => {
|
|
50
50
|
if (!p.value) return;
|
|
51
|
-
let
|
|
52
|
-
if (!
|
|
51
|
+
let s = e.publishableKey;
|
|
52
|
+
if (!s && e.clientData)
|
|
53
53
|
try {
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const i = JSON.parse(e.clientData);
|
|
55
|
+
s = i.publishableKey || i.publishable_key;
|
|
56
56
|
} catch {
|
|
57
57
|
}
|
|
58
|
-
if (!
|
|
59
|
-
|
|
58
|
+
if (!s) {
|
|
59
|
+
l.value = "Publishable key is required", u.value = !1;
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
try {
|
|
63
|
-
u.value = !0,
|
|
64
|
-
const { loadStripe:
|
|
65
|
-
if (d = await
|
|
63
|
+
u.value = !0, l.value = "";
|
|
64
|
+
const { loadStripe: i } = await import("@stripe/stripe-js");
|
|
65
|
+
if (d = await i(s), !d)
|
|
66
66
|
throw new Error("Failed to load Stripe");
|
|
67
|
-
const t =
|
|
67
|
+
const t = r.value, k = {
|
|
68
68
|
appearance: e.appearance || {
|
|
69
69
|
theme: "stripe",
|
|
70
70
|
variables: {
|
|
@@ -80,7 +80,7 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
80
80
|
loader: e.loader,
|
|
81
81
|
locale: e.locale
|
|
82
82
|
};
|
|
83
|
-
t && (
|
|
83
|
+
t && (k.clientSecret = t), f = d.elements(k), y = f.create("payment", {
|
|
84
84
|
layout: "tabs",
|
|
85
85
|
defaultValues: {
|
|
86
86
|
billingDetails: {
|
|
@@ -91,24 +91,24 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
91
91
|
}
|
|
92
92
|
}), y.mount(p.value), y.on("ready", () => {
|
|
93
93
|
u.value = !1, a("ready");
|
|
94
|
-
}), y.on("change", (
|
|
95
|
-
|
|
94
|
+
}), y.on("change", (U) => {
|
|
95
|
+
U.error ? (l.value = U.error.message, a("error", U.error)) : l.value = "";
|
|
96
96
|
});
|
|
97
|
-
} catch (
|
|
98
|
-
|
|
97
|
+
} catch (i) {
|
|
98
|
+
l.value = i instanceof Error ? i.message : "Failed to initialize payment form", u.value = !1, a("error", i);
|
|
99
99
|
}
|
|
100
|
-
},
|
|
100
|
+
}, R = async () => {
|
|
101
101
|
if (!(!d || !y)) {
|
|
102
|
-
n.value = !0,
|
|
102
|
+
n.value = !0, l.value = "";
|
|
103
103
|
try {
|
|
104
|
-
const
|
|
104
|
+
const s = e.returnUrl || `${window.location.origin}/payment/return`, { error: i, paymentIntent: t } = await d.confirmPayment({
|
|
105
105
|
elements: f,
|
|
106
106
|
confirmParams: {
|
|
107
|
-
return_url:
|
|
107
|
+
return_url: s
|
|
108
108
|
},
|
|
109
109
|
redirect: "if_required"
|
|
110
110
|
});
|
|
111
|
-
|
|
111
|
+
i ? (l.value = i.message || "Payment failed", a("error", i)) : t ? t.status === "succeeded" ? a("success", {
|
|
112
112
|
paymentIntent: t,
|
|
113
113
|
status: "succeeded",
|
|
114
114
|
message: "Payment completed successfully!"
|
|
@@ -117,58 +117,58 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
117
117
|
status: "processing",
|
|
118
118
|
message: "Payment is being processed..."
|
|
119
119
|
}) : a("submit", { paymentIntent: t, status: t.status }) : a("submit", y);
|
|
120
|
-
} catch (
|
|
121
|
-
|
|
120
|
+
} catch (s) {
|
|
121
|
+
l.value = s instanceof Error ? s.message : "Payment failed", a("error", s);
|
|
122
122
|
} finally {
|
|
123
123
|
n.value = !1;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
},
|
|
126
|
+
}, C = () => {
|
|
127
127
|
y && (y.destroy(), y = null), f && (f = null), d && (d = null);
|
|
128
128
|
};
|
|
129
129
|
return A(() => {
|
|
130
|
-
|
|
130
|
+
c();
|
|
131
131
|
}), I(() => {
|
|
132
|
-
|
|
133
|
-
}),
|
|
134
|
-
|
|
135
|
-
}),
|
|
136
|
-
(e.publishableKey || e.clientData) && (
|
|
137
|
-
}),
|
|
138
|
-
destroyElements:
|
|
139
|
-
}), (
|
|
132
|
+
C();
|
|
133
|
+
}), N(() => e.currency, () => {
|
|
134
|
+
C(), c();
|
|
135
|
+
}), N([() => e.publishableKey, () => e.clientData], () => {
|
|
136
|
+
(e.publishableKey || e.clientData) && (C(), c());
|
|
137
|
+
}), D({
|
|
138
|
+
destroyElements: C
|
|
139
|
+
}), (s, i) => (b(), v("div", $, [
|
|
140
140
|
o("div", {
|
|
141
141
|
ref_key: "elementsContainer",
|
|
142
142
|
ref: p,
|
|
143
143
|
class: "elements-container"
|
|
144
144
|
}, null, 512),
|
|
145
|
-
u.value ? (b(), v("div",
|
|
145
|
+
u.value ? (b(), v("div", B, [...i[0] || (i[0] = [
|
|
146
146
|
o("div", { class: "loading-spinner" }, null, -1),
|
|
147
147
|
o("p", null, "Loading payment form...", -1)
|
|
148
|
-
])])) :
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
o("p", null,
|
|
148
|
+
])])) : P("", !0),
|
|
149
|
+
l.value ? (b(), v("div", x, [
|
|
150
|
+
i[1] || (i[1] = o("div", { class: "error-icon" }, " ⚠️ ", -1)),
|
|
151
|
+
o("p", null, g(l.value), 1),
|
|
152
152
|
o("button", {
|
|
153
153
|
class: "retry-btn",
|
|
154
|
-
onClick:
|
|
154
|
+
onClick: c
|
|
155
155
|
}, " Retry ")
|
|
156
|
-
])) :
|
|
157
|
-
h.showPayButton && !u.value && !
|
|
156
|
+
])) : P("", !0),
|
|
157
|
+
h.showPayButton && !u.value && !l.value ? (b(), v("div", M, [
|
|
158
158
|
o("button", {
|
|
159
159
|
disabled: n.value,
|
|
160
160
|
class: "payment-button",
|
|
161
|
-
onClick:
|
|
162
|
-
},
|
|
163
|
-
])) :
|
|
161
|
+
onClick: R
|
|
162
|
+
}, g(n.value ? "Processing..." : `Pay ${w.value}${K.value}`), 9, O)
|
|
163
|
+
])) : P("", !0)
|
|
164
164
|
]));
|
|
165
165
|
}
|
|
166
|
-
}), F = (h,
|
|
166
|
+
}), F = (h, D) => {
|
|
167
167
|
const m = h.__vccOpts || h;
|
|
168
|
-
for (const [e, a] of
|
|
168
|
+
for (const [e, a] of D)
|
|
169
169
|
m[e] = a;
|
|
170
170
|
return m;
|
|
171
|
-
}, ne = /* @__PURE__ */ F(H, [["__scopeId", "data-v-adbdf3c5"]]), z = /* @__PURE__ */
|
|
171
|
+
}, ne = /* @__PURE__ */ F(H, [["__scopeId", "data-v-adbdf3c5"]]), z = /* @__PURE__ */ E({
|
|
172
172
|
__name: "AdyenPayment",
|
|
173
173
|
props: {
|
|
174
174
|
paymentId: {},
|
|
@@ -181,8 +181,8 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
181
181
|
onCancel: { type: Function }
|
|
182
182
|
},
|
|
183
183
|
emits: ["submit", "additionalDetails", "error", "ready", "success"],
|
|
184
|
-
setup(h, { emit:
|
|
185
|
-
const m = h, e =
|
|
184
|
+
setup(h, { emit: D }) {
|
|
185
|
+
const m = h, e = D, a = _(null), p = () => {
|
|
186
186
|
if (!m.clientData)
|
|
187
187
|
return console.error("No clientData provided"), null;
|
|
188
188
|
try {
|
|
@@ -199,7 +199,7 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
199
199
|
return console.error("Failed to parse clientData:", n), null;
|
|
200
200
|
}
|
|
201
201
|
}, u = async () => {
|
|
202
|
-
var
|
|
202
|
+
var l;
|
|
203
203
|
if (!m.clientKey || !a.value) {
|
|
204
204
|
console.error("Initialization failed: Missing clientKey or container.");
|
|
205
205
|
return;
|
|
@@ -210,12 +210,12 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
212
|
try {
|
|
213
|
-
const { AdyenCheckout: d, Card: f, ApplePay: y, GooglePay:
|
|
213
|
+
const { AdyenCheckout: d, Card: f, ApplePay: y, GooglePay: w, Klarna: K, Blik: r, Dropin: c } = await import("@adyen/adyen-web"), R = {
|
|
214
214
|
environment: m.environment || "test",
|
|
215
215
|
clientKey: m.clientKey,
|
|
216
216
|
session: n,
|
|
217
|
-
onPaymentCompleted: (t,
|
|
218
|
-
console.info("Payment Completed:", t,
|
|
217
|
+
onPaymentCompleted: (t, k) => {
|
|
218
|
+
console.info("Payment Completed:", t, k), 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
221
|
resultCode: t.resultCode,
|
|
@@ -233,12 +233,12 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
233
233
|
paymentData: t
|
|
234
234
|
}));
|
|
235
235
|
},
|
|
236
|
-
onError: (t,
|
|
237
|
-
console.error("Adyen Error:", t.name, t.message, t.stack,
|
|
236
|
+
onError: (t, k) => {
|
|
237
|
+
console.error("Adyen Error:", t.name, t.message, t.stack, k), e("error", t);
|
|
238
238
|
}
|
|
239
|
-
},
|
|
239
|
+
}, C = {
|
|
240
240
|
showPayButton: !0,
|
|
241
|
-
paymentMethodComponents: [f, y,
|
|
241
|
+
paymentMethodComponents: [f, y, w, K, r],
|
|
242
242
|
paymentMethodsConfiguration: {
|
|
243
243
|
card: {
|
|
244
244
|
hasHolderName: !0,
|
|
@@ -259,37 +259,37 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
259
259
|
// BLIK configuration for Polish market
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
},
|
|
263
|
-
console.log("Adyen Checkout created:",
|
|
264
|
-
const
|
|
265
|
-
console.log("Adyen Drop-in created with session payment methods"), a.value && (
|
|
262
|
+
}, s = await d(R);
|
|
263
|
+
console.log("Adyen Checkout created:", s), console.log("Available payment methods from session:", (l = s.paymentMethodsResponse) == null ? void 0 : l.paymentMethods);
|
|
264
|
+
const i = new c(s, C);
|
|
265
|
+
console.log("Adyen Drop-in created with session payment methods"), a.value && (i.mount(a.value), console.log("Adyen Drop-in mounted successfully"), e("ready"));
|
|
266
266
|
} catch (d) {
|
|
267
267
|
console.error("Error creating Adyen Drop-in:", d), e("error", d);
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
return A(() => {
|
|
271
271
|
u();
|
|
272
|
-
}),
|
|
272
|
+
}), N(() => m.clientData, () => {
|
|
273
273
|
a.value && (a.value.innerHTML = "", u());
|
|
274
|
-
}), (n,
|
|
274
|
+
}), (n, l) => (b(), v("div", {
|
|
275
275
|
ref_key: "dropinContainer",
|
|
276
276
|
ref: a,
|
|
277
277
|
class: "payment-dropin"
|
|
278
278
|
}, null, 512));
|
|
279
279
|
}
|
|
280
|
-
}), ae = /* @__PURE__ */ F(z, [["__scopeId", "data-v-ef2ec054"]]),
|
|
280
|
+
}), ae = /* @__PURE__ */ F(z, [["__scopeId", "data-v-ef2ec054"]]), L = { class: "delayed-payment" }, q = { class: "payment-form" }, J = { class: "amount-display" }, V = { class: "amount-value" }, G = {
|
|
281
281
|
key: 0,
|
|
282
282
|
class: "session-info"
|
|
283
|
-
},
|
|
283
|
+
}, T = {
|
|
284
284
|
key: 0,
|
|
285
285
|
class: "info-row"
|
|
286
|
-
},
|
|
286
|
+
}, W = { class: "value" }, Z = {
|
|
287
287
|
key: 1,
|
|
288
288
|
class: "info-row"
|
|
289
|
-
},
|
|
289
|
+
}, j = { class: "value" }, Q = {
|
|
290
290
|
key: 1,
|
|
291
291
|
class: "error-message"
|
|
292
|
-
},
|
|
292
|
+
}, X = { class: "button-container" }, Y = ["disabled"], ee = /* @__PURE__ */ E({
|
|
293
293
|
__name: "DelayedPayment",
|
|
294
294
|
props: {
|
|
295
295
|
paymentId: { default: void 0 },
|
|
@@ -299,8 +299,8 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
299
299
|
tenantId: { default: void 0 }
|
|
300
300
|
},
|
|
301
301
|
emits: ["submit", "success", "error", "ready"],
|
|
302
|
-
setup(h, { expose:
|
|
303
|
-
const e = h, a = m, p =
|
|
302
|
+
setup(h, { expose: D, emit: m }) {
|
|
303
|
+
const e = h, a = m, p = _(!1), u = _(""), n = _({}), l = S(() => ({
|
|
304
304
|
EUR: "€",
|
|
305
305
|
USD: "$",
|
|
306
306
|
GBP: "£",
|
|
@@ -309,65 +309,41 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
309
309
|
SEK: "kr",
|
|
310
310
|
DKK: "kr",
|
|
311
311
|
PLN: "zł"
|
|
312
|
-
})[e.currency] || e.currency), d = S(() => e.amount.toFixed(2)), f = S(() => n.value.invoiceNumber && n.value.
|
|
312
|
+
})[e.currency] || e.currency), d = S(() => e.amount.toFixed(2)), f = S(() => n.value.invoiceNumber && n.value.confirmationUrl), y = () => {
|
|
313
313
|
if (!e.clientData) {
|
|
314
314
|
console.error("No clientData provided for delayed payment");
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
try {
|
|
318
|
-
const
|
|
319
|
-
console.log("Parsed delayed payment session data:",
|
|
320
|
-
invoiceNumber:
|
|
321
|
-
merchantReference:
|
|
322
|
-
providerUid:
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
const r = JSON.parse(e.clientData);
|
|
319
|
+
console.log("Parsed delayed payment session data:", r), n.value = {
|
|
320
|
+
invoiceNumber: r.invoiceNumber,
|
|
321
|
+
merchantReference: r.merchantReference,
|
|
322
|
+
providerUid: r.providerUid,
|
|
323
|
+
paymentId: r.paymentId,
|
|
324
|
+
confirmationUrl: r.confirmationUrl,
|
|
325
|
+
returnUrl: r.returnUrl
|
|
325
326
|
}, a("ready");
|
|
326
|
-
} catch (
|
|
327
|
-
console.error("Failed to parse clientData:",
|
|
327
|
+
} catch (r) {
|
|
328
|
+
console.error("Failed to parse clientData:", r), u.value = "Invalid session data", a("error", r);
|
|
328
329
|
}
|
|
329
|
-
},
|
|
330
|
+
}, w = () => {
|
|
330
331
|
if (!(!f.value || p.value)) {
|
|
331
332
|
p.value = !0, u.value = "";
|
|
332
333
|
try {
|
|
333
|
-
const
|
|
334
|
+
const r = {
|
|
334
335
|
provider: "delayed-payment",
|
|
335
336
|
amount: e.amount,
|
|
336
337
|
currency: e.currency,
|
|
337
338
|
invoiceNumber: n.value.invoiceNumber,
|
|
338
339
|
merchantReference: n.value.merchantReference,
|
|
339
|
-
providerUid: n.value.providerUid,
|
|
340
340
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
341
341
|
};
|
|
342
|
-
if (a("submit",
|
|
343
|
-
throw new Error("
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
e.tenantId && (k["X-Tenant-ID"] = e.tenantId);
|
|
348
|
-
const g = await fetch(
|
|
349
|
-
`${i}/api/v1/webhooks/delayed-payments/confirm/${e.paymentId}`,
|
|
350
|
-
{
|
|
351
|
-
method: "POST",
|
|
352
|
-
headers: k
|
|
353
|
-
}
|
|
354
|
-
);
|
|
355
|
-
if (!g.ok) {
|
|
356
|
-
const r = await g.text();
|
|
357
|
-
throw new Error(`Failed to confirm payment: ${r}`);
|
|
358
|
-
}
|
|
359
|
-
a("success", {
|
|
360
|
-
status: "succeeded",
|
|
361
|
-
message: "Payment confirmed successfully. You will receive a receipt shortly.",
|
|
362
|
-
resultCode: "Authorised",
|
|
363
|
-
invoiceNumber: n.value.invoiceNumber,
|
|
364
|
-
providerUid: n.value.providerUid,
|
|
365
|
-
paymentData: s
|
|
366
|
-
});
|
|
367
|
-
} catch (s) {
|
|
368
|
-
u.value = s instanceof Error ? s.message : "Failed to confirm payment", a("error", s);
|
|
369
|
-
} finally {
|
|
370
|
-
p.value = !1;
|
|
342
|
+
if (a("submit", r), !n.value.confirmationUrl)
|
|
343
|
+
throw new Error("Confirmation URL not provided");
|
|
344
|
+
window.location.href = n.value.confirmationUrl;
|
|
345
|
+
} catch (r) {
|
|
346
|
+
u.value = r instanceof Error ? r.message : "Failed to confirm payment", a("error", r), p.value = !1;
|
|
371
347
|
}
|
|
372
348
|
}
|
|
373
349
|
}, K = () => {
|
|
@@ -375,44 +351,44 @@ const $ = { class: "stripe-elements" }, x = {
|
|
|
375
351
|
};
|
|
376
352
|
return A(() => {
|
|
377
353
|
y();
|
|
378
|
-
}),
|
|
354
|
+
}), D({
|
|
379
355
|
clearError: K
|
|
380
|
-
}), (
|
|
381
|
-
o("div",
|
|
382
|
-
|
|
356
|
+
}), (r, c) => (b(), v("div", L, [
|
|
357
|
+
o("div", q, [
|
|
358
|
+
c[4] || (c[4] = o("div", { class: "info-section" }, [
|
|
383
359
|
o("div", { class: "info-icon" }, " 📄 "),
|
|
384
360
|
o("h3", { class: "info-title" }, " Delayed Payment "),
|
|
385
361
|
o("p", { class: "info-description" }, " Payment will be processed manually via invoice or bank transfer ")
|
|
386
362
|
], -1)),
|
|
387
|
-
o("div",
|
|
388
|
-
|
|
389
|
-
o("span",
|
|
363
|
+
o("div", J, [
|
|
364
|
+
c[0] || (c[0] = o("span", { class: "amount-label" }, "Amount to pay:", -1)),
|
|
365
|
+
o("span", V, g(l.value) + g(d.value), 1)
|
|
390
366
|
]),
|
|
391
|
-
f.value ? (b(), v("div",
|
|
392
|
-
n.value.invoiceNumber ? (b(), v("div",
|
|
393
|
-
|
|
394
|
-
o("span",
|
|
395
|
-
])) :
|
|
396
|
-
n.value.merchantReference ? (b(), v("div",
|
|
397
|
-
|
|
398
|
-
o("span",
|
|
399
|
-
])) :
|
|
400
|
-
])) :
|
|
401
|
-
u.value ? (b(), v("div",
|
|
402
|
-
|
|
403
|
-
o("p", null,
|
|
404
|
-
])) :
|
|
405
|
-
o("div",
|
|
367
|
+
f.value ? (b(), v("div", G, [
|
|
368
|
+
n.value.invoiceNumber ? (b(), v("div", T, [
|
|
369
|
+
c[1] || (c[1] = o("span", { class: "label" }, "Invoice Number:", -1)),
|
|
370
|
+
o("span", W, g(n.value.invoiceNumber), 1)
|
|
371
|
+
])) : P("", !0),
|
|
372
|
+
n.value.merchantReference ? (b(), v("div", Z, [
|
|
373
|
+
c[2] || (c[2] = o("span", { class: "label" }, "Reference:", -1)),
|
|
374
|
+
o("span", j, g(n.value.merchantReference), 1)
|
|
375
|
+
])) : P("", !0)
|
|
376
|
+
])) : P("", !0),
|
|
377
|
+
u.value ? (b(), v("div", Q, [
|
|
378
|
+
c[3] || (c[3] = o("div", { class: "error-icon" }, " ⚠️ ", -1)),
|
|
379
|
+
o("p", null, g(u.value), 1)
|
|
380
|
+
])) : P("", !0),
|
|
381
|
+
o("div", X, [
|
|
406
382
|
o("button", {
|
|
407
383
|
disabled: p.value || !f.value,
|
|
408
384
|
class: "submit-button",
|
|
409
|
-
onClick:
|
|
410
|
-
},
|
|
385
|
+
onClick: w
|
|
386
|
+
}, g(p.value ? "Processing..." : `Confirm Payment ${l.value}${d.value}`), 9, Y)
|
|
411
387
|
])
|
|
412
388
|
])
|
|
413
389
|
]));
|
|
414
390
|
}
|
|
415
|
-
}), oe = /* @__PURE__ */ F(ee, [["__scopeId", "data-v-
|
|
391
|
+
}), oe = /* @__PURE__ */ F(ee, [["__scopeId", "data-v-d0f79a32"]]);
|
|
416
392
|
export {
|
|
417
393
|
ae as AdyenPayment,
|
|
418
394
|
oe as DelayedPayment,
|