Skip to content

Commit

Permalink
Fix capture quote_id in Redsys callback and fix float amount comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
oriolauge committed May 25, 2022
1 parent d39f6d5 commit 148b6d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Controller/Callback/Processpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function getQuote(array $merchantParameters)
}

$merchantData = json_decode(
htmlspecialchars_decode($merchantParameters['Ds_MerchantData']),
urldecode($merchantParameters['Ds_MerchantData']),
true
);

Expand Down
2 changes: 1 addition & 1 deletion Model/MerchantParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function execute(Quote $quote): string
'Ds_Merchant_ConsumerLanguage' => $this->language->getLanguageByCode($codeLanguage),
'Ds_Merchant_ProductDescription' => $this->productDescription->execute($quote),
'Ds_Merchant_PayMethods' => 'C',
'Ds_Merchant_MerchantData' => json_encode(['quote_id' => $quote->getId()]),
'Ds_Merchant_MerchantData' => json_encode(['quote_id' => $quote->getId()])
];

if (!empty($merchantName) && strlen($merchantName) <= ConfigInterface::MERCHANT_NAME_MAX_LENGTH) {
Expand Down
6 changes: 3 additions & 3 deletions Model/MerchantParameters/TotalAmount.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class TotalAmount
* Convert amount to Redsys format
*
* @param CartInterface $quote
* @return float
* @return string
*/
public function execute(CartInterface $quote): float
public function execute(CartInterface $quote): string
{
return floatval($quote->getGrandTotal()) * 100;
return number_format($quote->getGrandTotal(), 2, '', '');
}
}

0 comments on commit 148b6d5

Please sign in to comment.