From 2460d7d8cc1898b11bd214ce0654bbb0e3ecdb93 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 7 Aug 2024 21:32:00 +0100 Subject: [PATCH] [Adelante] Deal with timeout in payment query. --- perllib/FixMyStreet/Roles/Cobrand/Adelante.pm | 3 +++ perllib/Integrations/Adelante.pm | 2 +- t/app/controller/waste_merton_garden.t | 19 ++++++++++++++++++- templates/web/base/waste/pay_error.html | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/Roles/Cobrand/Adelante.pm b/perllib/FixMyStreet/Roles/Cobrand/Adelante.pm index 5ae4d366be4..ee2fd29a9b9 100644 --- a/perllib/FixMyStreet/Roles/Cobrand/Adelante.pm +++ b/perllib/FixMyStreet/Roles/Cobrand/Adelante.pm @@ -112,6 +112,9 @@ sub garden_cc_check_payment_status { my ($error, $data) = $self->cc_check_payment_status($reference); if ($error) { + if ($error =~ /Execution Timeout Expired/) { + $c->stash->{retry_confirmation} = 1; + } $c->stash->{error} = $error; return undef; } diff --git a/perllib/Integrations/Adelante.pm b/perllib/Integrations/Adelante.pm index 49ae8129eaa..00c2d209278 100644 --- a/perllib/Integrations/Adelante.pm +++ b/perllib/Integrations/Adelante.pm @@ -102,7 +102,7 @@ sub call { $response = JSON::MaybeXS->new->utf8->decode($response); if ($response->{Result} ne 'OK') { - die $response->{Result}; + die $response->{Result} . "\n"; } return $response; } diff --git a/t/app/controller/waste_merton_garden.t b/t/app/controller/waste_merton_garden.t index a9f14252cec..2fd5d628d80 100644 --- a/t/app/controller/waste_merton_garden.t +++ b/t/app/controller/waste_merton_garden.t @@ -491,7 +491,24 @@ FixMyStreet::override_config { is $sent_params->{items}[0]{amount}, 8978, 'correct amount used'; check_extra_data_pre_confirm($new_report, bin_type => 27); - $mech->get_ok("/waste/pay_complete/$report_id/$token"); + subtest 'Error checking payment confirmation' => sub { + $pay->mock(query => sub { + my $self = shift; + $sent_params = shift; + die "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.\n"; + }); + $mech->get_ok("/waste/pay_complete/$report_id/$token"); + $mech->content_contains('Press Retry below'); + # Set back to original + $pay->mock(query => sub { + my $self = shift; + $sent_params = shift; + return $query_return; + }); + $mech->submit_form_ok({ form_number => 1 }); + $mech->content_contains('Payment successful'); + }; + check_extra_data_post_confirm($new_report); $mech->content_contains('Containers typically arrive within two weeks'); diff --git a/templates/web/base/waste/pay_error.html b/templates/web/base/waste/pay_error.html index 5504004e73c..1bdfbcd93b8 100644 --- a/templates/web/base/waste/pay_error.html +++ b/templates/web/base/waste/pay_error.html @@ -12,12 +12,19 @@

[% IF report && (report.get_extra_field_value('payment') > 0 OR report.get_extra_field_value('pro_rata') > 0) %] + [% IF retry_confirmation %] +
+
+ Press Retry below to retry your payment confirmation +
+ [% ELSE %]
Press Retry below to retry your payment for [% report.title %] by credit/debit card
+ [% END %]