Steps to Reproduce:
Send request to the Spree::Api::V2::Storefront::IntentsController#handle_response endpoint.
In some cases, the params['response'] parameter is sent as nil in the request payload.
Expected Behavior:
I expect the handle_response method to gracefully handle cases where params['response'] is nil, preventing a NoMethodError. Instead of raising an error, the method should handle this scenario and respond appropriately.
Actual Behavior:
When params['response'] is nil, a NoMethodError is raised in the Spree::Api::V2::Storefront::IntentsController#handle_response method when attempting to access nested attributes. This can be seen in the server logs:
NoMethodError Spree::Api::V2::Storefront::IntentsController#handle_response
undefined method `[]' for nil:NilClass
def handle_response
if params['response']['error']
invalidate_payment
render_error_payload(params['response']['error']['message'])
else
render_serialized_payload { { message: I18n.t('spree.payment_successfully_authorized') } }
end
end
Screenshots:

Additional Context:
This issue occurs intermittently and is challenging to reproduce consistently. It seems to be related to scenarios where the expected response structure is not received.
Thanks.
Steps to Reproduce:
Send request to the
Spree::Api::V2::Storefront::IntentsController#handle_responseendpoint.In some cases, the params['response'] parameter is sent as nil in the request payload.
Expected Behavior:
I expect the handle_response method to gracefully handle cases where params['response'] is nil, preventing a NoMethodError. Instead of raising an error, the method should handle this scenario and respond appropriately.
Actual Behavior:
When params['response'] is nil, a NoMethodError is raised in the
Spree::Api::V2::Storefront::IntentsController#handle_responsemethod when attempting to access nested attributes. This can be seen in the server logs:Code Snippets:
Screenshots:
Additional Context:
This issue occurs intermittently and is challenging to reproduce consistently. It seems to be related to scenarios where the expected response structure is not received.
Thanks.