From ad669fabbbe9f42b7e09620e9f2a23c732b6c693 Mon Sep 17 00:00:00 2001 From: Toon Willems Date: Tue, 22 Oct 2024 17:16:43 +0200 Subject: [PATCH] also send webhook for missing payment provider code --- .../payment_providers/adyen/handle_incoming_webhook_service.rb | 3 +-- app/services/payment_providers/find_service.rb | 2 +- .../adyen/handle_incoming_webhook_service_spec.rb | 2 +- spec/services/payment_providers/find_service_spec.rb | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/services/payment_providers/adyen/handle_incoming_webhook_service.rb b/app/services/payment_providers/adyen/handle_incoming_webhook_service.rb index 60350d37ea5..691fcccffc1 100644 --- a/app/services/payment_providers/adyen/handle_incoming_webhook_service.rb +++ b/app/services/payment_providers/adyen/handle_incoming_webhook_service.rb @@ -41,9 +41,8 @@ def call def handle_payment_provider_failure(payment_provider_result) return payment_provider_result unless payment_provider_result.error.is_a?(BaseService::ServiceFailure) - return payment_provider_result unless payment_provider_result.error.code == 'payment_provider_code_missing' - result.service_failure!(code: 'webhook_error', message: 'Payment provider code is missing') + result.service_failure!(code: 'webhook_error', message: payment_provider_result.error.error_message) end end end diff --git a/app/services/payment_providers/find_service.rb b/app/services/payment_providers/find_service.rb index 32e487cdd77..6f7b4dfcc5b 100644 --- a/app/services/payment_providers/find_service.rb +++ b/app/services/payment_providers/find_service.rb @@ -27,7 +27,7 @@ def call if code.blank? && scope.count > 1 return result.service_failure!( code: 'payment_provider_code_missing', - message: 'Code is missing' + message: 'Payment provider code is missing' ) end diff --git a/spec/services/payment_providers/adyen/handle_incoming_webhook_service_spec.rb b/spec/services/payment_providers/adyen/handle_incoming_webhook_service_spec.rb index 094f0930a11..a16233af1e5 100644 --- a/spec/services/payment_providers/adyen/handle_incoming_webhook_service_spec.rb +++ b/spec/services/payment_providers/adyen/handle_incoming_webhook_service_spec.rb @@ -55,7 +55,7 @@ aggregate_failures do expect(result).not_to be_success expect(result.error).to be_a(BaseService::ServiceFailure) - expect(result.error.code).to eq('payment_provider_not_found') + expect(result.error.code).to eq('webhook_error') expect(result.error.error_message).to eq('Payment provider not found') end end diff --git a/spec/services/payment_providers/find_service_spec.rb b/spec/services/payment_providers/find_service_spec.rb index da3e9510164..5c524fc4ce6 100644 --- a/spec/services/payment_providers/find_service_spec.rb +++ b/spec/services/payment_providers/find_service_spec.rb @@ -82,7 +82,7 @@ expect(result).not_to be_success expect(result.error).to be_a(BaseService::ServiceFailure) expect(result.error.code).to eq('payment_provider_code_missing') - expect(result.error.error_message).to eq('Code is missing') + expect(result.error.error_message).to eq('Payment provider code is missing') end end end