Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sutton] Remove EPDQ payment provider. #5326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,115 +131,6 @@ sub service_name_override {
return $service_name_override{$service->{ServiceId}} // '';
}

sub waste_cc_munge_form_details {
my ($self, $c) = @_;

$c->stash->{payment_amount} = $c->stash->{amount} * 100;

my $url = $c->uri_for_action(
'/waste/pay_complete', [
$c->stash->{report}->id,
$c->stash->{report}->get_extra_metadata('redirect_id')
]);

$c->stash->{redirect_url} = $url;

my ($pspid, $sha_passphrase);
if ($c->stash->{report}->category eq 'Bulky collection') {
$sha_passphrase = $c->stash->{payment_details}->{sha_passphrase_bulky};
$pspid = $c->stash->{payment_details}->{pspid_bulky};
} else {
$sha_passphrase = $c->stash->{payment_details}->{sha_passphrase};
$pspid = $c->stash->{payment_details}->{pspid};
}
$c->stash->{pspid} = $pspid;

my $form_params = {
'PSPID' => $pspid,
'ORDERID' => $c->stash->{reference},
'AMOUNT' => $c->stash->{payment_amount},
'CURRENCY' => 'GBP',
'LANGUAGE' => 'en_GB',
'CN' => $c->stash->{first_name} . " " . $c->stash->{last_name},
'EMAIL' => $c->stash->{email},
'OWNERZIP' => $c->stash->{postcode},
'OWNERADDRESS' => $c->stash->{address1},
'OWNERCTY' => 'UK',
'OWNERTOWN' => $c->stash->{town},
'OWNERTELNO' => $c->stash->{phone},
'ACCEPTURL' => $url,
'DECLINEURL' => $url,
'EXCEPTIONURL' => $url,
'CANCELURL' => $url,
};

my $sha = $self->garden_waste_generate_sig( $form_params, $sha_passphrase );
$c->stash->{cc_sha} = $sha;
}

sub garden_waste_generate_sig {
my ($self, $params, $passphrase) = @_;

my $str = "";
for my $param ( sort { uc($a) cmp uc($b) } keys %$params ) {
next unless defined $params->{$param} && length $params->{$param}; # Want any 0s
$str .= uc($param) . "=" . encode_utf8($params->{$param}) . $passphrase;
}

my $sha = sha1_hex( $str );
return uc $sha;
}

sub waste_cc_has_redirect {
my ($self, $p) = @_;
return 1 if $p->category eq 'Request new container';
return 0;
}

around garden_cc_check_payment_status => sub {
my ($orig, $self, $c, $p) = @_;

if ($p->category eq 'Request new container') {
# Call the SCP role code
return $self->$orig($c, $p);
}

# Otherwise, the EPDQ code

my $passphrase;
if ($p->category eq 'Bulky collection') {
$passphrase = $self->feature('payment_gateway')->{sha_out_passphrase_bulky};
} else {
$passphrase = $self->feature('payment_gateway')->{sha_out_passphrase};
}

if ( $passphrase ) {
my $sha = $c->get_param('SHASIGN');

my %params = %{$c->req->params};
delete $params{SHASIGN};
my $check = $self->garden_waste_generate_sig( \%params, $passphrase );
if ( $check ne $sha ) {
$c->stash->{error} = "Failed security check";
return undef;
}
}

my $status = $c->get_param('STATUS');
if ( $status == 9 ) {
return $c->get_param('PAYID');
} else {
my $error = "Unknown error";
if ( $status == 1 ) {
$error = "Payment cancelled";
} elsif ( $status == 2 ) {
$error = "Payment declined";
}
$c->stash->{error} = $error;
return undef;
}
};

sub waste_request_single_radio_list { 1 }

=head2 waste_munge_request_form_fields
Expand Down
10 changes: 1 addition & 9 deletions t/app/controller/waste_kands_bulky.t
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,6 @@ FixMyStreet::override_config {
$mech->content_contains('Bob Marge', 'name shown');
$mech->content_contains('44 07 111 111 111', 'phone shown');
}
sub test_summary_submission {
# external redirects make Test::WWW::Mechanize unhappy so clone
# the mech for the redirect
my $mech2 = $mech->clone;
$mech2->submit_form_ok({ with_fields => { tandc => 1 } });
is $mech2->res->previous->code, 302, 'payments issues a redirect';
is $mech2->res->previous->header('Location'), "http://example.org/faq", "redirects to payment gateway";
}

subtest 'Summary page' => \&test_summary;

Expand Down Expand Up @@ -409,7 +401,7 @@ FixMyStreet::override_config {
},
] } );

subtest 'Summary submission' => \&test_summary_submission;
$mech->waste_submit_check({ with_fields => { tandc => 1 } });
};

my $catch_email;
Expand Down
Loading