diff --git a/Model/Api/Base.php b/Model/Api/Base.php index a0ad9ad..0e48913 100644 --- a/Model/Api/Base.php +++ b/Model/Api/Base.php @@ -82,10 +82,10 @@ public function sendRequest($data, $cmd, $headers = [], $method = 'post', $assoc { $paymentConf = $this->getPaymentConfig(); $baseConf = $this->getBaseConfig(); - + $paymentConf['public_key'] = isset($paymentConf['public_key']) ? $paymentConf['public_key'] : ''; $paymentConf['api_version'] = isset($paymentConf['api_version']) ? $paymentConf['api_version'] : '1'; - + $additionalData = [ 'version' => $baseConf['api_version'], 'cmd' => $cmd, @@ -112,7 +112,7 @@ public function sendRequest($data, $cmd, $headers = [], $method = 'post', $assoc public function generateHmac($data, $secretKey = null) { if (!$secretKey) { - $secretKey = $this->getPaymentConfig('secret_key'); + $secretKey = $this->getPaymentConfig('secret_key') ?: ''; } return hash_hmac('sha512', http_build_query($data), $secretKey); } diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 19cda93..6f85c01 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -68,22 +68,27 @@ public function getConfig() $this->_curl->post($coinpaymentsApi, $data); $response = json_decode($this->_curl->getBody()); - $currencies = ['error' => $response->error]; - $acceptedCurrencies = ['error' => $response->error]; - if ($response->error == 'ok') { - $currencies = []; - $acceptedCurrencies = []; - foreach ($response->result as $key => $item) { - $elm = [ - 'value' => $key, - 'body' => $item, - 'name' => $item->name - ]; - $currencies[] = $elm; - if (isset($item->accepted) && $item->accepted == '1') { - $acceptedCurrencies[] = $elm; + if (!is_null($response) && property_exists($response, 'error') && property_exists($response, 'result')) { + $currencies = ['error' => $response->error]; + $acceptedCurrencies = ['error' => $response->error]; + if ($response->error == 'ok') { + $currencies = []; + $acceptedCurrencies = []; + foreach ($response->result as $key => $item) { + $elm = [ + 'value' => $key, + 'body' => $item, + 'name' => $item->name + ]; + $currencies[] = $elm; + if (isset($item->accepted) && $item->accepted == '1') { + $acceptedCurrencies[] = $elm; + } } } + } else { + $currencies = ['error' => 'Could not load currencies list.']; + $acceptedCurrencies = ['error' => 'Could not load currencies list.']; } return [ diff --git a/composer.json b/composer.json index 4c3ba09..e4b7e45 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "coinpaymentsnet/magento2", "description": "Add new payment method for CoinPayments.net", "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1" + "php": "~5.5.0|~5.6.0|~7.0.0|~7.1|~8.0|~8.1|~8.2" }, "type": "magento2-module", - "version": "1.6.0", + "version": "1.6.3", "license": [ "OSL-3.0" ], diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 1e575cd..d64827f 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -52,6 +52,10 @@ Magento\Payment\Model\Config\Source\Allspecificcountries + + + validate-number + Magento\Directory\Model\Config\Source\Country diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml new file mode 100644 index 0000000..2b7a8fa --- /dev/null +++ b/etc/csp_whitelist.xml @@ -0,0 +1,10 @@ + + + + + + https://www.coinpayments.net + + + + diff --git a/view/frontend/templates/coinpayments/iframe.phtml b/view/frontend/templates/coinpayments/iframe.phtml index 7a98c57..8714a38 100644 --- a/view/frontend/templates/coinpayments/iframe.phtml +++ b/view/frontend/templates/coinpayments/iframe.phtml @@ -26,8 +26,8 @@ $failUrl = $block->getFailUrl(); 'utf-8' ); ?>"> - - + + @@ -50,4 +50,4 @@ $failUrl = $block->getFailUrl(); \ No newline at end of file + diff --git a/view/frontend/templates/coinpayments/status.phtml b/view/frontend/templates/coinpayments/status.phtml index a1d1918..a6cbc47 100644 --- a/view/frontend/templates/coinpayments/status.phtml +++ b/view/frontend/templates/coinpayments/status.phtml @@ -4,8 +4,8 @@ $currency = $block->getTransactionCurrency(); ?>
-

Your order # is: getLastOrderIncrementId(); ?>.

-

We'll email you an order confirmation with details and tracking info.

+

getLastOrderIncrementId(); ?>.

+

error == 'ok') : ?>

Status link

diff --git a/view/frontend/web/js/view/payment/method-renderer/coin-method.js b/view/frontend/web/js/view/payment/method-renderer/coin-method.js index d41acf6..837c57f 100644 --- a/view/frontend/web/js/view/payment/method-renderer/coin-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/coin-method.js @@ -237,7 +237,7 @@ define( window.location.replace(redirect); } }, - error: function (err) { + error: function (error) { console.log(error); if (redirect) { window.location.replace(redirect); diff --git a/view/frontend/web/template/payment/coin_payment.html b/view/frontend/web/template/payment/coin_payment.html index a89c2ba..10ede24 100644 --- a/view/frontend/web/template/payment/coin_payment.html +++ b/view/frontend/web/template/payment/coin_payment.html @@ -22,7 +22,7 @@
-              +
-                   +
@@ -55,4 +55,4 @@
- \ No newline at end of file +