diff --git a/composer.json b/composer.json index ca55fd34..370168bc 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ } ], "description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen", - "version": "4.0.0-rc1", + "version": "4.0.0", "type": "shopware-platform-plugin", "license": "MIT", "require": { diff --git a/src/Resources/app/administration/src/component/adyen-notifications/index.js b/src/Resources/app/administration/src/component/adyen-notifications/index.js index 2e081bf2..ca642489 100644 --- a/src/Resources/app/administration/src/component/adyen-notifications/index.js +++ b/src/Resources/app/administration/src/component/adyen-notifications/index.js @@ -77,8 +77,8 @@ Component.register('adyen-notifications', { } }, - beforeMount() { - this.showWidget = this.adyenService.isAdyenOrder(this.order); + async beforeMount() { + this.showWidget = await this.adyenService.isAdyenOrder(this.order); if (this.showWidget) { this.fetchNotifications(); } diff --git a/src/Resources/app/administration/src/component/adyen-partial-payments/index.js b/src/Resources/app/administration/src/component/adyen-partial-payments/index.js index 66c7dea4..d658ed15 100644 --- a/src/Resources/app/administration/src/component/adyen-partial-payments/index.js +++ b/src/Resources/app/administration/src/component/adyen-partial-payments/index.js @@ -57,9 +57,9 @@ Component.register('adyen-partial-payments', { } }, - beforeMount() { + async beforeMount() { this.isVersionOlderThan65 = VersionHelper.isVersionOlderThan65(); - this.showWidget = this.adyenService.isAdyenOrder(this.order); + this.showWidget = await this.adyenService.isAdyenOrder(this.order); if (this.showWidget) { this.fetchAdyenPartialPayments(); diff --git a/src/Resources/app/administration/src/component/adyen-refund/index.js b/src/Resources/app/administration/src/component/adyen-refund/index.js index cd4639be..af83fa38 100644 --- a/src/Resources/app/administration/src/component/adyen-refund/index.js +++ b/src/Resources/app/administration/src/component/adyen-refund/index.js @@ -120,8 +120,8 @@ Component.register('adyen-refund', { }, }, - beforeMount() { - this.showWidget = this.adyenService.isAdyenOrder(this.order); + async beforeMount() { + this.showWidget = await this.adyenService.isAdyenOrder(this.order); if (this.showWidget) { this.fetchRefunds(); } diff --git a/src/Resources/app/administration/src/service/adyenService.js b/src/Resources/app/administration/src/service/adyenService.js index 9b18b896..5fac02f2 100644 --- a/src/Resources/app/administration/src/service/adyenService.js +++ b/src/Resources/app/administration/src/service/adyenService.js @@ -173,7 +173,7 @@ class ApiClient extends ApiService { }) .catch((error) => { console.error('An error occurred: ' + error.message); - throw error; + return false; }); } diff --git a/src/Resources/public/administration/js/adyen-payment-shopware6.js b/src/Resources/public/administration/js/adyen-payment-shopware6.js index d9c8ce85..9cd8c6db 100644 --- a/src/Resources/public/administration/js/adyen-payment-shopware6.js +++ b/src/Resources/public/administration/js/adyen-payment-shopware6.js @@ -1 +1 @@ -(function(){var e={405:function(){},951:function(){},465:function(){let{Component:e}=Shopware,{Criteria:t}=Shopware.Data;e.extend("sw-entity-single-select-override","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default(){let e=new t(1,this.resultLimit);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},918:function(){let e=Shopware.Classes.ApiService,{Application:t}=Shopware;class n extends e{constructor(e,t,n="adyen"){super(e,t,n),this.headers=this.getBasicHeaders({})}check(t){let n=this.getBasicHeaders({});return this.httpClient.post(`_action/${this.getApiBasePath()}/verify`,t,{headers:n}).then(t=>e.handleResponse(t))}capture(t){return this.httpClient.post(this.getApiBasePath()+"/capture",{orderId:t},{headers:this.headers}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during capture request: "+e.message),e})}getCaptureRequests(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/captures",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during capture request: "+e.message),e})}isCaptureAllowed(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/is-capture-allowed",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during is-capture-allowed request: "+e.message),e})}isManualCaptureEnabled(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/is-manual-capture-enabled",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during is-capture-allowed request: "+e.message),e})}getRefunds(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/refunds",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during refunds request: "+e.message),e})}postRefund(t,n){let a=this.getBasicHeaders({});return this.httpClient.post(this.getApiBasePath()+"/refunds",{orderId:t,refundAmount:n},{headers:a}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during post refund request: "+e.message),e})}fetchNotifications(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/notifications",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}rescheduleNotification(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/reschedule-notification/"+t,{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}isAdyenOrder(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t.id+"/is-adyen-order",{headers:n}).then(t=>e.handleResponse(t)).then(e=>e.status).catch(e=>{throw console.error("An error occurred: "+e.message),e})}fetchAdyenPartialPayments(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/partial-payments",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}}t.addServiceProvider("adyenService",e=>new n(t.getContainer("init").httpClient,e.loginService))},597:function(e,t,n){var a=n(405);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),n(346).Z("252611c6",a,!0,{})},842:function(e,t,n){var a=n(951);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),n(346).Z("3c1af017",a,!0,{})},346:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},s=0;sn.parts.length&&(a.parts.length=n.parts.length)}else{for(var i=[],s=0;s\n Test Configuration\n\n',inject:["adyenService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSaveSuccessful:!1}},computed:{pluginConfig(){let e=this.$parent;for(;void 0===e.actualConfigData;)e=e.$parent;let t=e.currentSalesChannelId,n=e.actualConfigData;return Object.assign({},n.null,n[t])}},methods:{saveFinish(){this.isSaveSuccessful=!1},check(){this.isLoading=!0,this.adyenService.check(this.pluginConfig).then(e=>{e.success?(this.isSaveSuccessful=!0,this.createNotificationSuccess({title:this.$tc("adyen.configTestTitle"),message:this.$tc("adyen.configTestSuccess")})):this.createNotificationError({title:this.$tc("adyen.configTestTitle"),message:this.$tc(e.message?e.message:"adyen.configTestFail")}),this.isLoading=!1})}}}),n(597);let{Component:a,Mixin:s}=Shopware;a.register("adyen-payment-capture",{template:'{% block adyen_capture %}\n \n
\n
\n
\n {{ $tc(\'adyen.noCaptureRequests\') }}\n
\n
\n \n {{ $tc(\'adyen.sendCaptureRequest\') }}\n \n
\n \n \n \n
\n \n \n
\n
\n {{ $tc(\'adyen.error\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService","systemConfigApiService"],mixins:[s.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],showModal:!1,captureRequests:[],allowCapture:!1,captureEnabled:!1,errorOccurred:!1,isLoading:!0,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onSubmitCapture(){this.isLoading=!0,this.adyenService.capture(this.order.id).then(e=>{e.success?(this.fetchCaptureRequests(),this.createNotificationSuccess({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.captureSuccessful")})):this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoading=!1,this.showModal=!1})},fetchCaptureRequests(){this.isLoading=!0,this.adyenService.getCaptureRequests(this.order.id).then(e=>{this.captureRequests=e,this.isCaptureAllowed()}).catch(()=>{this.errorOccurred=!0,this.captureRequests=[]}).finally(()=>{this.isLoading=!1})},isManualCaptureEnabled(){this.isLoading=!0,this.adyenService.isManualCaptureEnabled(this.order.id).then(e=>{this.captureEnabled=e,this.showWidget=this.adyenService.isAdyenOrder(this.order)&&this.captureEnabled}).catch(()=>{this.errorOccurred=!0,this.captureEnabled=!1}).finally(()=>{this.isLoading=!1})},isCaptureAllowed(){this.isLoading=!0,this.adyenService.isCaptureAllowed(this.order.id).then(e=>{this.allowCapture=e}).catch(()=>{this.errorOccurred=!0,this.allowCapture=!1}).finally(()=>{this.isLoading=!1})}},beforeMount(){this.isManualCaptureEnabled(),this.fetchCaptureRequests()}}),n(842);let{Component:r,Mixin:i}=Shopware;r.register("adyen-refund",{template:'{% block adyen_refund %}\n \n
\n
\n
\n {{ $tc(\'adyen.noRefundsCreated\') }}\n
\n
\n \n {{ $tc(\'sw-order.documentCard.labelCreateNew\') }}\n \n
\n \n
\n \n \n
\n \n
\n
\n \n \n
\n
\n {{ $tc(\'adyen.refundFetchError\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[i.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],refundAmount:0,showModal:!1,refunds:[],allowRefund:!0,isLoadingTable:!0,errorOccurred:!1,isLoadingRefund:!1,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onRefund(){this.isLoadingRefund=!0,this.adyenService.postRefund(this.order.id,this.refundAmount).then(e=>{e.success?(this.fetchRefunds(),this.createNotificationSuccess({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.refundSuccessful")})):this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoadingRefund=!1,this.showModal=!1})},fetchRefunds(){this.isLoadingTable=!0,this.adyenService.getRefunds(this.order.id).then(e=>{this.refunds=e,this.isRefundAllowed()}).catch(()=>{this.errorOccurred=!0,this.refunds=[]}).finally(()=>{this.isLoadingTable=!1})},isRefundAllowed(){let e=0;for(let t of this.refunds)"Failed"!==t.status&&(e+=t.rawAmount);this.allowRefund=this.order.amountTotal>e/100}},beforeMount(){this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchRefunds()}});let{Component:d,Mixin:o}=Shopware;d.register("adyen-notifications",{template:'{% block adyen_notifications %}\n
\n \n \n {% block sw_data_grid_body_columns %}\n {% block sw_data_grid_column_actions %}\n \n {% endblock %}\n {% endblock %}\n \n

{{ $tc(\'adyen.noNotificationsReceived\') }}

\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[o.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{notifications:[],columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"eventCode",label:this.$tc("adyen.columnHeaders.event")},{property:"success",label:this.$tc("adyen.columnHeaders.success")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")},{property:"errorCount",label:this.$tc("adyen.columnHeaders.errorCount")},{property:"errorMessage",label:this.$tc("adyen.columnHeaders.errorMessage")}],showWidget:!1}},methods:{fetchNotifications(){this.adyenService.fetchNotifications(this.order.id).then(e=>{this.notifications=e})},onReschedule(e){this.adyenService.rescheduleNotification(e.notificationId).then(e=>{this.createNotificationSuccess({title:this.$tc("adyen.reprocessNotification"),message:this.$tc("adyen.notificationRescheduleSuccess")}),this.fetchNotifications()})}},beforeMount(){this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchNotifications()}});let c={};c.isVersionOlderThan65=()=>{var e,t;return -1===(t="6.5.0.0",(e=Shopware.Context.app.config.version).startsWith(t+"-")?-1:t.startsWith(e+"-")?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"case",caseFirst:"upper"}))};var l=c;let{Component:u}=Shopware;u.register("adyen-partial-payments",{template:'
\n
    \n
    {{ $tc(\'adyen.authorisedPayments\') }}
    \n
    \n {{ payment.pspReference }} -\n {{ payment.method }} -\n {{ payment.amount }}\n
    \n
    {{ errorMessage }}
    \n
\n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n PSP Reference\n
    \n
    \n
    \n Payment Method\n
    \n
    \n
    \n Amount\n
    \n
    \n \n \n
    \n {{ payment.method }}\n
    \n
    \n
    \n {{ payment.amount }}\n
    \n
    \n
    \n
    \n {{ errorMessage }}\n
\n
\n',inject:["adyenService"],props:{order:{type:Object,required:!0}},methods:{fetchAdyenPartialPayments(){this.adyenService.fetchAdyenPartialPayments(this.order.id).then(e=>{e.length>0?this.partialPayments=e:this.errorMessage=this.$tc("adyen.pendingWebhook")})}},data(){return{errorMessage:"",partialPayments:[],showWidget:!1,isVersionOlderThan65:!1}},beforeMount(){this.isVersionOlderThan65=l.isVersionOlderThan65(),this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchAdyenPartialPayments()}}),Shopware.Component.override("sw-order-detail-general",{template:'{% block sw_order_detail_general_line_items_card %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-base",{template:'{% block sw_order_detail_base_custom_fields %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-user-card",{template:'{% block sw_order_detail_base_secondary_info_payment %}\n {% parent %}\n\n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-details",{template:'{% block sw_order_detail_details_payment_method_select %}\n {% parent %}\n\n \n{% endblock %}\n'}),n(465);var h=JSON.parse('{"adyen":{"configTestTitle":"Configuration test","configTestSuccess":"Configuration is successfully tested","configTestFail":"There\'s an issue in your configuration","adyenRefunds":"Adyen Refunds","refundTitle":"Refund","refundSuccessful":"A refund has been successfully submitted.","invalidRefundAmount":"Refund amount exceeds order total","error":"An error has occurred. Please check the logs.","refundFetchError":"An error has occurred while attempting to get linked refunds.","refundConfirm":"Create refund for order","createRefund":"Create Refund","noRefundsCreated":"No refunds created","columnHeaders":{"pspReference":"PSP Reference","amount":"Amount","status":"Status","event":"Event","success":"Success","created":"Created","updated":"Updated","errorCount":"Error Count","errorMessage":"Error Message"},"reprocessNotification":"Reprocess Notification","notificationRescheduleSuccess":"Notification will be processed again.","notificationsTitle":"Adyen Webhook Notifications","noNotificationsReceived":"No webhook notifications received.","adyenPaymentCaptureTitle":"Adyen Capture Requests","noCaptureRequests":"No capture requests have been sent","sendCaptureRequest":"Send Capture Request","captureConfirm":"Capture payment for order","captureSuccessful":"Capture request has been successfully sent","pendingWebhook":"Order is pending webhook.","authorisedPayments":"Authorised Payments"}}');Shopware.Locale.extend("en-GB",h)}()})(); \ No newline at end of file +(function(){var e={405:function(){},951:function(){},465:function(){let{Component:e}=Shopware,{Criteria:t}=Shopware.Data;e.extend("sw-entity-single-select-override","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default(){let e=new t(1,this.resultLimit);return e.addFilter(t.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},918:function(){let e=Shopware.Classes.ApiService,{Application:t}=Shopware;class n extends e{constructor(e,t,n="adyen"){super(e,t,n),this.headers=this.getBasicHeaders({})}check(t){let n=this.getBasicHeaders({});return this.httpClient.post(`_action/${this.getApiBasePath()}/verify`,t,{headers:n}).then(t=>e.handleResponse(t))}capture(t){return this.httpClient.post(this.getApiBasePath()+"/capture",{orderId:t},{headers:this.headers}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during capture request: "+e.message),e})}getCaptureRequests(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/captures",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during capture request: "+e.message),e})}isCaptureAllowed(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/is-capture-allowed",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during is-capture-allowed request: "+e.message),e})}isManualCaptureEnabled(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/is-manual-capture-enabled",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during is-capture-allowed request: "+e.message),e})}getRefunds(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/refunds",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during refunds request: "+e.message),e})}postRefund(t,n){let a=this.getBasicHeaders({});return this.httpClient.post(this.getApiBasePath()+"/refunds",{orderId:t,refundAmount:n},{headers:a}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred during post refund request: "+e.message),e})}fetchNotifications(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/notifications",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}rescheduleNotification(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/reschedule-notification/"+t,{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}isAdyenOrder(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t.id+"/is-adyen-order",{headers:n}).then(t=>e.handleResponse(t)).then(e=>e.status).catch(e=>(console.error("An error occurred: "+e.message),!1))}fetchAdyenPartialPayments(t){let n=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+t+"/partial-payments",{headers:n}).then(t=>e.handleResponse(t)).catch(e=>{throw console.error("An error occurred: "+e.message),e})}}t.addServiceProvider("adyenService",e=>new n(t.getContainer("init").httpClient,e.loginService))},597:function(e,t,n){var a=n(405);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),n(346).Z("252611c6",a,!0,{})},842:function(e,t,n){var a=n(951);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),n(346).Z("3c1af017",a,!0,{})},346:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},s=0;sn.parts.length&&(a.parts.length=n.parts.length)}else{for(var i=[],s=0;s\n Test Configuration\n\n',inject:["adyenService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSaveSuccessful:!1}},computed:{pluginConfig(){let e=this.$parent;for(;void 0===e.actualConfigData;)e=e.$parent;let t=e.currentSalesChannelId,n=e.actualConfigData;return Object.assign({},n.null,n[t])}},methods:{saveFinish(){this.isSaveSuccessful=!1},check(){this.isLoading=!0,this.adyenService.check(this.pluginConfig).then(e=>{e.success?(this.isSaveSuccessful=!0,this.createNotificationSuccess({title:this.$tc("adyen.configTestTitle"),message:this.$tc("adyen.configTestSuccess")})):this.createNotificationError({title:this.$tc("adyen.configTestTitle"),message:this.$tc(e.message?e.message:"adyen.configTestFail")}),this.isLoading=!1})}}}),n(597);let{Component:a,Mixin:s}=Shopware;a.register("adyen-payment-capture",{template:'{% block adyen_capture %}\n \n
\n
\n
\n {{ $tc(\'adyen.noCaptureRequests\') }}\n
\n
\n \n {{ $tc(\'adyen.sendCaptureRequest\') }}\n \n
\n \n \n \n
\n \n \n
\n
\n {{ $tc(\'adyen.error\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService","systemConfigApiService"],mixins:[s.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],showModal:!1,captureRequests:[],allowCapture:!1,captureEnabled:!1,errorOccurred:!1,isLoading:!0,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onSubmitCapture(){this.isLoading=!0,this.adyenService.capture(this.order.id).then(e=>{e.success?(this.fetchCaptureRequests(),this.createNotificationSuccess({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.captureSuccessful")})):this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoading=!1,this.showModal=!1})},fetchCaptureRequests(){this.isLoading=!0,this.adyenService.getCaptureRequests(this.order.id).then(e=>{this.captureRequests=e,this.isCaptureAllowed()}).catch(()=>{this.errorOccurred=!0,this.captureRequests=[]}).finally(()=>{this.isLoading=!1})},isManualCaptureEnabled(){this.isLoading=!0,this.adyenService.isManualCaptureEnabled(this.order.id).then(e=>{this.captureEnabled=e,this.showWidget=this.adyenService.isAdyenOrder(this.order)&&this.captureEnabled}).catch(()=>{this.errorOccurred=!0,this.captureEnabled=!1}).finally(()=>{this.isLoading=!1})},isCaptureAllowed(){this.isLoading=!0,this.adyenService.isCaptureAllowed(this.order.id).then(e=>{this.allowCapture=e}).catch(()=>{this.errorOccurred=!0,this.allowCapture=!1}).finally(()=>{this.isLoading=!1})}},beforeMount(){this.isManualCaptureEnabled(),this.fetchCaptureRequests()}}),n(842);let{Component:r,Mixin:i}=Shopware;r.register("adyen-refund",{template:'{% block adyen_refund %}\n \n
\n
\n
\n {{ $tc(\'adyen.noRefundsCreated\') }}\n
\n
\n \n {{ $tc(\'sw-order.documentCard.labelCreateNew\') }}\n \n
\n \n
\n \n \n
\n \n
\n
\n \n \n
\n
\n {{ $tc(\'adyen.refundFetchError\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[i.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],refundAmount:0,showModal:!1,refunds:[],allowRefund:!0,isLoadingTable:!0,errorOccurred:!1,isLoadingRefund:!1,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onRefund(){this.isLoadingRefund=!0,this.adyenService.postRefund(this.order.id,this.refundAmount).then(e=>{e.success?(this.fetchRefunds(),this.createNotificationSuccess({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.refundSuccessful")})):this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoadingRefund=!1,this.showModal=!1})},fetchRefunds(){this.isLoadingTable=!0,this.adyenService.getRefunds(this.order.id).then(e=>{this.refunds=e,this.isRefundAllowed()}).catch(()=>{this.errorOccurred=!0,this.refunds=[]}).finally(()=>{this.isLoadingTable=!1})},isRefundAllowed(){let e=0;for(let t of this.refunds)"Failed"!==t.status&&(e+=t.rawAmount);this.allowRefund=this.order.amountTotal>e/100}},async beforeMount(){this.showWidget=await this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchRefunds()}});let{Component:d,Mixin:o}=Shopware;d.register("adyen-notifications",{template:'{% block adyen_notifications %}\n
\n \n \n {% block sw_data_grid_body_columns %}\n {% block sw_data_grid_column_actions %}\n \n {% endblock %}\n {% endblock %}\n \n

{{ $tc(\'adyen.noNotificationsReceived\') }}

\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[o.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{notifications:[],columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"eventCode",label:this.$tc("adyen.columnHeaders.event")},{property:"success",label:this.$tc("adyen.columnHeaders.success")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")},{property:"errorCount",label:this.$tc("adyen.columnHeaders.errorCount")},{property:"errorMessage",label:this.$tc("adyen.columnHeaders.errorMessage")}],showWidget:!1}},methods:{fetchNotifications(){this.adyenService.fetchNotifications(this.order.id).then(e=>{this.notifications=e})},onReschedule(e){this.adyenService.rescheduleNotification(e.notificationId).then(e=>{this.createNotificationSuccess({title:this.$tc("adyen.reprocessNotification"),message:this.$tc("adyen.notificationRescheduleSuccess")}),this.fetchNotifications()})}},async beforeMount(){this.showWidget=await this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchNotifications()}});let c={};c.isVersionOlderThan65=()=>{var e,t;return -1===(t="6.5.0.0",(e=Shopware.Context.app.config.version).startsWith(t+"-")?-1:t.startsWith(e+"-")?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"case",caseFirst:"upper"}))};var l=c;let{Component:u}=Shopware;u.register("adyen-partial-payments",{template:'
\n
    \n
    {{ $tc(\'adyen.authorisedPayments\') }}
    \n
    \n {{ payment.pspReference }} -\n {{ payment.method }} -\n {{ payment.amount }}\n
    \n
    {{ errorMessage }}
    \n
\n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n PSP Reference\n
    \n
    \n
    \n Payment Method\n
    \n
    \n
    \n Amount\n
    \n
    \n \n \n
    \n {{ payment.method }}\n
    \n
    \n
    \n {{ payment.amount }}\n
    \n
    \n
    \n
    \n {{ errorMessage }}\n
\n
\n',inject:["adyenService"],props:{order:{type:Object,required:!0}},methods:{fetchAdyenPartialPayments(){this.adyenService.fetchAdyenPartialPayments(this.order.id).then(e=>{e.length>0?this.partialPayments=e:this.errorMessage=this.$tc("adyen.pendingWebhook")})}},data(){return{errorMessage:"",partialPayments:[],showWidget:!1,isVersionOlderThan65:!1}},async beforeMount(){this.isVersionOlderThan65=l.isVersionOlderThan65(),this.showWidget=await this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchAdyenPartialPayments()}}),Shopware.Component.override("sw-order-detail-general",{template:'{% block sw_order_detail_general_line_items_card %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-base",{template:'{% block sw_order_detail_base_custom_fields %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-user-card",{template:'{% block sw_order_detail_base_secondary_info_payment %}\n {% parent %}\n\n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-details",{template:'{% block sw_order_detail_details_payment_method_select %}\n {% parent %}\n\n \n{% endblock %}\n'}),n(465);var h=JSON.parse('{"adyen":{"configTestTitle":"Configuration test","configTestSuccess":"Configuration is successfully tested","configTestFail":"There\'s an issue in your configuration","adyenRefunds":"Adyen Refunds","refundTitle":"Refund","refundSuccessful":"A refund has been successfully submitted.","invalidRefundAmount":"Refund amount exceeds order total","error":"An error has occurred. Please check the logs.","refundFetchError":"An error has occurred while attempting to get linked refunds.","refundConfirm":"Create refund for order","createRefund":"Create Refund","noRefundsCreated":"No refunds created","columnHeaders":{"pspReference":"PSP Reference","amount":"Amount","status":"Status","event":"Event","success":"Success","created":"Created","updated":"Updated","errorCount":"Error Count","errorMessage":"Error Message"},"reprocessNotification":"Reprocess Notification","notificationRescheduleSuccess":"Notification will be processed again.","notificationsTitle":"Adyen Webhook Notifications","noNotificationsReceived":"No webhook notifications received.","adyenPaymentCaptureTitle":"Adyen Capture Requests","noCaptureRequests":"No capture requests have been sent","sendCaptureRequest":"Send Capture Request","captureConfirm":"Capture payment for order","captureSuccessful":"Capture request has been successfully sent","pendingWebhook":"Order is pending webhook.","authorisedPayments":"Authorised Payments"}}');Shopware.Locale.extend("en-GB",h)}()})();