Skip to content

Commit

Permalink
bug(Adyen) - Also send webhook for missing payment provider code (#2728)
Browse files Browse the repository at this point in the history
## Context 

we convert some errors to webhook errors, the payment provider code
missing was not handled like that. This MR changes this, so it's now
also a webhook error.
  • Loading branch information
nudded authored Oct 23, 2024
1 parent 33a68b2 commit 46d9377
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/services/payment_providers/find_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/services/payment_providers/find_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46d9377

Please sign in to comment.