Skip to content

Commit

Permalink
[Adelante] Deal with timeout in payment query.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Aug 7, 2024
1 parent b488199 commit 2460d7d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions perllib/FixMyStreet/Roles/Cobrand/Adelante.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion perllib/Integrations/Adelante.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 18 additions & 1 deletion t/app/controller/waste_merton_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
7 changes: 7 additions & 0 deletions templates/web/base/waste/pay_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ <h1 class="govuk-error-summary__title">
</div>

[% IF report && (report.get_extra_field_value('payment') > 0 OR report.get_extra_field_value('pro_rata') > 0) %]
[% IF retry_confirmation %]
<form method="GET">
<div class="govuk-form-group">
Press Retry below to retry your payment confirmation
</div>
[% ELSE %]
<form method="POST" action="[% c.uri_for_action('waste/pay_retry') %]">
<input type="hidden" name="id" value="[% report.id %]">
<input type="hidden" name="token" value="[% report.get_extra_metadata('redirect_id') %]">
<div class="govuk-form-group">
Press Retry below to retry your payment for [% report.title %] by credit/debit card
</div>
[% END %]
<div class="govuk-form-group">
<input class="govuk-button" type="submit" value="Retry">
</div>
Expand Down

0 comments on commit 2460d7d

Please sign in to comment.