From bc590f08a55b48537be4474c35f148ac9253108c Mon Sep 17 00:00:00 2001 From: 4Giedrius <4giedrius@gmail.com> Date: Thu, 15 Jan 2015 13:40:30 +0200 Subject: [PATCH] Webmoney hashing logic fixes #226 --- src/bb-library/Payment/Adapter/WebMoney.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bb-library/Payment/Adapter/WebMoney.php b/src/bb-library/Payment/Adapter/WebMoney.php index c0116b206..6e2e3d5e0 100644 --- a/src/bb-library/Payment/Adapter/WebMoney.php +++ b/src/bb-library/Payment/Adapter/WebMoney.php @@ -48,6 +48,7 @@ class Payment_Adapter_WebMoney implements \Box\InjectionAwareInterface public function __construct($config) { $this->config = $config; + $this->testMode = (isset($config['test_mode']) && $config['test_mode']) ? true : false; if(!$this->config['purse']) { throw new Payment_Exception('Payment gateway "WebMoney" is not configured properly. Please update configuration parameter "Purse" at "Configuration -> Payment gateways > WebMoney".'); @@ -165,7 +166,7 @@ class Payment_Adapter_WebMoney implements \Box\InjectionAwareInterface * @return string */ private function _getHash($data) { - $string = $data['LMI_PAYEE_PURSE'] . $data['LMI_PAYMENT_AMOUNT'] . $data['LMI_PAYMENT_NO'] . $data['INVOICE_ID']; + $string = $data['LMI_PAYEE_PURSE'] . number_format($data['LMI_PAYMENT_AMOUNT'], 2) . $data['LMI_PAYMENT_NO'] . $data['INVOICE_ID']; if (isset($data['LMI_MODE']) && $data['LMI_MODE'] == 1) { $string .= 'test'; } @@ -234,7 +235,7 @@ class Payment_Adapter_WebMoney implements \Box\InjectionAwareInterface $string .= $data['LMI_PAYER_WM']; } - return strtoupper(MD5($string)); + return strtoupper(hash('sha256', $string)); } /**