-
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
Open
pawellen
wants to merge
27
commits into
ETSGlobal:master
Choose a base branch
from
pawellen:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
50dc295
Update composer.json
pawellen 6ea700c
Update composer.json
pawellen 14f579d
Update composer.json
pawellen 35fb47c
bee7740
9982b4d
241ef7b
aaac29e
04dacfb
437cef6
6dd9caf
56268ef
87c5dbe
added recipientChk suppord for dotpay recipientParameters
6cab675
allow recipient fields
5c76185
onlinetransfer parameter support
32627d6
onlinetransfer parameter support, 1 bugfix
b4253c5
added support of fields street_n1, street_n2
13c9ea0
Update DotpayDirectPlugin.php
pawellen 2f4609e
Update String.php
pawellen 3f9e588
transaction amount is now taken from amount parameter
pawellen d3d0e1c
small text - bugfix
pawellen 4dc8c92
logging t_id
pawellen b2fa1c3
logging t_id - fix
pawellen 31db77a
expirationDate parameter
b7bb34c
expirationDate parameter - fix
677b990
fail information
bae30ed
return url to uppercase
pawellen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,22 +89,48 @@ class DotpayDirectPlugin extends AbstractPlugin | |
*/ | ||
protected $type; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $chk; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $recipientChk; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $onlineTransfer; | ||
|
||
/** | ||
* @var integer | ||
*/ | ||
protected $expirationTime; | ||
|
||
|
||
/** | ||
* @param Router $router The router | ||
* @param Token $token The client token | ||
* @param String $stringTools The String tool package | ||
* @param string $url The urlc | ||
* @param integer $type The type | ||
* @param string $returnUrl The return url | ||
* @param boolean $returnUrl Using DotPay CHK parameter, by default false | ||
*/ | ||
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, $recipientChk = false, $onlineTransfer = false, $expirationTime = 0) | ||
{ | ||
$this->router = $router; | ||
$this->token = $token; | ||
$this->stringTools = $stringTools; | ||
$this->returnUrl = $returnUrl; | ||
$this->url = $url; | ||
$this->type = $type; | ||
$this->chk = $chk; | ||
$this->recipientChk = $recipientChk; | ||
$this->onlineTransfer = $onlineTransfer; | ||
$this->expirationTime = $expirationTime; | ||
} | ||
|
||
/** | ||
|
@@ -148,19 +174,29 @@ public function createDotpayRedirectActionException(FinancialTransactionInterfac | |
|
||
$datas = array( | ||
'id' => $this->token->getId(), | ||
'url' => $this->getReturnUrl($extendedData), | ||
'URL' => $this->getReturnUrl($extendedData), | ||
'URLC' => $urlc, | ||
'type' => $this->type, | ||
'onlinetransfer' => $this->onlineTransfer ? 1 : 0, | ||
|
||
'amount' => $transaction->getRequestedAmount(), | ||
'currency' => $instruction->getCurrency(), | ||
'description' => sprintf('Payment Instruction #%d', $instruction->getId()), | ||
|
||
'data_waznosci' => $this->expirationTime > 0 ? date('Y-m-d H:i:s', time() + $this->expirationTime * 60) : null, | ||
'data_zapadalnosci' => null | ||
); | ||
|
||
$additionalDatas = array( | ||
'street', 'phone', 'postcode', 'lastname', | ||
'firstname', 'email', 'country', 'city', 'grupykanalow', | ||
'street', 'phone', 'postcode', 'lastname', 'firstname', | ||
'email', 'country', 'city', 'grupykanalow', 'street_n1', 'street_n2', 'description' | ||
); | ||
if ($this->recipientChk) { | ||
$additionalDatas = array_merge($additionalDatas, array( | ||
'recipientAccountNumber', 'recipientCompany', 'recipientFirstName', 'recipientLastName', 'recipientAddressStreet', | ||
'recipientAddressBuilding', 'recipientAddressApartment', 'recipientAddressPostcode', 'recipientAddressCity' | ||
)); | ||
} | ||
|
||
foreach ($additionalDatas as $value) { | ||
if ($extendedData->has($value)) { | ||
|
@@ -172,10 +208,101 @@ public function createDotpayRedirectActionException(FinancialTransactionInterfac | |
$datas['lang'] = substr($extendedData->get('lang'), 0, 2); | ||
} | ||
|
||
if ($this->recipientChk) { | ||
$datas['recipientChk'] = $this->generateRecipientChk($datas, $this->token->getPin()); | ||
} | ||
|
||
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']; | ||
$key .= number_format($datas['amount'], 2, '.', ''); | ||
$key .= $datas['currency']; | ||
$key .= rawurlencode($datas['description']); | ||
|
||
if (isset($datas['control'])) { | ||
$key .= $datas['control']; | ||
} | ||
|
||
$key .= $pin; | ||
|
||
if (isset($datas['channel'])) { | ||
$key .= $datas['channel']; | ||
|
||
if (isset($datas['chlock'])) { | ||
$key .= $datas['chlock']; | ||
} | ||
} | ||
|
||
if (isset($datas['data_waznosci'])) { | ||
|
||
if (isset($datas['data_zapadalnosci'])) { | ||
$key .= $datas['data_zapadalnosci']; | ||
} | ||
|
||
$key .= $datas['data_waznosci']; | ||
} | ||
|
||
if (isset($datas['recipientChk'])) { | ||
$key .= $datas['recipientChk']; | ||
} | ||
|
||
|
||
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 generates recipientChk parameter user to sign request with recipient data to dotpay | ||
* | ||
* @param array $datas | ||
* @param string $pin | ||
*/ | ||
protected function generateRecipientChk(array $datas, $pin) | ||
{ | ||
$key = $datas['id']; | ||
$key .= number_format($datas['amount'], 2, '.', ''); | ||
$key .= $datas['currency']; | ||
|
||
if (isset($datas['control'])) { | ||
$key .= $datas['control']; | ||
} | ||
|
||
$recipientFields = array( | ||
'recipientAccountNumber', | ||
'recipientCompany', | ||
'recipientFirstName', | ||
'recipientLastName', | ||
'recipientAddressStreet', | ||
'recipientAddressBuilding', | ||
'recipientAddressApartment', | ||
'recipientAddressPostcode', | ||
'recipientAddressCity' | ||
); | ||
foreach ($recipientFields as $f) { | ||
if (isset($datas[$f])) { | ||
$key .= $datas[$f]; | ||
} | ||
} | ||
|
||
$key .= $pin; | ||
|
||
return hash( 'sha256', $key); | ||
} | ||
|
||
/** | ||
* This method executes an approve transaction. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add the parameter to the param list