From 2e49d609c35ec94e1cdb2c1e1c72b7c2a28e3724 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 31 Aug 2023 16:54:54 +0100 Subject: [PATCH] [Waste] Option to confirm bulky before payment. This can be used in situations where the backend lets you then confirm that payment has been successful. --- perllib/FixMyStreet/App/Controller/Waste.pm | 4 +++- perllib/FixMyStreet/App/Controller/Waste/Bulky.pm | 3 ++- perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm index b3fa2b91e1f..adbbbd520c1 100644 --- a/perllib/FixMyStreet/App/Controller/Waste.pm +++ b/perllib/FixMyStreet/App/Controller/Waste.pm @@ -266,8 +266,10 @@ sub confirm_subscription : Private { $c->stash->{property_id} = $p->get_extra_field_value('property_id'); + my $already_confirmed; if ($p->category eq 'Bulky collection') { $c->stash->{template} = 'waste/bulky/confirmation.html'; + $already_confirmed = $c->cobrand->bulky_send_before_payment; } else { $c->stash->{template} = 'waste/garden/subscribe_confirm.html'; } @@ -277,7 +279,7 @@ sub confirm_subscription : Private { # rather than the default 'done' form one $c->stash->{override_template} = $c->stash->{template}; - return unless $p->state eq 'unconfirmed'; + return unless $p->state eq 'unconfirmed' || $already_confirmed; $p->update_extra_field( { name => 'LastPayMethod', diff --git a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm index 2fce099b90b..bbc4b8404be 100644 --- a/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm +++ b/perllib/FixMyStreet/App/Controller/Waste/Bulky.pm @@ -222,7 +222,8 @@ sub process_bulky_data : Private { amend_extra_data($c, $c->stash->{report}, $data); $c->stash->{report}->update; } else { - $c->forward('/waste/add_report', [ $data, 1 ]) or return; + my $no_confirm = !$c->cobrand->bulky_send_before_payment; + $c->forward('/waste/add_report', [ $data, $no_confirm ]) or return; } if ( FixMyStreet->staging_flag('skip_waste_payment') ) { $c->stash->{message} = 'Payment skipped on staging'; diff --git a/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm b/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm index 9d6b3fd4821..e345dadb582 100644 --- a/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm +++ b/perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm @@ -475,4 +475,6 @@ sub _bulky_send_reminder_email { } } +sub bulky_send_before_payment { 0 } + 1;