Skip to content

Undefined index: u_predcislo #3

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 25 additions & 3 deletions src/SporoPay/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,33 @@ public function getData()
{
$sharedSecret = $this->getParameter('sharedSecret');

$data = "{$_GET['u_predcislo']};{$_GET['u_cislo']};{$_GET['u_kbanky']};{$_GET['pu_predcislo']};{$_GET['pu_cislo']};{$_GET['pu_kbanky']};{$_GET['suma']};{$_GET['mena']};{$_GET['vs']};{$_GET['ss']};{$_GET['url']};{$_GET['param']};{$_GET['result']};{$_GET['real']}";
$data = [];
$getParams = ['u_predcislo', 'u_cislo', 'u_kbanky', 'pu_predcislo', 'pu_cislo', 'pu_kbanky', 'suma', 'mena', 'vs', 'ss', 'url', /*'param',*/ 'result', 'real'];
foreach ($getParams as $getParam){
if(!isset($_GET[$getParam])){
throw new InvalidRequestException(sprintf('one of the input parameters is missing: %1$s', $getParam));
}

$data[$getParam] = $_GET[$getParam];
}

$dataString = implode(';', $data);
$sign = new Des3Sign();

if ($sign->sign($data, $sharedSecret) != $_GET['SIGN2']) {
throw new InvalidRequestException('incorect signature');
if(!isset($_GET['SIGN2'])){
throw new InvalidRequestException(sprintf('missing input parameter: SIGN2', $getParam));
}

if ($sign->sign($dataString, $sharedSecret) != $_GET['SIGN2']) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this SIGN2 GET parameter is provided in this case when other parameter are missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I've added the condition too.

// Ještě to zkusím s prázdným parametrem 'param', který dřív posílali - ale musím ho vložit na správnou pozici - před 'result'.
// Implode se dělá jen z hodnot, takže je vlastně jedno, jak pojmenuju ten vložený parametr. Ale nechám tam param, když tam dřív býval ...
$pos = array_search('result', array_keys($data));
$data2 = array_slice($data, 0, $pos, true) + array('param' => '') + array_slice($data, $pos, count($data)-$pos, true);
$dataString2 = implode(';', $data2);

if ($sign->sign($dataString2, $sharedSecret) != $_GET['SIGN2']) {
throw new InvalidRequestException('incorect signature');
}
}

return [
Expand Down