Skip to content

Commit

Permalink
fixup! [SLWP] Pass in correct payment meta information.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 8, 2023
1 parent ef50213 commit 10932ee
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
28 changes: 28 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Sutton.pm
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
=head1 NAME
Open311::Endpoint::Integration::UK::Sutton
=head1 DESCRIPTION
The Sutton integration. As well as the boilerplate, and setting it as an Echo
integration, this makes sure the right "Payment Taken By" option is chosen for
bulky collections.
=cut

package Open311::Endpoint::Integration::UK::Sutton;

use Moo;
Expand All @@ -10,4 +22,20 @@ around BUILDARGS => sub {
return $class->$orig(%args);
};

around check_for_data_value => sub {
my ($orig, $class, $name, $args, $request, $parent_name) = @_;

# Bulky items
if ($args->{service_code} eq '1636') {
my $method = $args->{attributes}{payment_method} || '';
if ($method eq 'csc' || $method eq 'cheque') {
return 1 if $name eq 'Payment Taken By'; # Council
} elsif ($method eq 'credit_card') {
return 2 if $name eq 'Payment Taken By'; # Veolia
}
}

return $class->$orig($name, $args, $request, $parent_name);
};

1;
9 changes: 3 additions & 6 deletions perllib/Open311/Endpoint/Role/SLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ around check_for_data_value => sub {
# Default in configuration is Payment Type 1 (Card), Payment Method 2 (Website)
my $method = $args->{attributes}{payment_method} || '';
return 2 if $name eq 'Payment Type' && $method eq 'cheque'; # Cheque
if ($method eq 'csc' || $method eq 'cheque') {
return 1 if $name eq 'Payment Taken By'; # Council
return 1 if $name eq 'Payment Method'; # Borough Phone Payment
} elsif ($method eq 'credit_card') {
return 2 if $name eq 'Payment Taken By'; # Veolia
return 2 if $name eq 'Payment Method'; # Borough Website Payment
if ($name eq 'Payment Method') {
return 1 if $method eq 'csc' || $method eq 'cheque'; # Borough Phone Payment
return 2 if $method eq 'credit_card'; # Borough Website Payment
}
}

Expand Down
2 changes: 1 addition & 1 deletion t/open311/endpoint/kingston.t
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $soap_lite->mock(call => sub {
my $val = $client_ref eq 'bulky-cc' ? 2 : 1;
@payment = ${$data[1]->value}->value;
is $payment[0]->value, 1012;
is $payment[1]->value, $val;
is $payment[1]->value, 1; # Always 1
@payment = ${$data[2]->value}->value;
is $payment[0]->value, 1013;
is $payment[1]->value, $val;
Expand Down
1 change: 1 addition & 0 deletions t/open311/endpoint/kingston.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ service_id_override:
default_data_event_type:
1636:
Payment Type: 1
Payment Taken By: 1
6 changes: 5 additions & 1 deletion t/open311/endpoint/sutton.t
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ $soap_lite->mock(call => sub {
my @method = ${$data[1]->value}->value;
is $method[0]->value, 1010;
is $method[1]->value, 2;
my @by = ${$data[2]->value}->value;
is $by[0]->value, 1011;
is $by[1]->value, 2;
}
return SOAP::Result->new(result => {
EventGuid => '1234',
Expand All @@ -110,6 +113,7 @@ $soap_lite->mock(call => sub {
{ Id => 2002, Name => "Paper" },
{ Id => 1009, Name => "Payment Type" },
{ Id => 1010, Name => "Payment Method" },
{ Id => 1011, Name => "Payment Taken By" },
] },
});
} else {
Expand Down Expand Up @@ -185,7 +189,7 @@ subtest "POST bulky collection OK" => sub {
my $res = $endpoint->run_test_request(@params,
service_code => EVENT_TYPE_BULKY,
'attribute[fixmystreet_id]' => 2000126,
'attribute[LastPayMethod]' => 2,
'attribute[payment_method]' => 'credit_card',
);
ok $res->is_success, 'valid request'
or diag $res->content;
Expand Down

0 comments on commit 10932ee

Please sign in to comment.