Skip to content

Commit

Permalink
change the sign calculation when the card is saved (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
SzczepaniakG committed Jun 21, 2021
1 parent d2ac794 commit 3c781d5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions tpayLibs/src/_class_tpay/CardApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,29 @@ public function registerSaleMethod(
$params['card'] = $this->cardData;
}
$params = array_merge($params, array(
CardDictionary::NAME => $clientName,
CardDictionary::EMAIL => $clientEmail,
CardDictionary::DESC => $saleDescription,
CardDictionary::NAME => $clientName,
CardDictionary::EMAIL => $clientEmail,
CardDictionary::DESC => $saleDescription,
CardDictionary::AMOUNT => $this->amount,
));
$params[CardDictionary::CURRENCY] = $this->currency;
if (!empty($this->orderID)) {
$params['order_id'] = $this->orderID;
$optionalParams = [
'order_id' => !empty($this->orderID) ? $this->orderID : '',
'onetimer' => $this->oneTimer ? : '',
CardDictionary::LANGUAGE => $this->lang,
'enable_pow_url' => $this->enablePowUrl ? 1 : '',
];
if($this->method === 'register_sale')
{
unset($optionalParams['enable_pow_url']);
}
if ($this->oneTimer) {
$params['onetimer'] = $this->oneTimer;
$params = array_merge($params, $optionalParams);
$params[CardDictionary::SIGN] = hash($this->cardHashAlg, implode('&', $params) . '&' . $this->cardVerificationCode);
foreach ($optionalParams as $optionalParamKey => $optionalParamValue) {
if ($optionalParamValue === '') {
unset($params[$optionalParamKey]);
}
}
$params[CardDictionary::LANGUAGE] = $this->lang;
if ($this->enablePowUrl) {
$params['enable_pow_url'] = 1;
}
$params[CardDictionary::SIGN] = hash($this->cardHashAlg, implode('&', $params) .'&'. $this->cardVerificationCode);
$params[CardDictionary::APIPASS] = $this->cardApiPass;
$params = array_merge($params, $this->checkReturnUrls());
if (!is_null($this->moduleName)) {
Expand Down Expand Up @@ -165,3 +171,4 @@ public function deregisterClient()
return $this->requests($this->cardsApiURL . $this->cardApiKey, $params);
}
}

0 comments on commit 3c781d5

Please sign in to comment.