-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added dotpay CHK parameter support and Symfony version requirments. #3
base: master
Are you sure you want to change the base?
Changes from 10 commits
50dc295
6ea700c
14f579d
35fb47c
bee7740
9982b4d
241ef7b
aaac29e
04dacfb
437cef6
6dd9caf
56268ef
87c5dbe
6cab675
5c76185
32627d6
b4253c5
13c9ea0
2f4609e
3f9e588
d3d0e1c
4dc8c92
b2fa1c3
31db77a
b7bb34c
677b990
bae30ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,12 @@ class DotpayDirectPlugin extends AbstractPlugin | |
*/ | ||
protected $type; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $chk; | ||
|
||
|
||
/** | ||
* @param Router $router The router | ||
* @param Token $token The client token | ||
|
@@ -97,14 +103,15 @@ class DotpayDirectPlugin extends AbstractPlugin | |
* @param integer $type The type | ||
* @param string $returnUrl The return url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the parameter to the param list |
||
*/ | ||
public function __construct(Router $router, Token $token, String $stringTools, $url, $type, $returnUrl) | ||
public function __construct(Router $router, Token $token, String $stringTools, $url, $type, $returnUrl, $chk = false) | ||
{ | ||
$this->router = $router; | ||
$this->token = $token; | ||
$this->stringTools = $stringTools; | ||
$this->returnUrl = $returnUrl; | ||
$this->url = $url; | ||
$this->type = $type; | ||
$this->chk = $chk ? true : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is useless, you already validated by the configuration that this value is a boolean. |
||
} | ||
|
||
/** | ||
|
@@ -171,11 +178,37 @@ public function createDotpayRedirectActionException(FinancialTransactionInterfac | |
if ($extendedData->has('lang')) { | ||
$datas['lang'] = substr($extendedData->get('lang'), 0, 2); | ||
} | ||
|
||
if ($this->chk) { | ||
$datas['chk'] = $this->generateChk($datas, $this->token->getPin()); | ||
} | ||
|
||
$actionRequest->setAction(new VisitUrl($this->url . '?' . http_build_query($datas))); | ||
|
||
return $actionRequest; | ||
} | ||
|
||
/** | ||
* This method generates chk parameter user to sign request to dotpay | ||
* | ||
* @param array $datas | ||
* @param string $pin | ||
*/ | ||
protected function generateChk(array $datas, $pin) | ||
{ | ||
$key = $datas['id']. | ||
number_format($datas['amount'], 2, '.', ''). | ||
$datas['currency']. | ||
rawurlencode($datas['description']). | ||
(isset($datas['control']) ? $datas['control'] : ''). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be more readable in this function please. protected function generateChk(array $datas, $pin)
{
$key = $datas['id'];
$key .= number_format($datas['amount'], 2, '.', '');
$key .= $datas['currency'];
$key .= rawurlencode($datas['description']);
if (isset($datas['control']) {
$key .= $datas['control'];
}
if (isset($datas['channel'])) {
$key .= $datas['channel'];
if (isset($datas['chlock'])) {
$key .= $datas['chlock'];
}
}
return md5($key);
} |
||
$pin; | ||
|
||
if (isset($datas['channel'])) { | ||
$key .= $datas['channel']. | ||
(isset($datas['chlock']) ? $datas['chlock'] : ''); | ||
} | ||
return md5($key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a blank line before the return statement |
||
} | ||
|
||
/** | ||
* This method executes an approve transaction. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this node is a boolean you should validate using
booleanNode
instead ofscalarNode