From a259dfa2920d4f8ffd355ef29237b3f1fa344b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Sat, 29 Sep 2018 17:47:19 -0400 Subject: [PATCH 001/107] Plugin updates --- .gitignore | 2 + Controller/Ipn/Index.php | 44 +------------------ README.md | 44 +++++++++++++------ etc/adminhtml/system.xml | 8 +--- .../coinpayments/form/coinpayments.phtml | 1 - .../templates/coinpayments/iframe.phtml | 2 +- .../templates/coinpayments/redirect.phtml | 29 +----------- 7 files changed, 38 insertions(+), 92 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b9bd87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.bak diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index f664589..5e66954 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -61,7 +61,7 @@ public function execute() $order_id = (int)$this->getRequest()->getParam('invoice'); if ($order = $this->orderRepository->get($order_id)) { if ($order->getState() == Order::STATE_NEW) { - if ($this->getRequest()->getParam('ipn_type') == 'button') { + if ($this->getRequest()->getParam('ipn_type') == 'button' || $this->getRequest()->getParam('ipn_type') == 'simple') { if ($this->getRequest()->getParam('currency1') == $order->getBaseCurrencyCode()) { if ($this->getRequest()->getParam('amount1') >= $order->getBaseGrandTotal()) { $status = (int)$this->getRequest()->getParam('status'); @@ -171,13 +171,7 @@ private function is_ipn_valid() return true; } } else { - if ($ipn['ipn_mode'] == 'httpauth' && $this->helper->getGeneralConfig('ipn_mode') == 1) { - if ($this->checkHttpauthIpn($ipn)) { - return true; - } - } else { - $this->logAndDie('Unknown ipn_mode.'); - } + $this->logAndDie('Unknown ipn_mode.'); } return false; @@ -227,38 +221,4 @@ private function checkHmacIpn($ipn) return true; } - - private function checkHttpauthIpn($ipn) - { - if (isset($_SERVER['PHP_AUTH_USER']) - && $_SERVER['PHP_AUTH_USER'] == trim( - $this->helper->getGeneralConfig('merchant_id') - ) - ) { - if (isset($_SERVER['PHP_AUTH_PW']) - && $_SERVER['PHP_AUTH_PW'] == trim( - $this->helper->getGeneralConfig('ipn_secret') - ) - ) { - $merchant = isset($ipn['merchant']) ? $ipn['merchant'] : ''; - if (empty($merchant)) { - $this->logAndDie('No Merchant ID passed'); - } - if ($merchant != trim($this->helper->getGeneralConfig('merchant_id'))) { - $this->logAndDie('Invalid Merchant ID'); - } - - return true; - } else { - $this->logAndDie( - 'IPN Secret not correct or no HTTP Auth variables passed. If you are using PHP in CGI mode try the HMAC method.' - ); - } - } else { - $this->logAndDie( - 'Merchant ID not correct or no HTTP Auth variables passed. If you are using PHP in CGI mode try the HMAC method.' - ); - } - return false; - } } diff --git a/README.md b/README.md index e326299..874e9d1 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,37 @@ - -

Live demo | Extension manualCoinPayments 

-

Meet the best way to accept cryptocurrency on Magento 2. With Firebear CoinPayments Magento 2 extension, you will easily integrate your ecommerce store with the popular cryptocurrency gateway accepting over 70 altcoins, including Bitcoin and Ethereum. Thus, Magento 2 cryptocurrency trading is no longer an unattainable goal - it is a new way of business dealing.

+

Overview

+

Meet the best way to accept cryptocurrency on Magento 2. With Firebear CoinPayments Magento 2 extension, you will easily integrate your ecommerce store with the popular cryptocurrency gateway accepting over 70 altcoins, including Bitcoin and Ethereum. Thus, Magento 2 cryptocurrency trading is no longer an unattainable goal - it is a new way of business dealing.

Features

- Magento 2 cryptocurrency integration: accept Bitcoin, Ethereum, and other altcoins as payment for products and services you sell;

-

- Use Magento 2 cryptocurrency wallets (based on CoinPayments) to store crypto: Ethereum, BitCoin or any altocoin wallet;

-

- Magento 2 Cryptocurrency PayPal integration: send payments to PayPal without any fees;

+

- Use Magento 2 cryptocurrency wallets (based on CoinPayments) to store crypto: Ethereum, Bitcoin or any supported altcoin wallet;

- Transparent transaction history: view separate logs for deposits, transfers, withdrawals, and conversions.

-

- Supported coins : Bitcoin, Litecoin, AudioCoin, BitConnect, Bitcoin Cash, BitBean, BlackCoin, Breakout, CloakCoin, Crown, CureCoin, Dash, Decred, DigiByte, Dogecoin, Ether Classic, Ethereum, Expanse, FLASH, GameCredits, GCRCoin, Goldcoin, Gridcoin, Groestlcoin, LeoCoin, LeoCoin (Old Chain), LISK, MaidSafeCoin, MonetaryUnit, NAV Coin, NoLimitCoin, Namecoin, NVO Token, Nexus, NXT, OMNI, PinkCoin, PIVX, PoSW Coin, PotCoin, Peercoin, ProCurrency, Quark, Steem Dollars, SibCoin, STEEM, Stratis, Syscoin, TetherUSD, Voxels, Vertcoin, Waves, Counterparty, NEM, Monero, VERGE, ZCash, ZenCash, Litecoin Testnet

-

CoinPayments is a popular online platform that allows accepting, storing, converting, and withdrawing altcoins. Currently it supports 70+ cryptocurrencies and provides a unique $tag to receive payments from all of them. Thus, you can easily accept payments in such popular altcoins as Bitcoin and Ethereum on your Magento 2 ecommerce website. Bitcoin is a number one cryptocurrency that has become the first decentralized digital currency that uses peer-to-peer transactions, so users interact directly without any intermediary. Ethereum is based on the same technology, blockchain, and provides a cryptocurrency token transferable between accounts as well. To view current Magento 2 cryptocurrency prices, visit CoinMarketCup.

-

-

Besides, CoinPayments offers an integration with PayPal. For all United States and Euro merchants, the platform, and our Magento 2 cryptocurrency extension, provides the ability to have a fiat settlement directly to a bank account. And since there are more than 70 altcoins are supported, CoinPayments offers autoconversion for them that is free of fees. As a result, you save lots of time and effort.

+

- Supported coins : Bitcoin, Litecoin, AudioCoin, BitConnect, Bitcoin Cash, BitBean, BlackCoin, Breakout, CloakCoin, Crown, CureCoin, Dash, Decred, DigiByte, Dogecoin, Ether Classic, Ethereum, Expanse, FLASH, GameCredits, GCRCoin, Goldcoin, Gridcoin, Groestlcoin, LeoCoin, LeoCoin (Old Chain), LISK, MaidSafeCoin, MonetaryUnit, NAV Coin, NoLimitCoin, Namecoin, NVO Token, Nexus, NXT, OMNI, PinkCoin, PIVX, PoSW Coin, PotCoin, Peercoin, ProCurrency, Quark, Steem Dollars, SibCoin, STEEM, Stratis, Syscoin, TetherUSD, Voxels, Vertcoin, Waves, Counterparty, NEM, Monero, VERGE, ZCash, ZenCash.

+

CoinPayments is a popular online platform that allows accepting, storing, converting, and withdrawing altcoins. Currently it supports 70+ cryptocurrencies and provides a unique $tag to receive payments from all of them. Thus, you can easily accept payments in such popular altcoins as Bitcoin and Ethereum on your Magento 2 ecommerce website. Bitcoin is a number one cryptocurrency that has become the first decentralized digital currency that uses peer-to-peer transactions, so users interact directly without any intermediary. Ethereum is based on the same technology, blockchain, and provides a cryptocurrency token transferable between accounts as well. To view current Magento 2 cryptocurrency prices, visit CoinMarketCup.

With the Firebear CoinPayments Magento 2 cryptocurrency extension, you can not only accept altcoins on your Magento 2 website, but also store cryptocurrency in a secure online wallet as well as protect altcoins in the vault that requires a time amount before being able to spend them. Almost 400 thousand vendors all over the world already use CoinPayments, so don't waste your chance to implement the new technology on your ecommerce storefront with the Firebear CoinPayments Magento 2 extension.

-

The Magento 2 CoinPyament cryptocurrency module is easy to configure. The integration of your store with CoinPayments (and the desired ability to accept crypto on Magento 2) won't take much time. Simply go to Stores -> Settings -> Configuration -> Sales -> Payment Methods -> Other Payment Methods. Here, you can find the 'Coin Payments' section that allows enabling the integration (specify such parameters as your CoinPayments.net Merchant ID and IPN secret), specifying countries to enable the new payment method for, and selecting order statuses for two cases: CoinPayments didn't receive funds and funds are received. You can find a more detailed Magento 2 payment gateway tutorial in the extension manual.

-

magento 2 bitcoin

-

magento 2 ethereum

+

The Magento 2 CoinPyament cryptocurrency module is easy to configure. The integration of your store with CoinPayments (and the desired ability to accept crypto on Magento 2) won't take much time. Simply go to Stores -> Settings -> Configuration -> Sales -> Payment Methods -> Other Payment Methods. Here, you can find the 'Coin Payments' section that allows enabling the integration (specify such parameters as your CoinPayments.net Merchant ID and IPN secret), specifying countries to enable the new payment method for, and selecting order statuses for two cases: CoinPayments didn't receive funds and funds are received.

+ +

Installation

+Composer driven installation coming soon , for now please use manual approach described below.

+ +1. Create backups of your web directory and Magento 2 store database;
+2. Download Firebear CoinPayments Magento 2 Extension installation package;
+3. Unzip (extract from zip archive) file and copy to /app/code/Firebear/CoinPayments/ folder (create it manually!)
+4. Navigate to your store root folder in the SSH console of your server:

+ +cd path_to_the_store_root_folder

+ +And run the following commands:

+ +php -f bin/magento module:enable Firebear_CoinPayments
+php -f bin/magento setup:upgrade

+ +5. Now, you have to flush store cache; log out from your backend and login once again. Use the following command:

+ +php -f bin/magento cache:clean


+ +Congratulations! The Firebear CoinPayments Magento 2 Bitcoin/Ethereum/Altcoin module is successfully installed. Now, you should configure your new Magento 2 cryptocurrency payment gateway. + +

User Experience

From the frontend perspective, you should add a product to cart and proceed to checkout. Complete the first step in order to be able to select a payment method. Select "Coin Payments" and you will see the following message:

magento 2 bitcoin checkout

-

Now, you are on the CoinPayments platform. Specify your first name, last name, and email, choose your altcoin, and complete the checkout. Alternatively, you can cancel it and return to seller's store, contact seller directly from the cryptocurrency payment gateway page, or view profile.

-

magento 2 coin payments checkout - bitcoin & ethereum

+

Now, you are on the CoinPayments platform. Choose your altcoin, and complete the checkout. Alternatively, you can cancel it and return to seller's store, contact seller directly from the cryptocurrency payment gateway page, or view profile.

send bitcoin magento 2

diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 03d2e14..a911704 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -9,7 +9,7 @@
- + @@ -29,12 +29,6 @@ - - - - Magento\Config\Model\Config\Source\Yesno - - diff --git a/view/frontend/templates/coinpayments/form/coinpayments.phtml b/view/frontend/templates/coinpayments/form/coinpayments.phtml index 4f5a28f..f6acf5e 100644 --- a/view/frontend/templates/coinpayments/form/coinpayments.phtml +++ b/view/frontend/templates/coinpayments/form/coinpayments.phtml @@ -11,4 +11,3 @@ if ($coinpaymentsScope->getValue('payment/coinpayments/fullscreen')) { '
  • You will be transfered to CoinPayments to complete your purchase when using this payment method.
  • ' . ''; } -?> \ No newline at end of file diff --git a/view/frontend/templates/coinpayments/iframe.phtml b/view/frontend/templates/coinpayments/iframe.phtml index 39b9b22..b4550cd 100644 --- a/view/frontend/templates/coinpayments/iframe.phtml +++ b/view/frontend/templates/coinpayments/iframe.phtml @@ -11,7 +11,7 @@ $successUrl = $block->getSuccessUrl(); $failUrl = $block->getFailUrl(); ?>
    - + diff --git a/view/frontend/templates/coinpayments/redirect.phtml b/view/frontend/templates/coinpayments/redirect.phtml index c923ce6..1d03c06 100644 --- a/view/frontend/templates/coinpayments/redirect.phtml +++ b/view/frontend/templates/coinpayments/redirect.phtml @@ -7,30 +7,5 @@ // Retrieve order $_order = $block->getOrder(); $orderId = $block->getRealOrderId(); -var_dump($orderId); -?> - +//var_dump($orderId); + From e73d527906528f1573eafe3ee9f4d7980c602430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Sat, 29 Sep 2018 17:49:09 -0400 Subject: [PATCH 002/107] Readme tweak --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 874e9d1..a6afd55 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,16 @@ Composer driven installation coming soon , for now please use manual approach de 3. Unzip (extract from zip archive) file and copy to /app/code/Firebear/CoinPayments/ folder (create it manually!)
    4. Navigate to your store root folder in the SSH console of your server:

    -cd path_to_the_store_root_folder

    +cd path_to_the_store_root_folder
    -And run the following commands:

    +And run the following commands:
    php -f bin/magento module:enable Firebear_CoinPayments
    -php -f bin/magento setup:upgrade

    +php -f bin/magento setup:upgrade
    -5. Now, you have to flush store cache; log out from your backend and login once again. Use the following command:

    +5. Now, you have to flush store cache; log out from your backend and login once again. Use the following command:
    -php -f bin/magento cache:clean


    +php -f bin/magento cache:clean

    Congratulations! The Firebear CoinPayments Magento 2 Bitcoin/Ethereum/Altcoin module is successfully installed. Now, you should configure your new Magento 2 cryptocurrency payment gateway. From c5acb71357cd32c56b4989af730fd9c293eafaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Mon, 1 Oct 2018 02:01:14 -0400 Subject: [PATCH 003/107] Updates --- Controller/Iframe/Index.php | 2 +- Controller/Ipn/Index.php | 12 ++++++------ view/frontend/templates/coinpayments/iframe.phtml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Controller/Iframe/Index.php b/Controller/Iframe/Index.php index d3679ad..2ced37a 100644 --- a/Controller/Iframe/Index.php +++ b/Controller/Iframe/Index.php @@ -56,7 +56,7 @@ public function execute() 'coinpayment/conf/url_payment', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - $html = 'You will be transfered to coinpayments.net to complete your purchase when using this payment method.'; + $html = 'You will be transfered to CoinPayments.net to complete your purchase when using this payment method.'; $this->getResponse()->setBody(json_encode(['html' => $html])); } } diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index 5e66954..52efe17 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -118,22 +118,22 @@ private function checkStatus($status, $order) . ' ' . $this->getRequest()->getParam('currency1') . '
    '; $str .= 'Received Amount: ' . sprintf('%.08f', $this->getRequest()->getParam('amount2')) . ' ' . $this->getRequest()->getParam('currency2'); + $order->addStatusToHistory($this->helper->getGeneralConfig('status_order_paid'), $str, true); $order->setState( $this->helper->getGeneralConfig('status_order_paid'), true, $str )->setStatus($this->helper->getGeneralConfig('status_order_paid')); - $this->_objectManager->create('\Magento\Sales\Model\OrderNotifier') - ->notify($order); + $this->_objectManager->create('\Magento\Sales\Model\OrderNotifier')->notify($order); } else { //order pending + $str = 'CoinPayments.net Payment Status: ' . $this->getRequest()->getParam('status_text'); + $order->addStatusToHistory(Order::STATE_NEW, $str, true); $order->setState( Order::STATE_NEW, true, - 'CoinPayments.net Payment Status: ' . $this->getRequest()->getParam( - 'status_text' - ) - )->setStatus(Order::STATE_PROCESSING); + $str + )->setStatus(Order::STATE_NEW); } $order->save(); } diff --git a/view/frontend/templates/coinpayments/iframe.phtml b/view/frontend/templates/coinpayments/iframe.phtml index b4550cd..210311f 100644 --- a/view/frontend/templates/coinpayments/iframe.phtml +++ b/view/frontend/templates/coinpayments/iframe.phtml @@ -37,12 +37,12 @@ $failUrl = $block->getFailUrl(); 'utf-8' ); ?>"> From 74c6f7eb3978a3a3f89d2fe14a813301616efc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Mon, 1 Oct 2018 02:06:12 -0400 Subject: [PATCH 004/107] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a6afd55..0eab093 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +

    Download

    +Grab the latest version by clicking the Releases tab. Then come back here for installation instructions.

    Overview

    Meet the best way to accept cryptocurrency on Magento 2. With Firebear CoinPayments Magento 2 extension, you will easily integrate your ecommerce store with the popular cryptocurrency gateway accepting over 70 altcoins, including Bitcoin and Ethereum. Thus, Magento 2 cryptocurrency trading is no longer an unattainable goal - it is a new way of business dealing.

    Features

    From eb8c981c315bb2176176bd0744fb35818d2ad596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Mon, 1 Oct 2018 02:17:35 -0400 Subject: [PATCH 005/107] Update --- Controller/Ipn/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index 52efe17..4b3c467 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -133,7 +133,7 @@ private function checkStatus($status, $order) Order::STATE_NEW, true, $str - )->setStatus(Order::STATE_NEW); + )->setStatus(Order::STATE_PROCESSING); } $order->save(); } From a5dd13850e2eb2f94c8c8bdea0034d0ea309efb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Mon, 1 Oct 2018 02:25:11 -0400 Subject: [PATCH 006/107] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0eab093..66446e8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Grab the latest version by clicking the Releases tab. Then come back here for in

    - Use Magento 2 cryptocurrency wallets (based on CoinPayments) to store crypto: Ethereum, Bitcoin or any supported altcoin wallet;

    - Transparent transaction history: view separate logs for deposits, transfers, withdrawals, and conversions.

    - Supported coins : Bitcoin, Litecoin, AudioCoin, BitConnect, Bitcoin Cash, BitBean, BlackCoin, Breakout, CloakCoin, Crown, CureCoin, Dash, Decred, DigiByte, Dogecoin, Ether Classic, Ethereum, Expanse, FLASH, GameCredits, GCRCoin, Goldcoin, Gridcoin, Groestlcoin, LeoCoin, LeoCoin (Old Chain), LISK, MaidSafeCoin, MonetaryUnit, NAV Coin, NoLimitCoin, Namecoin, NVO Token, Nexus, NXT, OMNI, PinkCoin, PIVX, PoSW Coin, PotCoin, Peercoin, ProCurrency, Quark, Steem Dollars, SibCoin, STEEM, Stratis, Syscoin, TetherUSD, Voxels, Vertcoin, Waves, Counterparty, NEM, Monero, VERGE, ZCash, ZenCash.

    -

    CoinPayments is a popular online platform that allows accepting, storing, converting, and withdrawing altcoins. Currently it supports 70+ cryptocurrencies and provides a unique $tag to receive payments from all of them. Thus, you can easily accept payments in such popular altcoins as Bitcoin and Ethereum on your Magento 2 ecommerce website. Bitcoin is a number one cryptocurrency that has become the first decentralized digital currency that uses peer-to-peer transactions, so users interact directly without any intermediary. Ethereum is based on the same technology, blockchain, and provides a cryptocurrency token transferable between accounts as well. To view current Magento 2 cryptocurrency prices, visit CoinMarketCup.

    +

    CoinPayments is a popular online platform that allows accepting, storing, converting, and withdrawing altcoins. Currently it supports 70+ cryptocurrencies and provides a unique $tag to receive payments from all of them. Thus, you can easily accept payments in such popular altcoins as Bitcoin and Ethereum on your Magento 2 ecommerce website. Bitcoin is a number one cryptocurrency that has become the first decentralized digital currency that uses peer-to-peer transactions, so users interact directly without any intermediary. Ethereum is based on the same technology, blockchain, and provides a cryptocurrency token transferable between accounts as well. To view current Magento 2 cryptocurrency prices, visit CoinMarketCap.

    With the Firebear CoinPayments Magento 2 cryptocurrency extension, you can not only accept altcoins on your Magento 2 website, but also store cryptocurrency in a secure online wallet as well as protect altcoins in the vault that requires a time amount before being able to spend them. Almost 400 thousand vendors all over the world already use CoinPayments, so don't waste your chance to implement the new technology on your ecommerce storefront with the Firebear CoinPayments Magento 2 extension.

    The Magento 2 CoinPyament cryptocurrency module is easy to configure. The integration of your store with CoinPayments (and the desired ability to accept crypto on Magento 2) won't take much time. Simply go to Stores -> Settings -> Configuration -> Sales -> Payment Methods -> Other Payment Methods. Here, you can find the 'Coin Payments' section that allows enabling the integration (specify such parameters as your CoinPayments.net Merchant ID and IPN secret), specifying countries to enable the new payment method for, and selecting order statuses for two cases: CoinPayments didn't receive funds and funds are received.

    From f97b86fb77c8acd8ba33e4e822cc9383c70a6dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Mon, 15 Oct 2018 11:31:52 -0400 Subject: [PATCH 007/107] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7e20972..2319b70 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "firebear/coinpayments", - "description": "Add new payment method for coinpayments.com", + "name": "coinpaymentsnet/magento2", + "description": "Add new payment method for CoinPayments.net", "require": { "php": "~5.5.0|~5.6.0|~7.0.0|~7.1" }, From c5e86c6cacec0923244259e7a38479f72312d960 Mon Sep 17 00:00:00 2001 From: vagrant Date: Wed, 17 Oct 2018 13:05:11 +0000 Subject: [PATCH 008/107] change namespases --- Block/Form/Coinpayments.php | 4 ++-- Block/Iframe.php | 2 +- Block/Info.php | 4 ++-- Block/Redirect.php | 2 +- Controller/Checkout/Failure.php | 2 +- Controller/Iframe/Index.php | 2 +- Controller/Invoice/Index.php | 8 ++++---- Controller/Ipn/Index.php | 6 +++--- Helper/Data.php | 2 +- Logger/Handler.php | 2 +- Logger/Logger.php | 2 +- Model/Methods/Coinpayments.php | 6 +++--- README.md | 12 ++++++------ composer.json | 2 +- etc/config.xml | 2 +- etc/di.xml | 6 +++--- etc/frontend/routes.xml | 2 +- etc/module.xml | 2 +- registration.php | 2 +- view/frontend/layout/checkout_index_index.xml | 2 +- view/frontend/layout/coinpayments_invoice_index.xml | 2 +- view/frontend/web/js/view/payment/coin_payments.js | 2 +- .../js/view/payment/method-renderer/coin-method.js | 4 ++-- 23 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Block/Form/Coinpayments.php b/Block/Form/Coinpayments.php index 841c4e4..700b358 100644 --- a/Block/Form/Coinpayments.php +++ b/Block/Form/Coinpayments.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Block\Form; +namespace Coinpayments\CoinPayments\Block\Form; use Magento\Customer\Helper\Session\CurrentCustomer; @@ -29,7 +29,7 @@ class Coinpayments extends \Magento\Payment\Block\Form protected function _construct() { - $template = 'Firebear_CoinPayments::coinpayments/form/coinpayments.phtml'; + $template = 'Coinpayments_CoinPayments::coinpayments/form/coinpayments.phtml'; $this->setTemplate($template); parent::__construct(); diff --git a/Block/Iframe.php b/Block/Iframe.php index f4b23d4..66ed1ac 100644 --- a/Block/Iframe.php +++ b/Block/Iframe.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Block; +namespace Coinpayments\CoinPayments\Block; class Iframe extends \Magento\Framework\View\Element\Template { diff --git a/Block/Info.php b/Block/Info.php index eac6e9f..a5af79c 100644 --- a/Block/Info.php +++ b/Block/Info.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Block; +namespace Coinpayments\CoinPayments\Block; /** * Base payment iformation block @@ -14,7 +14,7 @@ class Info extends \Magento\Framework\View\Element\Template /** * @var string */ - protected $_template = 'Firebear_CoinPayments::coinpayments/info/default.phtml'; + protected $_template = 'Coinpayments_CoinPayments::coinpayments/info/default.phtml'; /** * @return mixed diff --git a/Block/Redirect.php b/Block/Redirect.php index a617b68..474e837 100644 --- a/Block/Redirect.php +++ b/Block/Redirect.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Block; +namespace Coinpayments\CoinPayments\Block; class Redirect extends \Magento\Framework\View\Element\Template { diff --git a/Controller/Checkout/Failure.php b/Controller/Checkout/Failure.php index b876a10..fd2e5d4 100644 --- a/Controller/Checkout/Failure.php +++ b/Controller/Checkout/Failure.php @@ -1,6 +1,6 @@ */ -namespace Firebear\CoinPayments\Controller\Iframe; +namespace Coinpayments\CoinPayments\Controller\Iframe; class Index extends \Magento\Framework\App\Action\Action { diff --git a/Controller/Invoice/Index.php b/Controller/Invoice/Index.php index 1376a0d..cb4514f 100644 --- a/Controller/Invoice/Index.php +++ b/Controller/Invoice/Index.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Controller\Invoice; +namespace Coinpayments\CoinPayments\Controller\Invoice; use Magento\Framework\App\Action\Context; use Magento\Framework\Controller\ResultFactory; @@ -47,7 +47,7 @@ class Index extends \Magento\Framework\App\Action\Action private $orderRepository; /** - * @var \Firebear\CoinPayments\Helper\Data + * @var \Coinpayments\CoinPayments\Helper\Data */ private $coinPayemtnsHelper; @@ -60,7 +60,7 @@ class Index extends \Magento\Framework\App\Action\Action * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Sales\Model\OrderRepository $orderRepository - * @param \Firebear\CoinPayments\Helper\Data $coinPayemtnsHelper + * @param \Coinpayments\CoinPayments\Helper\Data $coinPayemtnsHelper */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -70,7 +70,7 @@ public function __construct( \Magento\Checkout\Model\Session $checkoutSession, \Psr\Log\LoggerInterface $logger, \Magento\Sales\Model\OrderRepository $orderRepository, - \Firebear\CoinPayments\Helper\Data $coinPayemtnsHelper + \Coinpayments\CoinPayments\Helper\Data $coinPayemtnsHelper ) { $this->_coreRegistry = $coreRegistry; $this->config = $config; diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index 4b3c467..c9870c7 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -4,12 +4,12 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Controller\Ipn; +namespace Coinpayments\CoinPayments\Controller\Ipn; use Magento\Sales\Model\Order; use Magento\Framework\App\Action\Context; -use Firebear\CoinPayments\Logger\Logger; -use Firebear\CoinPayments\Helper\Data as CoinPaymentHelper; +use Coinpayments\CoinPayments\Logger\Logger; +use Coinpayments\CoinPayments\Helper\Data as CoinPaymentHelper; /** * Class Index diff --git a/Helper/Data.php b/Helper/Data.php index 8c47e9a..77b842c 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Helper; +namespace Coinpayments\CoinPayments\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; diff --git a/Logger/Handler.php b/Logger/Handler.php index 6059fac..7b2a043 100644 --- a/Logger/Handler.php +++ b/Logger/Handler.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Logger; +namespace Coinpayments\CoinPayments\Logger; use \Monolog\Logger as MonologLogger; diff --git a/Logger/Logger.php b/Logger/Logger.php index 3b62945..80f3dc3 100644 --- a/Logger/Logger.php +++ b/Logger/Logger.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Logger; +namespace Coinpayments\CoinPayments\Logger; class Logger extends \Monolog\Logger { diff --git a/Model/Methods/Coinpayments.php b/Model/Methods/Coinpayments.php index 8109914..a4061c0 100644 --- a/Model/Methods/Coinpayments.php +++ b/Model/Methods/Coinpayments.php @@ -4,7 +4,7 @@ * @author : Firebear Studio */ -namespace Firebear\CoinPayments\Model\Methods; +namespace Coinpayments\CoinPayments\Model\Methods; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\HTTP\ZendClientFactory; @@ -31,9 +31,9 @@ class Coinpayments extends AbstractMethod /* Uncomment if need using blocks - protected $_formBlockType = 'Firebear\CoinPayments\Block\Form\Coinpayments'; + protected $_formBlockType = 'Coinpayments\CoinPayments\Block\Form\Coinpayments'; - protected $_infoBlockType = 'Firebear\CoinPayments\Block\Info';*/ + protected $_infoBlockType = 'Coinpayments\CoinPayments\Block\Info';*/ /** diff --git a/README.md b/README.md index 66446e8..6c79d17 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,36 @@

    Download

    Grab the latest version by clicking the Releases tab. Then come back here for installation instructions.

    Overview

    -

    Meet the best way to accept cryptocurrency on Magento 2. With Firebear CoinPayments Magento 2 extension, you will easily integrate your ecommerce store with the popular cryptocurrency gateway accepting over 70 altcoins, including Bitcoin and Ethereum. Thus, Magento 2 cryptocurrency trading is no longer an unattainable goal - it is a new way of business dealing.

    +

    Meet the best way to accept cryptocurrency on Magento 2. With Coinpayments CoinPayments Magento 2 extension, you will easily integrate your ecommerce store with the popular cryptocurrency gateway accepting over 70 altcoins, including Bitcoin and Ethereum. Thus, Magento 2 cryptocurrency trading is no longer an unattainable goal - it is a new way of business dealing.

    Features

    - Magento 2 cryptocurrency integration: accept Bitcoin, Ethereum, and other altcoins as payment for products and services you sell;

    - Use Magento 2 cryptocurrency wallets (based on CoinPayments) to store crypto: Ethereum, Bitcoin or any supported altcoin wallet;

    - Transparent transaction history: view separate logs for deposits, transfers, withdrawals, and conversions.

    - Supported coins : Bitcoin, Litecoin, AudioCoin, BitConnect, Bitcoin Cash, BitBean, BlackCoin, Breakout, CloakCoin, Crown, CureCoin, Dash, Decred, DigiByte, Dogecoin, Ether Classic, Ethereum, Expanse, FLASH, GameCredits, GCRCoin, Goldcoin, Gridcoin, Groestlcoin, LeoCoin, LeoCoin (Old Chain), LISK, MaidSafeCoin, MonetaryUnit, NAV Coin, NoLimitCoin, Namecoin, NVO Token, Nexus, NXT, OMNI, PinkCoin, PIVX, PoSW Coin, PotCoin, Peercoin, ProCurrency, Quark, Steem Dollars, SibCoin, STEEM, Stratis, Syscoin, TetherUSD, Voxels, Vertcoin, Waves, Counterparty, NEM, Monero, VERGE, ZCash, ZenCash.

    CoinPayments is a popular online platform that allows accepting, storing, converting, and withdrawing altcoins. Currently it supports 70+ cryptocurrencies and provides a unique $tag to receive payments from all of them. Thus, you can easily accept payments in such popular altcoins as Bitcoin and Ethereum on your Magento 2 ecommerce website. Bitcoin is a number one cryptocurrency that has become the first decentralized digital currency that uses peer-to-peer transactions, so users interact directly without any intermediary. Ethereum is based on the same technology, blockchain, and provides a cryptocurrency token transferable between accounts as well. To view current Magento 2 cryptocurrency prices, visit CoinMarketCap.

    -

    With the Firebear CoinPayments Magento 2 cryptocurrency extension, you can not only accept altcoins on your Magento 2 website, but also store cryptocurrency in a secure online wallet as well as protect altcoins in the vault that requires a time amount before being able to spend them. Almost 400 thousand vendors all over the world already use CoinPayments, so don't waste your chance to implement the new technology on your ecommerce storefront with the Firebear CoinPayments Magento 2 extension.

    +

    With the Coinpayments CoinPayments Magento 2 cryptocurrency extension, you can not only accept altcoins on your Magento 2 website, but also store cryptocurrency in a secure online wallet as well as protect altcoins in the vault that requires a time amount before being able to spend them. Almost 400 thousand vendors all over the world already use CoinPayments, so don't waste your chance to implement the new technology on your ecommerce storefront with the Coinpayments CoinPayments Magento 2 extension.

    The Magento 2 CoinPyament cryptocurrency module is easy to configure. The integration of your store with CoinPayments (and the desired ability to accept crypto on Magento 2) won't take much time. Simply go to Stores -> Settings -> Configuration -> Sales -> Payment Methods -> Other Payment Methods. Here, you can find the 'Coin Payments' section that allows enabling the integration (specify such parameters as your CoinPayments.net Merchant ID and IPN secret), specifying countries to enable the new payment method for, and selecting order statuses for two cases: CoinPayments didn't receive funds and funds are received.

    Installation

    Composer driven installation coming soon , for now please use manual approach described below.

    1. Create backups of your web directory and Magento 2 store database;
    -2. Download Firebear CoinPayments Magento 2 Extension installation package;
    -3. Unzip (extract from zip archive) file and copy to /app/code/Firebear/CoinPayments/ folder (create it manually!)
    +2. Download Coinpayments CoinPayments Magento 2 Extension installation package;
    +3. Unzip (extract from zip archive) file and copy to /app/code/Coinpayments/CoinPayments/ folder (create it manually!)
    4. Navigate to your store root folder in the SSH console of your server:

    cd path_to_the_store_root_folder
    And run the following commands:
    -php -f bin/magento module:enable Firebear_CoinPayments
    +php -f bin/magento module:enable Coinpayments_CoinPayments
    php -f bin/magento setup:upgrade
    5. Now, you have to flush store cache; log out from your backend and login once again. Use the following command:
    php -f bin/magento cache:clean

    -Congratulations! The Firebear CoinPayments Magento 2 Bitcoin/Ethereum/Altcoin module is successfully installed. Now, you should configure your new Magento 2 cryptocurrency payment gateway. +Congratulations! The Coinpayments CoinPayments Magento 2 Bitcoin/Ethereum/Altcoin module is successfully installed. Now, you should configure your new Magento 2 cryptocurrency payment gateway.

    User Experience

    From the frontend perspective, you should add a product to cart and proceed to checkout. Complete the first step in order to be able to select a payment method. Select "Coin Payments" and you will see the following message:

    diff --git a/composer.json b/composer.json index 2319b70..bb3fd76 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "registration.php" ], "psr-4": { - "Firebear\\CoinPayments\\": "" + "Coinpayments\\CoinPayments\\": "" } } } diff --git a/etc/config.xml b/etc/config.xml index ab46a61..afa1eb6 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -11,7 +11,7 @@ 1 - Firebear\CoinPayments\Model\Methods\Coinpayments + Coinpayments\CoinPayments\Model\Methods\Coinpayments pending Coin Payments 0 diff --git a/etc/di.xml b/etc/di.xml index f284408..ccf7983 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -7,16 +7,16 @@ --> - + Magento\Framework\Filesystem\Driver\File - + CoinPaymentDebug - Firebear\CoinPayments\Logger\Handler + Coinpayments\CoinPayments\Logger\Handler diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 310c7ae..71b31b9 100644 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index d66de55..6f7dc5f 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/registration.php b/registration.php index a2abac6..4995652 100644 --- a/registration.php +++ b/registration.php @@ -6,6 +6,6 @@ \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Firebear_CoinPayments', + 'Coinpayments_CoinPayments', __DIR__ ); diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 0736117..227acc6 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -24,7 +24,7 @@ - Firebear_CoinPayments/js/view/payment/coin_payments + Coinpayments_CoinPayments/js/view/payment/coin_payments true diff --git a/view/frontend/layout/coinpayments_invoice_index.xml b/view/frontend/layout/coinpayments_invoice_index.xml index 38e09d2..8d8388c 100644 --- a/view/frontend/layout/coinpayments_invoice_index.xml +++ b/view/frontend/layout/coinpayments_invoice_index.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/coin_payments.js b/view/frontend/web/js/view/payment/coin_payments.js index f44c385..32c9a07 100644 --- a/view/frontend/web/js/view/payment/coin_payments.js +++ b/view/frontend/web/js/view/payment/coin_payments.js @@ -14,7 +14,7 @@ define( rendererList.push( { type: 'coin_payments', - component: 'Firebear_CoinPayments/js/view/payment/method-renderer/coin-method' + component: 'Coinpayments_CoinPayments/js/view/payment/method-renderer/coin-method' } ); return Component.extend({}); 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 4d8adcb..253ca16 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 @@ -15,14 +15,14 @@ define( 'Magento_Checkout/js/checkout-data', 'Magento_Checkout/js/model/payment/additional-validators', 'mage/url', - 'Firebear_CoinPayments/js/action/set-payment-method', + 'Coinpayments_CoinPayments/js/action/set-payment-method', 'Magento_Checkout/js/model/full-screen-loader' ], function (ko,Component, quote,$,placeOrderAction,selectPaymentMethodAction,customer, checkoutData, additionalValidators, url,setPaymentMethodAction,fullScreenLoader) { 'use strict'; return Component.extend({ defaults: { - template: 'Firebear_CoinPayments/payment/coin_payment' + template: 'Coinpayments_CoinPayments/payment/coin_payment' }, getCode: function() { return 'coin_payments'; From 77d2ebb43d5d7cdad27701c0fff206ed6426900d Mon Sep 17 00:00:00 2001 From: Litahrts Date: Wed, 7 Nov 2018 17:07:56 +0200 Subject: [PATCH 009/107] add direct mode to coinpayments module --- Api/CurrencyManagementInterface.php | 13 ++ Api/TransactionInterface.php | 13 ++ Block/Iframe.php | 1 - Block/Status.php | 62 ++++++ Controller/Checkout/Failure.php | 2 +- Controller/Transaction/Status.php | 40 ++++ Helper/Data.php | 11 ++ Model/CoinPaymentsConfigProvider.php | 95 ++++++++++ Model/Currency.php | 37 ++++ Model/Transaction.php | 105 +++++++++++ etc/acl.xml | 10 + etc/adminhtml/system.xml | 31 ++- etc/config.xml | 1 + etc/di.xml | 2 + etc/frontend/di.xml | 13 ++ etc/module.xml | 3 +- etc/webapi.xml | 15 ++ view/frontend/layout/checkout_index_index.xml | 8 +- .../coinpayments_transaction_status.xml | 14 ++ .../templates/coinpayments/status.phtml | 37 ++++ .../web/js/model/validate-direct-form.js | 41 ++++ .../web/js/view/payment/coin_payments.js | 12 +- .../payment/method-renderer/coin-method.js | 176 +++++++++++++++++- .../js/view/payment/validate-direct-form.js | 16 ++ .../web/template/payment/coin_payment.html | 30 ++- .../template/payment/coin_payment_form.html | 38 ++++ .../payment/coin_payment_message.html | 2 + 27 files changed, 789 insertions(+), 39 deletions(-) create mode 100644 Api/CurrencyManagementInterface.php create mode 100644 Api/TransactionInterface.php create mode 100644 Block/Status.php create mode 100644 Controller/Transaction/Status.php create mode 100644 Model/CoinPaymentsConfigProvider.php create mode 100644 Model/Currency.php create mode 100644 Model/Transaction.php create mode 100644 etc/acl.xml create mode 100644 etc/frontend/di.xml create mode 100644 etc/webapi.xml create mode 100644 view/frontend/layout/coinpayments_transaction_status.xml create mode 100644 view/frontend/templates/coinpayments/status.phtml create mode 100644 view/frontend/web/js/model/validate-direct-form.js create mode 100644 view/frontend/web/js/view/payment/validate-direct-form.js create mode 100644 view/frontend/web/template/payment/coin_payment_form.html create mode 100644 view/frontend/web/template/payment/coin_payment_message.html diff --git a/Api/CurrencyManagementInterface.php b/Api/CurrencyManagementInterface.php new file mode 100644 index 0000000..67ebb9d --- /dev/null +++ b/Api/CurrencyManagementInterface.php @@ -0,0 +1,13 @@ + + */ + +namespace Coinpayments\CoinPayments\Block; + +use Magento\Framework\View\Element\Template; +use Magento\Checkout\Model\Session; + +class Status extends \Magento\Framework\View\Element\Template +{ + /* @var \Magento\Checkout\Model\Session */ + protected $_checkoutSession; + + /** + * Status constructor. + * @param Session $checkoutSession + * @param Template\Context $context + * @param array $data + */ + public function __construct( + Session $checkoutSession, + Template\Context $context, + array $data = []) + { + parent::__construct($context, $data); + $this->_checkoutSession = $checkoutSession; + } + + /** + * @var string + */ + protected $_template = 'Coinpayments_CoinPayments::coinpayments/status.phtml'; + + public function getTransactionData() + { + if ($this->_checkoutSession->getCoinpaymentsTransactionData()) { + return json_decode($this->_checkoutSession->getCoinpaymentsTransactionData()); + } + return (object) [ + 'error' => __('Transaction is not found') + ]; + } + + /** + * @return mixed + */ + public function getTransactionCurrency() + { + return $this->_checkoutSession->getCoinpaymentsCurrency(); + } + + /** + * @return string + */ + public function getLastOrderIncrementId() + { + return $this->_checkoutSession->getLastRealOrder()->getIncrementId(); + } +} diff --git a/Controller/Checkout/Failure.php b/Controller/Checkout/Failure.php index fd2e5d4..6f42ce2 100644 --- a/Controller/Checkout/Failure.php +++ b/Controller/Checkout/Failure.php @@ -43,7 +43,7 @@ public function execute() $order = $this->orderRepository->get($lastOrderId); $order->setStatus(Order::STATE_CANCELED)->setState(Order::STATE_CANCELED); $this->orderRepository->save($order); - $this->logger->info('ORDER INFO kjgjkgjkghjgjhggjh: ' . $order->getStatus() . $order->getState()); + $this->logger->info('ORDER INFO: ' . $order->getStatus() . $order->getState()); return $this->resultPageFactory->create(); } diff --git a/Controller/Transaction/Status.php b/Controller/Transaction/Status.php new file mode 100644 index 0000000..bef4853 --- /dev/null +++ b/Controller/Transaction/Status.php @@ -0,0 +1,40 @@ + + */ + +namespace Coinpayments\CoinPayments\Controller\Transaction; + +use Magento\Framework\App\Action\Context; +use Magento\Framework\View\Result\PageFactory; + + +class Status extends \Magento\Framework\App\Action\Action +{ + /** + * @var \Magento\Framework\View\Result\PageFactory + */ + protected $_resultPageFactory; + + /** + * Status constructor. + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory + */ + public function __construct(Context $context, PageFactory $resultPageFactory) + { + parent::__construct($context); + $this->_resultPageFactory = $resultPageFactory; + } + + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page + */ + public function execute() + { + $page = $this->_resultPageFactory->create(); + $page->getConfig()->getTitle()->set(__('Transaction Status')); + return $page; + } +} diff --git a/Helper/Data.php b/Helper/Data.php index 77b842c..637908b 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -49,4 +49,15 @@ public function getGeneralConfig($code, $storeId = null) { return $this->getConfigValue(self::XML_PATH_CONFIG_COINPAYMENTS . $code, $storeId); } + + public function getInvoiceTemplate() + { + if ($this->getConfigValue('payment/coin_payments/is_direct')) { + $template = 'Coinpayments_CoinPayments::coinpayments/iframe.phtml'; + } else { + $template = 'Coinpayments_CoinPayments::coinpayments/status.phtml'; + } + + return $template; + } } diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php new file mode 100644 index 0000000..6d910d6 --- /dev/null +++ b/Model/CoinPaymentsConfigProvider.php @@ -0,0 +1,95 @@ +_curl = $curl; + $this->_scopeConfig = $scopeConfig; + $this->_assetRepo = $assetRepo; + } + + /** + * @return array + */ + public function getConfig() + { + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; + $secretKey = $this->_scopeConfig->getValue('payment/coin_payments/secret_key', $scope); + $publicKey = $this->_scopeConfig->getValue('payment/coin_payments/public_key', $scope); + $isDirect = $this->_scopeConfig->getValue('payment/coin_payments/is_direct', $scope); + $coinpaymentsDomain = $this->_scopeConfig->getValue('coinpayment/conf/url_payment', $scope); + $coinpaymentsApi = $this->_scopeConfig->getValue('coinpayment/conf/api_payment', $scope); + + $data = [ + 'version' => 1, + 'cmd' => 'rates', + 'key' => $publicKey, + 'accepted' => 1, + ]; + + $this->_curl->addHeader('HMAC', hash_hmac('sha512', http_build_query($data), $secretKey)); + $this->_curl->addHeader('Content-Type', 'application/x-www-form-urlencoded'); + $this->_curl->post($coinpaymentsApi, $data); + $response = json_decode($this->_curl->getBody()); + + $currencies = ['error' => $response->error]; + if ($response->error == 'ok') { + $currencies = []; + foreach ($response->result as $key => $item) { + $currencies[] = [ + 'value' => $key, + 'body' => $item, + 'name' => $item->name + ]; + } + } + + return [ + 'payment' => [ + 'coinpayments' => [ + 'available_currencies' => $currencies, + 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), + 'direct_mode' => (int)$isDirect, + 'url' => $coinpaymentsDomain, + 'api_url' => $coinpaymentsApi + ] + ] + ]; + } +} \ No newline at end of file diff --git a/Model/Currency.php b/Model/Currency.php new file mode 100644 index 0000000..b0361aa --- /dev/null +++ b/Model/Currency.php @@ -0,0 +1,37 @@ +_quoteFactory = $quoteFactory; + $this->_checkoutSession = $checkoutSession; + } + + /** + * @param string $cartId + * @param string $currency + * @param float $value + * @return boolean + */ + public function saveCurrency($cartId, $currency, $value) + { + $quote = $this->_quoteFactory->create()->load($cartId); + if (!$quote->getId()) { + return false; + } + + $this->_checkoutSession->setCoinpaymentsCurrency($currency); + $this->_checkoutSession->setCoinpaymentsCurrencyTotal($value); + return true; + } +} \ No newline at end of file diff --git a/Model/Transaction.php b/Model/Transaction.php new file mode 100644 index 0000000..5d893d3 --- /dev/null +++ b/Model/Transaction.php @@ -0,0 +1,105 @@ +_quoteFactory = $quoteFactory; + $this->_checkoutSession = $checkoutSession; + $this->_curl = $curl; + $this->_scopeConfig = $scopeConfig; + $this->_orderModel = $orderModel; + $this->_urlBuilder = $urlBuilder; + } + + /** + * @param string $cartId + * @param string $currency + * @param float $value + * @return boolean + */ + public function createTransaction($cartId, $currency, $value) + { + $quote = $this->_quoteFactory->create()->load($cartId); + $order = $this->_checkoutSession->getLastRealOrder(); + + if (!$order->getId() && !$quote->getId()) { + return false; + } + $data = $this->prepareCreateTransactionData($order, $currency); + $this->_checkoutSession->setCoinpaymentsCurrency($currency); + $this->_checkoutSession->setCoinpaymentsCurrencyTotal($value); + $this->_checkoutSession->setCoinpaymentsTransactionData(json_encode($data)); + return true; + } + + /** + * @param $order + * @return mixed + */ + private function prepareCreateTransactionData($order, $currenctCurrency) + { + $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; + $secretKey = $this->_scopeConfig->getValue('payment/coin_payments/secret_key', $scope); + $publicKey = $this->_scopeConfig->getValue('payment/coin_payments/public_key', $scope); + $coinpaymentsApi = $this->_scopeConfig->getValue('coinpayment/conf/api_payment', $scope); + + $data = [ + 'version' => 1, + 'cmd' => 'create_transaction', + 'key' => $publicKey, + 'amount' => $order->getBaseGrandTotal(), + 'currency1' => $order->getOrderCurrencyCode(), + 'currency2' => $currenctCurrency, + 'buyer_email' => $order->getCustomerEmail(), + 'buyer_name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), + 'invoice' => $order->getIncrementId(), + 'ipn_url' => $this->_urlBuilder->getUrl('coinpayments/ipn/index') + ]; + + $this->_curl->addHeader('HMAC', hash_hmac('sha512', http_build_query($data), $secretKey)); + $this->_curl->addHeader('Content-Type', 'application/x-www-form-urlencoded'); + $this->_curl->post($coinpaymentsApi, $data); + $response = json_decode($this->_curl->getBody()); + + return $response; + } +} \ No newline at end of file diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100644 index 0000000..1686ef0 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index a911704..d51771a 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -15,49 +15,62 @@ Magento\Config\Model\Config\Source\Yesno - + + + Magento\Config\Model\Config\Source\Yesno + + - + Account Settings -> Basic Settings -> Your Merchant ID.]]> - + - + + + + + + + + + + - + Magento\Payment\Model\Config\Source\Allspecificcountries - + Magento\Directory\Model\Config\Source\Country 1 - + Magento\Sales\Model\Config\Source\Order\Status\NewStatus - + Magento\Sales\Model\Config\Source\Order\Status - + Magento\Config\Model\Config\Source\Yesno diff --git a/etc/config.xml b/etc/config.xml index afa1eb6..7eca386 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -21,6 +21,7 @@ https://www.coinpayments.net + https://www.coinpayments.net/api.php ` diff --git a/etc/di.xml b/etc/di.xml index ccf7983..4f80664 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -20,4 +20,6 @@ + + \ No newline at end of file diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml new file mode 100644 index 0000000..fca8dd9 --- /dev/null +++ b/etc/frontend/di.xml @@ -0,0 +1,13 @@ + + + + + + + Coinpayments\CoinPayments\Model\CoinPaymentsConfigProvider + + + + + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index 6f7dc5f..10c35a2 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -13,5 +13,6 @@ - + + \ No newline at end of file diff --git a/etc/webapi.xml b/etc/webapi.xml new file mode 100644 index 0000000..47dc727 --- /dev/null +++ b/etc/webapi.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 227acc6..65d003c 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -20,8 +20,14 @@ + + + + Coinpayments_CoinPayments/js/view/payment/validate-direct-form + + + - Coinpayments_CoinPayments/js/view/payment/coin_payments diff --git a/view/frontend/layout/coinpayments_transaction_status.xml b/view/frontend/layout/coinpayments_transaction_status.xml new file mode 100644 index 0000000..43f212f --- /dev/null +++ b/view/frontend/layout/coinpayments_transaction_status.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/view/frontend/templates/coinpayments/status.phtml b/view/frontend/templates/coinpayments/status.phtml new file mode 100644 index 0000000..636054d --- /dev/null +++ b/view/frontend/templates/coinpayments/status.phtml @@ -0,0 +1,37 @@ +getTransactionData(); +$currency = $block->getTransactionCurrency(); + +print_r($transactionData); +?> + +
    +

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

    +

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

    + error == 'ok') : ?> +

    Status link

    +
    +
    +

    + : + result->address ?> +

    +
    +
    +

    + : + result->amount . ' ' . $currency ?> +

    +
    +
    +

    + : + +

    +
    +
    + +

    +

    error ?>

    + +
    diff --git a/view/frontend/web/js/model/validate-direct-form.js b/view/frontend/web/js/model/validate-direct-form.js new file mode 100644 index 0000000..8d379d6 --- /dev/null +++ b/view/frontend/web/js/model/validate-direct-form.js @@ -0,0 +1,41 @@ +define( + ['jquery'], + function ($) { + 'use strict'; + return { + getCode: function () { + return 'coin_payments'; + }, + /** + * @returns {boolean} + */ + validate: function() { + if (this.getIsDirect()) { + return !this.validateDirectMode() + } + + return true; + }, + /** + * @returns {boolean} + */ + validateDirectMode: function () { + var isError = false; + var self = this; + var code = self.getCode(); + if (!$("#" + code + "_crypto_currency").find('option:selected').val()) { + // self.reportCurrencyMessage(); + isError = true; + } + return isError; + }, + getIsDirect: function () { + return window.checkoutConfig.payment.coinpayments.direct_mode; + }, + reportCurrencyMessage: function (message) + { + $("#" + this.getCode() + "_crypto_currency_error").text(message); + } + } + } +); \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/coin_payments.js b/view/frontend/web/js/view/payment/coin_payments.js index 32c9a07..d7ed9df 100644 --- a/view/frontend/web/js/view/payment/coin_payments.js +++ b/view/frontend/web/js/view/payment/coin_payments.js @@ -1,15 +1,12 @@ -/** - * @copyright: Copyright © 2017 Firebear Studio. All rights reserved. - * @author : Firebear Studio - */ - define( [ 'uiComponent', 'Magento_Checkout/js/model/payment/renderer-list' ], - function (Component, - rendererList) { + function ( + Component, + rendererList + ) { 'use strict'; rendererList.push( { @@ -17,6 +14,7 @@ define( component: 'Coinpayments_CoinPayments/js/view/payment/method-renderer/coin-method' } ); + /** Add view logic here if needed */ return Component.extend({}); } ); \ No newline at end of file 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 253ca16..d6af498 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 @@ -1,4 +1,4 @@ - /** +/** * @copyright: Copyright © 2017 Firebear Studio. All rights reserved. * @author : Firebear Studio */ @@ -16,42 +16,81 @@ define( 'Magento_Checkout/js/model/payment/additional-validators', 'mage/url', 'Coinpayments_CoinPayments/js/action/set-payment-method', - 'Magento_Checkout/js/model/full-screen-loader' + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/model/error-processor' ], - function (ko,Component, quote,$,placeOrderAction,selectPaymentMethodAction,customer, checkoutData, additionalValidators, url,setPaymentMethodAction,fullScreenLoader) { + function (ko, + Component, + quote, + $, + placeOrderAction, + selectPaymentMethodAction, + customer, + checkoutData, + additionalValidators, + url, + setPaymentMethodAction, + fullScreenLoader, + errorProcessor) { 'use strict'; return Component.extend({ defaults: { template: 'Coinpayments_CoinPayments/payment/coin_payment' }, - getCode: function() { + /** + * @returns {string} + */ + getCode: function () { return 'coin_payments'; }, - isActive: function() { + /** + * @returns {boolean} + */ + isActive: function () { return true; }, afterPlaceOrder: function () { - window.location.replace(url.build('coinpayments/invoice/index/')); + // fullScreenLoader.startLoader(); + var self = this; + if (self.getIsDirect()) { + self.createTransaction( + window.checkoutConfig.payment.coinpayments.currentData.currency, + window.checkoutConfig.payment.coinpayments.currentData.total, + url.build('coinpayments/transaction/status/') + ); + } else { + window.location.replace(url.build('coinpayments/invoice/index/')); + } }, getRedirectionText: function () { var iframeHtml; - jQuery.ajax( { + jQuery.ajax({ url: url.build('coinpayments/iframe/index/'), - async: false , + async: false, dataType: "json", - success: function(a) { + success: function (a) { iframeHtml = a.html; } }); return iframeHtml; }, - selectPaymentMethod: function() { + /** + * + * @returns {boolean} + */ + selectPaymentMethod: function () { selectPaymentMethodAction(this.getData()); checkoutData.setSelectedPaymentMethod(this.item.method); return true; }, + /** + * + * @param data + * @param event + * @returns {boolean} + */ placeOrder: function (data, event) { if (event) { event.preventDefault(); @@ -78,6 +117,123 @@ define( getMailingAddress: function () { return window.checkoutConfig.payment.checkmo.mailingAddress; }, + + getCurrencies: function () { + if (!window.checkoutConfig.payment.coinpayments.available_currencies.error) { + return window.checkoutConfig.payment.coinpayments.available_currencies; + } + + return [{error: "error"}]; + }, + getPaymentAcceptanceMarkSrc: function () { + return window.checkoutConfig.payment.coinpayments.logo; + }, + getIsDirect: function () { + return window.checkoutConfig.payment.coinpayments.direct_mode; + }, + getCoinpaymentsUrl: function () { + return window.checkoutConfig.payment.coinpayments.url; + }, + + getBaseGrandTotal: function () { + return window.checkoutConfig.totalsData.base_grand_total; + }, + /** + * + * @param element + * @param event + */ + getConvertedAmount: function (element, event) { + var shopCurrency = window.checkoutConfig.totalsData.base_currency_code; + var elemToChange = $('#converted_amount_coinpayments'); + var total = this.getBaseGrandTotal(); + var currentCurrencyCode = $(event.target).find('option:selected').val(); + + var currentCurrency = this.getCurrencies().find(function (e, i, array) { + return e.value == currentCurrencyCode ? true : false + }); + if (!currentCurrency) return; + + var shopCurrencyValue = this.getCurrencies().find(function (e, i, array) { + return e.value == shopCurrency ? true : false + }); + if (currentCurrencyCode === 'BTC') { + total = (shopCurrencyValue.body.rate_btc * total); + } else { + total = (shopCurrencyValue.body.rate_btc * total) / currentCurrency.body.rate_btc; + } + total = total.toFixed(5); + elemToChange.val(total + ' ' + currentCurrencyCode); + + window.checkoutConfig.payment.coinpayments.currentData = { + total: total, + currency: currentCurrencyCode + }; + }, + /** + * + * @returns {boolean} + */ + getAllowPlaceOrder: function () { + return this.getCode() === this.isChecked(); + }, + /** + * + * @param currency + * @param value + */ + saveCurrencyToQuote: function (currency, value) { + var quoteId = quote.getQuoteId(); + var url = '/rest/V1/coinpayments/' + quoteId + '/currency'; + var data = { + 'currency': currency, + 'value': value + }; + $.ajax({ + type: "POST", + url: url, + contentType: "application/json", + data: JSON.stringify(data), + success: function (result) { + //TODO success logic + }, + error: function (err) { + //TODO error logic + } + }); + }, + /** + * + * @param currency + * @param value + * @param redirect + */ + createTransaction: function (currency, value, redirect) { + var quoteId = quote.getQuoteId(); + var url = '/rest/V1/coinpayments/' + quoteId + '/transaction'; + var data = { + 'currency': currency, + 'value': value + }; + $.ajax({ + type: "POST", + url: url, + contentType: "application/json", + data: JSON.stringify(data), + success: function (result) { + console.log(result); + if (redirect) { + window.location.replace(redirect); + } + }, + error: function (err) { + console.log(error); + if (redirect) { + window.location.replace(redirect); + } + } + }); + } }); } ); \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/validate-direct-form.js b/view/frontend/web/js/view/payment/validate-direct-form.js new file mode 100644 index 0000000..7b78f8b --- /dev/null +++ b/view/frontend/web/js/view/payment/validate-direct-form.js @@ -0,0 +1,16 @@ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/payment/additional-validators', + 'Coinpayments_CoinPayments/js/model/validate-direct-form' + ], + function ( + Component, + additionalValidators, + validateDirectForm + ) { + 'use strict'; + additionalValidators.registerValidator(validateDirectForm); + return Component.extend({}); + } +); \ No newline at end of file diff --git a/view/frontend/web/template/payment/coin_payment.html b/view/frontend/web/template/payment/coin_payment.html index 90efeef..a89c2ba 100644 --- a/view/frontend/web/template/payment/coin_payment.html +++ b/view/frontend/web/template/payment/coin_payment.html @@ -9,8 +9,10 @@ + data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/> @@ -18,11 +20,21 @@ -
    -
    - -
    -
    +
    + +              + + +                   + +
    @@ -34,11 +46,11 @@ type="submit" data-bind=" click: placeOrder, - enable: (getCode() == isChecked()), - attr: {title: $t('Continue')}, + enable: getAllowPlaceOrder(), + attr: {title: $t('Place Order')}, css: {disabled: !isPlaceOrderActionAllowed()} "> - +
    diff --git a/view/frontend/web/template/payment/coin_payment_form.html b/view/frontend/web/template/payment/coin_payment_form.html new file mode 100644 index 0000000..ef46232 --- /dev/null +++ b/view/frontend/web/template/payment/coin_payment_form.html @@ -0,0 +1,38 @@ +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/view/frontend/web/template/payment/coin_payment_message.html b/view/frontend/web/template/payment/coin_payment_message.html new file mode 100644 index 0000000..bde7d78 --- /dev/null +++ b/view/frontend/web/template/payment/coin_payment_message.html @@ -0,0 +1,2 @@ +You will be transfered to CoinPayments.net to complete your purchase when using this payment method. \ No newline at end of file From 70521e0629eda495239bf632ace00b03297649a6 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Thu, 8 Nov 2018 18:07:22 +0200 Subject: [PATCH 010/107] fix IPN --- Block/Iframe.php | 3 +- Controller/Ipn/Handle.php | 52 ++++++++ Model/AbstractIpn.php | 209 +++++++++++++++++++++++++++++++++ Model/Info.php | 33 ++++++ Model/Ipn.php | 54 +++++++++ Model/IpnInterface.php | 13 ++ Model/Methods/Coinpayments.php | 5 + Model/Transaction.php | 58 ++++++++- 8 files changed, 423 insertions(+), 4 deletions(-) create mode 100644 Controller/Ipn/Handle.php create mode 100644 Model/AbstractIpn.php create mode 100644 Model/Info.php create mode 100644 Model/Ipn.php create mode 100644 Model/IpnInterface.php diff --git a/Block/Iframe.php b/Block/Iframe.php index 7aa21ea..e68611c 100644 --- a/Block/Iframe.php +++ b/Block/Iframe.php @@ -62,8 +62,7 @@ public function getFrameActionUrl() */ public function getIpnUrl() { - $quoteModel = $this->getQuote(); - return $this->getUrl('coinpayments/ipn/index'); + return $this->getUrl('coinpayments/ipn/handle'); } /** diff --git a/Controller/Ipn/Handle.php b/Controller/Ipn/Handle.php new file mode 100644 index 0000000..0361997 --- /dev/null +++ b/Controller/Ipn/Handle.php @@ -0,0 +1,52 @@ +_orderModel = $orderModel; + $this->_ipnModel = $ipnModel; + $this->_jsonResultFactory = $jsonResultFactory; + + } + + public function execute() + { + $requestData = (object)$this->getRequest()->getParams(); + $hmac = $this->getRequest()->getHeaders()->get('HMAC')->getFieldValue(); + $result = $this->_jsonResultFactory->create(); + if (!$requestData || !$hmac) { + $result->setData([ + 'error' => __('Invalid Data Sent') + ]); + return $result; + } + $errors = $this->_ipnModel->processIpnRequest($requestData, $hmac); + if (!empty($errors)) { + $result->setData($errors); + return $result; + } + return $result->setData(['error' => 'OK']); + } +} \ No newline at end of file diff --git a/Model/AbstractIpn.php b/Model/AbstractIpn.php new file mode 100644 index 0000000..22b8825 --- /dev/null +++ b/Model/AbstractIpn.php @@ -0,0 +1,209 @@ +_orderModel = $orderModel; + $this->_helper = $helper; + $this->_logger = $logger; + } + + protected function filterPaymentStatus($status) + { + switch ($status) { + case -2: + return Info::PAYMENT_STATUS_REFUND; + case -1: + return Info::PAYMENT_STATUS_CANCELLED; + case 0: + return Info::PAYMENT_STATUS_WAITING_FOR_FUNDS; + case 1: + return Info::PAYMENT_STATUS_COIN_CONFIRMED; + case 2: + return Info::PAYMENT_STATUS_QUEUE; + case 3: + return Info::PAYMENT_STATUS_HOLD; + case 100: + return Info::PAYMENT_STATUS_COMPLETE; + default: + return null; + + } + } + + protected function filterIpnType() + { + switch ($this->_data->ipn_type) { + case 'simple': + return Info::IPN_TYPE_SIMPLE; + case 'button': + return Info::IPN_TYPE_BUTTON; + case 'cart': + return Info::IPN_TYPE_CART; + case 'donation': + return Info::IPN_TYPE_DONATION; + case 'deposit': + return Info::IPN_TYPE_DEPOSIT; + case 'api': + return Info::IPN_TYPE_API; + default: + return null; + + } + } + + protected function checkHmac() + { + if (!$this->_hmac) { + return false; + } + + $serverHmac = hash_hmac( + "sha512", + http_build_query($this->_data), + trim($this->_helper->getGeneralConfig('ipn_secret')) + ); + if ($this->_hmac != $serverHmac) { + return false; + } + return true; + } + + protected function getOrder() + { + $order = $this->_orderModel->loadByIncrementId($this->_data->invoice); + if (!$order->getId()) { + $order = $this->_orderModel->load($this->_data->invoice); + } + if (!$order->getId()) { + return false; + } + $this->_currentOrder = $order; + return $order; + } + + /** + * @param $status + * @return $this + */ + protected function updateOrderStatus() + { + if ($this->filterPaymentStatus($this->_data->status) == Info::PAYMENT_STATUS_COMPLETE) { + $this->_currentOrder + ->setState($this->_helper->getGeneralConfig('status_order_paid')) + ->setStatus($this->_helper->getGeneralConfig('status_order_paid')); + } + return $this; + } + + /** + * @return $this + */ + protected function updateOrderPayment() + { + if ($this->filterPaymentStatus($this->_data->status) == Info::PAYMENT_STATUS_COMPLETE) { + $this->_currentOrder->setTotalPaid($this->_data->amount1); + } + return $this; + } + /** + * @return $this + */ + protected function addToOrderHistory() + { + $str = 'CoinPayments.net Payment Status: 1 ' . $this->_data->status_text . '
    '; + + if ($this->_data->status == Info::PAYMENT_STATUS_COMPLETE) { + $str .= 'Transaction ID: ' . $this->_data->txn_id + . '
    '; + $str .= 'Original Amount: ' . sprintf('%.08f', $this->_data->amount1) + . ' ' . $this->_data->currency1 . '
    '; + $str .= 'Received Amount: ' . sprintf('%.08f', $this->_data->amount2) + . ' ' . $this->_data->currency2; + } + $this->_currentOrder->addStatusToHistory($this->_currentOrder->getStatus(), $str); + + return $this; + } + /** + * @param int $status + * @return null|string + */ + protected function setTransactionStatus(int $status) + { + $this->_transactionStatus = $this->filterPaymentStatus($status); + return $this->_transactionStatus; + } + + /** + * @return mixed + */ + protected function getTransactionStatus() + { + return $this->_transactionStatus; + } + + protected function setHmac($hmac) + { + $this->_hmac = $hmac; + return $this->_hmac; + } + + protected function getHmac() + { + return $this->_hmac; + } + + protected function setRequestData($data) + { + $this->_data = $data; + return $this->_data; + } + + protected function getRequestData() + { + return $this->_data; + } + + protected function logAndDie($msg) + { + if ($this->_helper->getGeneralConfig('debug')) { + $message = ""; + if ($this->_currentOrder !== null) { + $message = "Order ID: " . $this->_currentOrder->getId() . "\n"; + } + $message .= $msg; + $this->_logger->info($message); + } + return $this; + } +} \ No newline at end of file diff --git a/Model/Info.php b/Model/Info.php new file mode 100644 index 0000000..f4e7267 --- /dev/null +++ b/Model/Info.php @@ -0,0 +1,33 @@ +setHmac($hmac); + $this->setRequestData($data); + $order = $this->getOrder(); + + $this + ->logAndDie('REQUEST: ' . print_r($data, true)) + ->logAndDie('HMAC: ' . $hmac); + + if (!$this->filterIpnType()) { + $error['ipn_type'] = __('Invalid IPN type'); + $this->logAndDie(__('Invalid IPN type')); + return $error; + } + + if (!$this->checkHmac()) { + $error['hmac'] = __('Invalid HMAC signature'); + $this->logAndDie(__('Invalid HMAC signature')); + return $error; + } + + $this + ->updateOrderPayment() + ->updateOrderStatus() + ->addToOrderHistory(); + + try { + $order->save(); + } catch (\Exception $e) { + $this->logAndDie(__('Error when save Order')); + $error['order_save'] = __('Error when save Order'); + return $error; + } + $this->logAndDie(__('SUCCESS UPDATE ORDER')); + return []; + } +} \ No newline at end of file diff --git a/Model/IpnInterface.php b/Model/IpnInterface.php new file mode 100644 index 0000000..829c42d --- /dev/null +++ b/Model/IpnInterface.php @@ -0,0 +1,13 @@ +getConfigData('active', $storeId); } + + public function getCode() + { + return $this->_code; + } } diff --git a/Model/Transaction.php b/Model/Transaction.php index 5d893d3..4867f0c 100644 --- a/Model/Transaction.php +++ b/Model/Transaction.php @@ -2,12 +2,15 @@ namespace Coinpayments\CoinPayments\Model; use Coinpayments\CoinPayments\Api\TransactionInterface; +use Coinpayments\CoinPayments\Logger\Logger; +use Coinpayments\CoinPayments\Model\Methods\Coinpayments; use Magento\Quote\Model\QuoteFactory; use Magento\Checkout\Model\Session; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Sales\Model\Order; use Magento\Framework\HTTP\Client\Curl; use Magento\Framework\UrlInterface; +use Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface; class Transaction implements TransactionInterface { @@ -23,6 +26,12 @@ class Transaction implements TransactionInterface protected $_scopeConfig; /* @var UrlInterface */ protected $_urlBuilder; + /* @var Coinpayments */ + protected $_coinpaymentsModel; + /* @var TransactionBuilder */ + protected $_transactionBuilder; + /* @var Logger */ + protected $_logger; /** * Transaction constructor. @@ -39,7 +48,10 @@ public function __construct( Curl $curl, ScopeConfigInterface $scopeConfig, Order $orderModel, - UrlInterface $urlBuilder + UrlInterface $urlBuilder, + Coinpayments $coinpaymentsModel, + BuilderInterface $transactionBuilder, + Logger $logger ) { $this->_quoteFactory = $quoteFactory; @@ -48,6 +60,9 @@ public function __construct( $this->_scopeConfig = $scopeConfig; $this->_orderModel = $orderModel; $this->_urlBuilder = $urlBuilder; + $this->_coinpaymentsModel = $coinpaymentsModel; + $this->_transactionBuilder = $transactionBuilder; + $this->_logger = $logger; } /** @@ -92,7 +107,7 @@ private function prepareCreateTransactionData($order, $currenctCurrency) 'buyer_email' => $order->getCustomerEmail(), 'buyer_name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'invoice' => $order->getIncrementId(), - 'ipn_url' => $this->_urlBuilder->getUrl('coinpayments/ipn/index') + 'ipn_url' => $this->_urlBuilder->getUrl('coinpayments/ipn/handle') ]; $this->_curl->addHeader('HMAC', hash_hmac('sha512', http_build_query($data), $secretKey)); @@ -100,6 +115,45 @@ private function prepareCreateTransactionData($order, $currenctCurrency) $this->_curl->post($coinpaymentsApi, $data); $response = json_decode($this->_curl->getBody()); + if ($response->error == 'OK') { + $this->addTransactionToOrder($order, $response); + } + return $response; } + + public function addTransactionToOrder(Order $order, $paymentData) { + try { + $payment = $order->getPayment(); + $payment->setMethod($this->_coinpaymentsModel->getCode()); + $payment->setLastTransId($paymentData['txn_id']); + $payment->setTransactionId($paymentData['txn_id']); + $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array) $paymentData]); + + $formatedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal()); + + /* @var BuilderInterface */ + $transaction = $this->_transactionBuilder + ->setPayment($payment) + ->setOrder($order) + ->setTransactionId($paymentData['txn_id']) + ->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array) $paymentData]) + ->setFailSafe(true) + ->build(Order\Payment\Transaction::TYPE_CAPTURE); + + // Add transaction to payment + $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); + $payment->setParentTransactionId(null); + + // Save payment, transaction and order + $payment->save(); + $order->save(); + $transaction->save(); + + return $transaction->getTransactionId(); + + } catch (\Exception $e) { + $this->_logger->info("Create transaction error. OrderId: " . $order->getId() . "\n. Message: " . $e->getMessage()); + } + } } \ No newline at end of file From be660737fd645d78c8f10bddd4181959bd4ef413 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Thu, 8 Nov 2018 22:36:35 +0200 Subject: [PATCH 011/107] add transaction to order after coinpayments transaction paid --- Model/AbstractIpn.php | 54 ++++++++++++++++++++++++++++++++++++++++++- Model/Ipn.php | 30 +++++++++++++++++------- Model/Transaction.php | 39 ------------------------------- 3 files changed, 75 insertions(+), 48 deletions(-) diff --git a/Model/AbstractIpn.php b/Model/AbstractIpn.php index 22b8825..c8075e7 100644 --- a/Model/AbstractIpn.php +++ b/Model/AbstractIpn.php @@ -5,6 +5,7 @@ use Coinpayments\CoinPayments\Helper\Data; use Magento\Sales\Model\Order; use Coinpayments\CoinPayments\Logger\Logger; +use Coinpayments\CoinPayments\Model\Methods\Coinpayments; class AbstractIpn @@ -21,6 +22,10 @@ class AbstractIpn protected $_hmac; + protected $_coinpaymentsModel; + + protected $_transactionBuilder; + /** * @var Order */ @@ -29,12 +34,17 @@ class AbstractIpn public function __construct( Order $orderModel, Data $helper, - Logger $logger + Logger $logger, + Coinpayments $coinpaymentsModel, + Order\Payment\Transaction\BuilderInterface $transactionBuilder ) { $this->_orderModel = $orderModel; $this->_helper = $helper; $this->_logger = $logger; + $this->_coinpaymentsModel = $coinpaymentsModel; + $this->_transactionBuilder = $transactionBuilder; + } protected function filterPaymentStatus($status) @@ -135,6 +145,48 @@ protected function updateOrderPayment() } return $this; } + + protected function addTransactionToOrder() + { + if ($this->filterPaymentStatus($this->_data->status) != Info::PAYMENT_STATUS_COMPLETE) { + return false; + } + try { + $payment = $this->_currentOrder->getPayment(); + $payment->setMethod($this->_coinpaymentsModel->getCode()); + $payment->setLastTransId($this->_data->txn_id); + $payment->setTransactionId($this->_data->txn_id); + $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$this->_data]); + + $formatedPrice = $this->_currentOrder->getBaseCurrency()->formatTxt($this->_currentOrder->getGrandTotal()); + + /* @var Order\Payment\Transaction\BuilderInterface */ + $transaction = $this->_transactionBuilder + ->setPayment($payment) + ->setOrder($this->_currentOrder) + ->setTransactionId($this->_data->txn_id) + ->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$this->_data]) + ->setFailSafe(true) + ->build(Order\Payment\Transaction::TYPE_CAPTURE); + + // Add transaction to payment + $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); + $payment->setParentTransactionId(null); + + // Save payment, transaction and order + $payment->save(); + $this->_currentOrder->save(); + $transaction->save(); + $this->logAndDie("Create transaction. OrderId: " . $this->_currentOrder->getId() . "\n. Transaction Id: " . $transaction->getTransactionId()); + return $transaction->getTransactionId(); + + } catch (\Exception $e) { + $this->logAndDie("Create transaction error. OrderId: " . $this->_currentOrder->getId() . "\n. Message: " . $e->getMessage()); + } + + return true; + } + /** * @return $this */ diff --git a/Model/Ipn.php b/Model/Ipn.php index 7845f01..c4abcd2 100644 --- a/Model/Ipn.php +++ b/Model/Ipn.php @@ -4,13 +4,20 @@ use Coinpayments\CoinPayments\Helper\Data; use Coinpayments\CoinPayments\Logger\Logger; +use Coinpayments\CoinPayments\Model\Methods\Coinpayments; use Magento\Sales\Model\Order; class Ipn extends AbstractIpn implements IpnInterface { - public function __construct(Order $orderModel, Data $helper, Logger $logger) + public function __construct( + Order $orderModel, + Data $helper, + Logger $logger, + Coinpayments $coinpaymentsModel, + Order\Payment\Transaction\BuilderInterface $transactionBuilder + ) { - parent::__construct($orderModel, $helper, $logger); + parent::__construct($orderModel, $helper, $logger, $coinpaymentsModel, $transactionBuilder); } public function processIpnRequest($data, $hmac) @@ -24,22 +31,29 @@ public function processIpnRequest($data, $hmac) ->logAndDie('REQUEST: ' . print_r($data, true)) ->logAndDie('HMAC: ' . $hmac); + if (!$order) { + $error['order'] = __('Order is not longer exist'); + $this->logAndDie(__('Order is not longer exist')); + return $error; + } + if (!$this->filterIpnType()) { $error['ipn_type'] = __('Invalid IPN type'); $this->logAndDie(__('Invalid IPN type')); return $error; } - if (!$this->checkHmac()) { - $error['hmac'] = __('Invalid HMAC signature'); - $this->logAndDie(__('Invalid HMAC signature')); - return $error; - } +// if (!$this->checkHmac()) { +// $error['hmac'] = __('Invalid HMAC signature'); +// $this->logAndDie(__('Invalid HMAC signature')); +// return $error; +// } $this ->updateOrderPayment() ->updateOrderStatus() - ->addToOrderHistory(); + ->addToOrderHistory() + ->addTransactionToOrder(); try { $order->save(); diff --git a/Model/Transaction.php b/Model/Transaction.php index 4867f0c..51a32a3 100644 --- a/Model/Transaction.php +++ b/Model/Transaction.php @@ -115,45 +115,6 @@ private function prepareCreateTransactionData($order, $currenctCurrency) $this->_curl->post($coinpaymentsApi, $data); $response = json_decode($this->_curl->getBody()); - if ($response->error == 'OK') { - $this->addTransactionToOrder($order, $response); - } - return $response; } - - public function addTransactionToOrder(Order $order, $paymentData) { - try { - $payment = $order->getPayment(); - $payment->setMethod($this->_coinpaymentsModel->getCode()); - $payment->setLastTransId($paymentData['txn_id']); - $payment->setTransactionId($paymentData['txn_id']); - $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array) $paymentData]); - - $formatedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal()); - - /* @var BuilderInterface */ - $transaction = $this->_transactionBuilder - ->setPayment($payment) - ->setOrder($order) - ->setTransactionId($paymentData['txn_id']) - ->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array) $paymentData]) - ->setFailSafe(true) - ->build(Order\Payment\Transaction::TYPE_CAPTURE); - - // Add transaction to payment - $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); - $payment->setParentTransactionId(null); - - // Save payment, transaction and order - $payment->save(); - $order->save(); - $transaction->save(); - - return $transaction->getTransactionId(); - - } catch (\Exception $e) { - $this->_logger->info("Create transaction error. OrderId: " . $order->getId() . "\n. Message: " . $e->getMessage()); - } - } } \ No newline at end of file From 7893719c93d5ee0a4a76158afe9e2b63203b7555 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Fri, 9 Nov 2018 10:23:15 +0200 Subject: [PATCH 012/107] update Ipn route --- Model/Ipn.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Model/Ipn.php b/Model/Ipn.php index c4abcd2..f309d96 100644 --- a/Model/Ipn.php +++ b/Model/Ipn.php @@ -33,21 +33,21 @@ public function processIpnRequest($data, $hmac) if (!$order) { $error['order'] = __('Order is not longer exist'); - $this->logAndDie(__('Order is not longer exist')); + $this->logAndDie($error['order']); return $error; } if (!$this->filterIpnType()) { $error['ipn_type'] = __('Invalid IPN type'); - $this->logAndDie(__('Invalid IPN type')); + $this->logAndDie($error['ipn_type']); return $error; } -// if (!$this->checkHmac()) { -// $error['hmac'] = __('Invalid HMAC signature'); -// $this->logAndDie(__('Invalid HMAC signature')); -// return $error; -// } + if (!$this->checkHmac()) { + $error['hmac'] = __('Invalid HMAC signature'); + $this->logAndDie($error['hmac']); + return $error; + } $this ->updateOrderPayment() @@ -58,8 +58,8 @@ public function processIpnRequest($data, $hmac) try { $order->save(); } catch (\Exception $e) { - $this->logAndDie(__('Error when save Order')); $error['order_save'] = __('Error when save Order'); + $this->logAndDie($error['order_save']); return $error; } $this->logAndDie(__('SUCCESS UPDATE ORDER')); From d33fd172809f3d9f826219456d39630f0c4fb1f5 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Fri, 9 Nov 2018 12:41:42 +0200 Subject: [PATCH 013/107] add logo --- view/frontend/web/images/logo.png | Bin 0 -> 2876 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 view/frontend/web/images/logo.png diff --git a/view/frontend/web/images/logo.png b/view/frontend/web/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4cc78a80875d05fc8e0d8f6a4d030724e502a0ef GIT binary patch literal 2876 zcmX|Dc{mi>8y;KMELpQ;46rJw@G(F8B$^ifXPG2@NLY|zOCvlbS z)XCn3fEWP)3|DY=PDCe*t8kA1KQP8Kz}*WR?iYCS4gl!rg$H6h@LoiqyB8McuM1jl zeggvHJas{i>K0Ioz)M~}II~+pUbeR^?L2PbJ+wVRdI%1kaQF#;pBE7W4EOW(4~B>9 zg8spUpX7h8At2yCEkwL7$lwnl(8Kp0d- z69QF-KsA)1DsZS49Hs*NcYzQbK%F2@Z#dG(7V8OVU!{3##F_&FSVfzFw)0UtCv&c?b7wV_48UT zcCBuUEy4hy(&X~$kJmJzFcOJhQL`Mh40cPgHvq)5^i()5GwL&MqK)w78MA14U@B8q zzI;9DFRI1Ftm=I-ygKckb>y6V=?GXZ&(=^*p%lewvt&TeOVmkrc<9cmXvwCrPNnJI z9Tg>e+KrS0ouRBQ6?Nvq{ZAU|jhP4S+eDRZ59gI+vOh^T9U^Pi-0dCPn|T?ocyKVR z$X4^8nE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_9lJ= zeeiNCg{e65yZ)K$!LxgJSch(!Ev5`EG&7RP@PM#AN$zRcY+r82UB~haa_pvy-6IKu zneRBOkx#w-)d{3NKc_O7D(45*1GVvrcVpRC=`HS&dmirNcpJCKfcn&d9mRX4?$@qS z>*mbq%DE4V(DH<~fIARRmfv@S1NU!SI06gG>Q0Ylohv(L{f5|dAvXSe9!4Z0_vQ93 zb~1L}6zJ4Azftv3s!d<3KU&kK#)J`4n_#*Nk24)f@_5nOKaF4n#$Z?8byA4jTonB> zOC#~jM|j2;iO56`iZ)e@3HOTnHF`!$7Z$2iIhZ3D=W5(76vLTq|1Hnqux8Mxm`*CgO{JLCb%*j^9iRseuV_ zqmTFYqnKEUjbmvl2zTDVYk8A+y9vLxmbOqj8;Ot399Yvzj!}8yFvXJrA>7a>SsSZd zLC+7Amlb$R=qVg`_|?l7c_$Bi6kzg`6r+JqQ>;sTKxs-%1!e4kw~ty~81KU4UY-XL zbP*KUKJ%v{DGak{kSWUlMLsKEuCk6FbCH*^U`D8)gy>MmXfG z^@UBEsMWl33l)9&Rzq6NHV9+dZ?SKOElMXAWAn3o*`tz)rq{Faf0tY&R43s{uNsoc z$rfl^#NO|etbjQ_I_nJn_3f?dy12;l$9>^zFAcoY8`c3+6gvc*b_z>!Ui+3=MM>wG z?^9K9A%J@X2-lW=A-1A*0B9@3GhM7VsextZ2)Ge+q;>xHmG9cBw$ut{gsWaFLj$|h z$Hn!Y$KJ(>OyMFUlA9Uf=8ox_btu{3|$P84RK5p>YgD(Em^ zcm1Uefp5coJL)Y+7&VhQ+NFuzvN#J#iykq^r>{PztTUa{OF-1(28%5o|1nC9&_kZs X%U{10%(AcjF};_KEsZJ--D3X-tYJ+I literal 0 HcmV?d00001 From 93aa7563733ff3b56ec65610d05c22bcf92ad1c6 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Fri, 9 Nov 2018 12:59:25 +0200 Subject: [PATCH 014/107] fix status --- Model/AbstractIpn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/AbstractIpn.php b/Model/AbstractIpn.php index c8075e7..4e39ac8 100644 --- a/Model/AbstractIpn.php +++ b/Model/AbstractIpn.php @@ -192,7 +192,7 @@ protected function addTransactionToOrder() */ protected function addToOrderHistory() { - $str = 'CoinPayments.net Payment Status: 1 ' . $this->_data->status_text . '
    '; + $str = 'CoinPayments.net Payment Status: ' . $this->_data->status . ' ' . $this->_data->status_text . '
    '; if ($this->_data->status == Info::PAYMENT_STATUS_COMPLETE) { $str .= 'Transaction ID: ' . $this->_data->txn_id From 4cd66b8ec374f658a85039cf31c68d1c2dc37847 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Tue, 13 Nov 2018 16:15:49 +0200 Subject: [PATCH 015/107] update readme --- README.md | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6c79d17..0c1a232 100644 --- a/README.md +++ b/README.md @@ -14,26 +14,19 @@ Grab the latest version by clicking the Releases tab. Then come back here for in

    Installation

    Composer driven installation coming soon , for now please use manual approach described below.

    -1. Create backups of your web directory and Magento 2 store database;
    -2. Download Coinpayments CoinPayments Magento 2 Extension installation package;
    -3. Unzip (extract from zip archive) file and copy to /app/code/Coinpayments/CoinPayments/ folder (create it manually!)
    -4. Navigate to your store root folder in the SSH console of your server:

    - -cd path_to_the_store_root_folder
    - -And run the following commands:
    - -php -f bin/magento module:enable Coinpayments_CoinPayments
    -php -f bin/magento setup:upgrade
    - -5. Now, you have to flush store cache; log out from your backend and login once again. Use the following command:
    - -php -f bin/magento cache:clean

    - +

    To install module through composer please type:

    +
      +
    1. cd /your/magento2/dir
    2. +
    3. Add module to composer.json - composer require coinpaymentsnet/magento2
    4. +
    5. Reinstall composer - composer install
    6. +
    7. Enable Coinpayments module - bin/magento module:enable Coinpayments_Coinpayments
    8. +
    9. Upgrade your modules - bin/magento setup:upgrade
    10. +
    11. Flush cache - bin/magento c:f
    12. +
    +

    Setting Up

    +
      +
    • Login to your admin account
    • +
    • Follow this way Stores->Configuration->Payment->Payment Methods
    • +
    • Put values int to the form. Keys you can find in your account here Coinpayments
    • +
    Congratulations! The Coinpayments CoinPayments Magento 2 Bitcoin/Ethereum/Altcoin module is successfully installed. Now, you should configure your new Magento 2 cryptocurrency payment gateway. - -

    User Experience

    -

    From the frontend perspective, you should add a product to cart and proceed to checkout. Complete the first step in order to be able to select a payment method. Select "Coin Payments" and you will see the following message:

    -

    magento 2 bitcoin checkout

    -

    Now, you are on the CoinPayments platform. Choose your altcoin, and complete the checkout. Alternatively, you can cancel it and return to seller's store, contact seller directly from the cryptocurrency payment gateway page, or view profile.

    -

    send bitcoin magento 2

    From d424d0976a622947c9e457db9e38cfb36959d0c5 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Tue, 13 Nov 2018 16:20:01 +0200 Subject: [PATCH 016/107] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c1a232..8db0287 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,16 @@ Grab the latest version by clicking the Releases tab. Then come back here for in

    Installation

    Composer driven installation coming soon , for now please use manual approach described below.

    -

    To install module through composer please type:

    +

    To install module through composer please type:

      -
    1. cd /your/magento2/dir
    2. +
    3. Open your magento 2 dir - cd /your/magento2/dir
    4. Add module to composer.json - composer require coinpaymentsnet/magento2
    5. Reinstall composer - composer install
    6. Enable Coinpayments module - bin/magento module:enable Coinpayments_Coinpayments
    7. Upgrade your modules - bin/magento setup:upgrade
    8. Flush cache - bin/magento c:f
    -

    Setting Up

    +

    Setting Up

    • Login to your admin account
    • Follow this way Stores->Configuration->Payment->Payment Methods
    • From 7b2f80e8629970f201ba0e9a70ce30e9026f1025 Mon Sep 17 00:00:00 2001 From: Litahrts Date: Thu, 22 Nov 2018 10:49:35 +0200 Subject: [PATCH 017/107] Payment currency --- Model/Api/Base.php | 115 ++++++++++++++++++ Model/Api/Rate.php | 59 +++++++++ Model/Api/Transaction.php | 73 +++++++++++ Model/Config/Source/Currency.php | 48 ++++++++ Model/Transaction.php | 80 ++---------- etc/adminhtml/system.xml | 15 +-- etc/config.xml | 1 + .../templates/coinpayments/status.phtml | 2 - 8 files changed, 310 insertions(+), 83 deletions(-) create mode 100644 Model/Api/Base.php create mode 100644 Model/Api/Rate.php create mode 100644 Model/Api/Transaction.php create mode 100644 Model/Config/Source/Currency.php diff --git a/Model/Api/Base.php b/Model/Api/Base.php new file mode 100644 index 0000000..0aa9ef4 --- /dev/null +++ b/Model/Api/Base.php @@ -0,0 +1,115 @@ + 'application/x-www-form-urlencoded' + ]; + + /** + * Base constructor. + * @param Curl $curl + * @param ScopeConfigInterface $scopeConfig + */ + public function __construct + ( + Curl $curl, + ScopeConfigInterface $scopeConfig + ) + { + $this->_curl = $curl; + $this->_scopeConfig = $scopeConfig; + } + + /** + * @param $base + * @param $field + * @return mixed + */ + protected function getConfig($base, $field) + { + if ($field) { + return $this->_scopeConfig->getValue($base . DIRECTORY_SEPARATOR . $field); + } + return $this->_scopeConfig->getValue($base); + } + + /** + * @param null $field + * @return mixed + */ + public function getPaymentConfig($field = null) + { + return $this->getConfig('payment/coin_payments', $field); + } + + /** + * @param null $field + * @return mixed + */ + public function getBaseConfig($field = null) + { + return $this->getConfig('coinpayment/conf', $field); + + } + + /** + * @param $data + * @param $cmd + * @param array $headers + * @param string $method + * @param bool $assoc + * @return mixed + */ + public function sendRequest($data, $cmd, $headers = [], $method = 'post', $assoc = false) + { + $paymentConf = $this->getPaymentConfig(); + $baseConf = $this->getBaseConfig(); + $additionalData = [ + 'version' => $baseConf['api_version'], + 'cmd' => $cmd, + 'key' => $paymentConf['public_key'] + ]; + + $data = array_merge($data, $additionalData); + $headers = array_merge($headers, $this->_defaultHeaders); + + $this->_curl->addHeader('HMAC', $this->generateHmac($data)); + foreach ($headers as $name => $value) { + $this->_curl->addHeader($name, $value); + } + $this->_curl->$method($baseConf['api_payment'], $data); + + return json_decode($this->_curl->getBody(), $assoc); + } + + /** + * @param $data + * @param null $secretKey + * @return string + */ + public function generateHmac($data, $secretKey = null) + { + if (!$secretKey) { + $secretKey = $this->getPaymentConfig('secret_key'); + } + return hash_hmac('sha512', http_build_query($data), $secretKey); + } +} \ No newline at end of file diff --git a/Model/Api/Rate.php b/Model/Api/Rate.php new file mode 100644 index 0000000..e5fcee2 --- /dev/null +++ b/Model/Api/Rate.php @@ -0,0 +1,59 @@ + $accepted]; + $rates = $this->sendRequest($data, 'rates', [], 'post', $assoc); + return $rates; + } + + + //TODO normal logic for exchange rate + /** + * @param $currency + * @param $amount + * @return float|int + */ + public function getConverted($currency, $amount) + { + $ratesData = $this->fetchRates(false, false); + + if (strtolower($ratesData->error) != 'ok') { + return 0; + } + $rates = $ratesData->result; + + $rate = $currency != 'BTC' ? + ($amount * $rates->USD->rate_btc) / $rates->$currency->rate_btc : + $amount * $rates->USD->rate_btc; + return round($rate, 8); + } +} \ No newline at end of file diff --git a/Model/Api/Transaction.php b/Model/Api/Transaction.php new file mode 100644 index 0000000..444580e --- /dev/null +++ b/Model/Api/Transaction.php @@ -0,0 +1,73 @@ +_urlBuilder = $urlBuilder; + $this->_logger = $logger; + $this->_rate = $rate; + parent::__construct($curl, $scopeConfig); + } + + /** + * @param Order $order + * @param string $customerCurrency + * @param array $headers + * @return array|mixed + */ + public function create($order, $customerCurrency, $headers = []) + { + $data = [ + 'amount' => $this->_rate->getConverted($customerCurrency, $order->getBaseGrandTotal()), + 'currency1' => $customerCurrency, + 'currency2' => $this->getPaymentConfig('receive_currency'), + 'buyer_email' => $order->getCustomerEmail(), + 'buyer_name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), + 'invoice' => $order->getIncrementId(), + 'ipn_url' => $this->_urlBuilder->getUrl('coinpayments/ipn/handle') + ]; + + $this->_logger->info('ORDER ' . $order->getId() . ' transaction request: ' . print_r($data, true)); + $data = $this->sendRequest($data, 'create_transaction', $headers, 'post', false); + $this->_logger->info('ORDER ' . $order->getId() . ' transaction response: ' . print_r($data, true)); + return $data; + } +} \ No newline at end of file diff --git a/Model/Config/Source/Currency.php b/Model/Config/Source/Currency.php new file mode 100644 index 0000000..e639223 --- /dev/null +++ b/Model/Config/Source/Currency.php @@ -0,0 +1,48 @@ +_coinpaymentsRate = $coinpaymentsRate; + } + + /** + * @return array + */ + public function toOptionArray() + { + $response = $this->_coinpaymentsRate->fetchRates(true, true); + $currencies = []; + $currencies[] = [ + 'value' => '', + 'label' => self::UNDEFINED_OPTION_LABEL + ]; + + if ($response['error'] == 'ok') { + foreach ($response['result'] as $key => $item) { + $currencies[] = [ + 'value' => $key, + 'label' => $item['name'], + ]; + } + } else { + $currencies[] = ['value' => '', 'label' => $response['error']]; + } + return $currencies; + } +} diff --git a/Model/Transaction.php b/Model/Transaction.php index 51a32a3..17c75e8 100644 --- a/Model/Transaction.php +++ b/Model/Transaction.php @@ -1,16 +1,11 @@ _quoteFactory = $quoteFactory; $this->_checkoutSession = $checkoutSession; - $this->_curl = $curl; - $this->_scopeConfig = $scopeConfig; - $this->_orderModel = $orderModel; - $this->_urlBuilder = $urlBuilder; - $this->_coinpaymentsModel = $coinpaymentsModel; - $this->_transactionBuilder = $transactionBuilder; - $this->_logger = $logger; + $this->_apiTransaction = $apiTransaction; } /** @@ -79,42 +47,10 @@ public function createTransaction($cartId, $currency, $value) if (!$order->getId() && !$quote->getId()) { return false; } - $data = $this->prepareCreateTransactionData($order, $currency); + $data = $this->_apiTransaction->create($order, $currency); $this->_checkoutSession->setCoinpaymentsCurrency($currency); $this->_checkoutSession->setCoinpaymentsCurrencyTotal($value); $this->_checkoutSession->setCoinpaymentsTransactionData(json_encode($data)); return true; } - - /** - * @param $order - * @return mixed - */ - private function prepareCreateTransactionData($order, $currenctCurrency) - { - $scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE; - $secretKey = $this->_scopeConfig->getValue('payment/coin_payments/secret_key', $scope); - $publicKey = $this->_scopeConfig->getValue('payment/coin_payments/public_key', $scope); - $coinpaymentsApi = $this->_scopeConfig->getValue('coinpayment/conf/api_payment', $scope); - - $data = [ - 'version' => 1, - 'cmd' => 'create_transaction', - 'key' => $publicKey, - 'amount' => $order->getBaseGrandTotal(), - 'currency1' => $order->getOrderCurrencyCode(), - 'currency2' => $currenctCurrency, - 'buyer_email' => $order->getCustomerEmail(), - 'buyer_name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), - 'invoice' => $order->getIncrementId(), - 'ipn_url' => $this->_urlBuilder->getUrl('coinpayments/ipn/handle') - ]; - - $this->_curl->addHeader('HMAC', hash_hmac('sha512', http_build_query($data), $secretKey)); - $this->_curl->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - $this->_curl->post($coinpaymentsApi, $data); - $response = json_decode($this->_curl->getBody()); - - return $response; - } } \ No newline at end of file diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index d51771a..fe68bdd 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -15,6 +15,11 @@ Magento\Config\Model\Config\Source\Yesno + + + Coinpayments\CoinPayments\Model\Config\Source\Currency + + Magento\Config\Model\Config\Source\Yesno @@ -27,49 +32,41 @@ Account Settings -> Basic Settings -> Your Merchant ID.]]> - - - + - - Magento\Payment\Model\Config\Source\Allspecificcountries - Magento\Directory\Model\Config\Source\Country 1 - Magento\Sales\Model\Config\Source\Order\Status\NewStatus - Magento\Sales\Model\Config\Source\Order\Status - Magento\Config\Model\Config\Source\Yesno diff --git a/etc/config.xml b/etc/config.xml index 7eca386..49ad4a9 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -22,6 +22,7 @@ https://www.coinpayments.net https://www.coinpayments.net/api.php + 1 ` diff --git a/view/frontend/templates/coinpayments/status.phtml b/view/frontend/templates/coinpayments/status.phtml index 636054d..a1d1918 100644 --- a/view/frontend/templates/coinpayments/status.phtml +++ b/view/frontend/templates/coinpayments/status.phtml @@ -1,8 +1,6 @@ getTransactionData(); $currency = $block->getTransactionCurrency(); - -print_r($transactionData); ?>
      From 4881da98609b497526dd9f67a8f1315a49046c35 Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Wed, 1 May 2019 22:15:21 +0300 Subject: [PATCH 018/107] Prevent undefined index warning if run first time --- Model/Api/Base.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Model/Api/Base.php b/Model/Api/Base.php index 0aa9ef4..a0ad9ad 100644 --- a/Model/Api/Base.php +++ b/Model/Api/Base.php @@ -82,6 +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,4 +116,4 @@ public function generateHmac($data, $secretKey = null) } return hash_hmac('sha512', http_build_query($data), $secretKey); } -} \ No newline at end of file +} From 1ef94518578fdae6493831e9774b86c0120cb8b1 Mon Sep 17 00:00:00 2001 From: Yannis Livasov Date: Fri, 3 May 2019 15:43:59 +0300 Subject: [PATCH 019/107] Fix list accepted coins Squashed commits --- .DS_Store | Bin 0 -> 6148 bytes Model/CoinPaymentsConfigProvider.php | 8 +++++++- .../view/payment/method-renderer/coin-method.js | 9 +++++++-- .../web/template/payment/coin_payment_form.html | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8938c2891a605566c52de61679c3bc803611e79e GIT binary patch literal 6148 zcmeHKJ5Iwu5S>X2jB+0`2dcrP*R{b z(#-SD&Rff`@a%|)?vCwNWFsPLxS^aZ%+2=AXST@93aEC*c7N!*VOIBB!njMhl|i1K zAEx}p&CgEPH%)tdIf%S{yubQ!$?5v`!p`tGJ*_y2feKIoDnJFO02Q#FZMMD&WTXOA zfC_voVE=~#H>`U;kuBZSN_*V+(s@XR?d{Xw- y*~eM0E%1Bzm!a0n5xf-xy%l3&t@wIUSL_-4HE|4dI`U2j@*-fm(5S#)DDVloAteI< literal 0 HcmV?d00001 diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 6d910d6..fd0789e 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -71,12 +71,17 @@ public function getConfig() $currencies = ['error' => $response->error]; if ($response->error == 'ok') { $currencies = []; + $acceptedCurrencies = []; foreach ($response->result as $key => $item) { - $currencies[] = [ + $elm = [ 'value' => $key, 'body' => $item, 'name' => $item->name ]; + $currencies[] = $elm; + if (isset($item->accepted) && $item->accepted == '1') { + $acceptedCurrencies[] = $elm; + } } } @@ -84,6 +89,7 @@ public function getConfig() 'payment' => [ 'coinpayments' => [ 'available_currencies' => $currencies, + 'accepted_currencies' => $acceptedCurrencies, 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), 'direct_mode' => (int)$isDirect, 'url' => $coinpaymentsDomain, 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 d6af498..dcb27bb 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 @@ -122,7 +122,12 @@ define( if (!window.checkoutConfig.payment.coinpayments.available_currencies.error) { return window.checkoutConfig.payment.coinpayments.available_currencies; } - + return [{error: "error"}]; + }, + getAcceptedCurrencies: function () { + if (!window.checkoutConfig.payment.coinpayments.accepted_currencies.error) { + return window.checkoutConfig.payment.coinpayments.accepted_currencies; + } return [{error: "error"}]; }, getPaymentAcceptanceMarkSrc: function () { @@ -236,4 +241,4 @@ define( } }); } -); \ No newline at end of file +); diff --git a/view/frontend/web/template/payment/coin_payment_form.html b/view/frontend/web/template/payment/coin_payment_form.html index ef46232..edb43ab 100644 --- a/view/frontend/web/template/payment/coin_payment_form.html +++ b/view/frontend/web/template/payment/coin_payment_form.html @@ -13,7 +13,7 @@ attr: {id: getCode() + '_crypto_currency', 'data-container': getCode() + '_crypto_currency'}, event: { change: getConvertedAmount}, enable: 1, - options: getCurrencies(), + options: getAcceptedCurrencies(), optionsValue: 'value', optionsText: 'name', optionsCaption: $t('Currency')"> @@ -35,4 +35,4 @@
      - \ No newline at end of file + From 4bb7333833ea7ed1bde5f6bc6a6c311bb797ce24 Mon Sep 17 00:00:00 2001 From: grumpy-dog Date: Sat, 4 May 2019 16:53:24 +0300 Subject: [PATCH 020/107] direct mode fix transaction currencies --- Model/Api/Transaction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Api/Transaction.php b/Model/Api/Transaction.php index 444580e..0ba6461 100644 --- a/Model/Api/Transaction.php +++ b/Model/Api/Transaction.php @@ -57,8 +57,8 @@ public function create($order, $customerCurrency, $headers = []) { $data = [ 'amount' => $this->_rate->getConverted($customerCurrency, $order->getBaseGrandTotal()), - 'currency1' => $customerCurrency, - 'currency2' => $this->getPaymentConfig('receive_currency'), + 'currency1' => $this->getPaymentConfig('receive_currency'), + 'currency2' => $customerCurrency, 'buyer_email' => $order->getCustomerEmail(), 'buyer_name' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'invoice' => $order->getIncrementId(), From 0bfc0c1e81a1f1f2ed3747ed8f8ae1d4e428c5bd Mon Sep 17 00:00:00 2001 From: grumpy-dog Date: Sat, 4 May 2019 16:55:43 +0300 Subject: [PATCH 021/107] direct mode fix default amount --- .../web/js/view/payment/method-renderer/coin-method.js | 6 ++++++ view/frontend/web/template/payment/coin_payment_form.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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 dcb27bb..d41acf6 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 @@ -143,6 +143,12 @@ define( getBaseGrandTotal: function () { return window.checkoutConfig.totalsData.base_grand_total; }, + getGrandTotal: function () { + return window.checkoutConfig.totalsData.grand_total; + }, + getCurrencyCode: function () { + return window.checkoutConfig.totalsData.quote_currency_code; + }, /** * * @param element diff --git a/view/frontend/web/template/payment/coin_payment_form.html b/view/frontend/web/template/payment/coin_payment_form.html index edb43ab..b637306 100644 --- a/view/frontend/web/template/payment/coin_payment_form.html +++ b/view/frontend/web/template/payment/coin_payment_form.html @@ -23,7 +23,7 @@
      Date: Sat, 4 May 2019 16:56:17 +0300 Subject: [PATCH 022/107] redirect mode fix transaction amount --- .../templates/coinpayments/iframe.phtml | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/view/frontend/templates/coinpayments/iframe.phtml b/view/frontend/templates/coinpayments/iframe.phtml index 210311f..7a98c57 100644 --- a/view/frontend/templates/coinpayments/iframe.phtml +++ b/view/frontend/templates/coinpayments/iframe.phtml @@ -1,53 +1,53 @@ - - */ -// Retrieve order -$orderId = $block->getLastOrderId(); -$payemntData = $block->getPaymentData(); -$quoteData = $block->getQuote(); -$successUrl = $block->getSuccessUrl(); -$failUrl = $block->getFailUrl(); -?> -
      - - - - - - - - - - - - - - - - - - - - -
      - \ No newline at end of file From 6bed3a1f1ed2a0ae3cdf190404fb9e63e887bf3e Mon Sep 17 00:00:00 2001 From: grumpy-dog Date: Sat, 4 May 2019 17:12:41 +0300 Subject: [PATCH 023/107] remove garbage --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8938c2891a605566c52de61679c3bc803611e79e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5Iwu5S>X2jB+0`2dcrP*R{b z(#-SD&Rff`@a%|)?vCwNWFsPLxS^aZ%+2=AXST@93aEC*c7N!*VOIBB!njMhl|i1K zAEx}p&CgEPH%)tdIf%S{yubQ!$?5v`!p`tGJ*_y2feKIoDnJFO02Q#FZMMD&WTXOA zfC_voVE=~#H>`U;kuBZSN_*V+(s@XR?d{Xw- y*~eM0E%1Bzm!a0n5xf-xy%l3&t@wIUSL_-4HE|4dI`U2j@*-fm(5S#)DDVloAteI< From fcefeebf74fa357df91e00614200cde19a2df79f Mon Sep 17 00:00:00 2001 From: Pieter Poorthuis Date: Mon, 24 Jun 2019 15:03:39 +0200 Subject: [PATCH 024/107] M2.3 CSRF fix (not compatible with M2.2/M2.1) --- Controller/Ipn/Index.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index c9870c7..cf27baa 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -16,7 +16,7 @@ * * @package Firebear\CoinPayments\Controller\Ipn */ -class Index extends \Magento\Framework\App\Action\Action +class Index extends \Magento\Framework\App\Action\Action implements \Magento\Framework\App\CsrfAwareActionInterface { /** * @var \Magento\Sales\Model\OrderRepository @@ -51,8 +51,19 @@ public function __construct( $this->log = $logger; $this->helper = $helper; parent::__construct($context); + } - + public function createCsrfValidationException(\Magento\Framework\App\RequestInterface $request): ?\Magento\Framework\App\Request\InvalidRequestException + { + return null; + } + + public function validateForCsrf(\Magento\Framework\App\RequestInterface $request): ?bool + { + return true; + } + + public function execute() { if ($this->getRequest()->getParams()) { From 5b9c16c2eed74f82aa9d78f871b6eb3b6139e37f Mon Sep 17 00:00:00 2001 From: Pieter Poorthuis Date: Mon, 24 Jun 2019 15:16:29 +0200 Subject: [PATCH 025/107] Backwards compatible CSRF fix --- Controller/Ipn/Index.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Controller/Ipn/Index.php b/Controller/Ipn/Index.php index cf27baa..44787a6 100644 --- a/Controller/Ipn/Index.php +++ b/Controller/Ipn/Index.php @@ -10,13 +10,15 @@ use Magento\Framework\App\Action\Context; use Coinpayments\CoinPayments\Logger\Logger; use Coinpayments\CoinPayments\Helper\Data as CoinPaymentHelper; +use Magento\Framework\App\Request\Http as HttpRequest; + /** * Class Index * * @package Firebear\CoinPayments\Controller\Ipn */ -class Index extends \Magento\Framework\App\Action\Action implements \Magento\Framework\App\CsrfAwareActionInterface +class Index extends \Magento\Framework\App\Action\Action { /** * @var \Magento\Sales\Model\OrderRepository @@ -47,21 +49,21 @@ public function __construct( Logger $logger, CoinPaymentHelper $helper ) { + parent::__construct($context); + $this->orderRepository = $orderRepository; $this->log = $logger; $this->helper = $helper; - parent::__construct($context); - - } - public function createCsrfValidationException(\Magento\Framework\App\RequestInterface $request): ?\Magento\Framework\App\Request\InvalidRequestException - { - return null; + // Fix for Magento2.3 adding isAjax to the request params + if(interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) { + $request = $this->getRequest(); + if ($request instanceof HttpRequest && $request->isPost()) { + $request->setParam('isAjax', true); + } } - public function validateForCsrf(\Magento\Framework\App\RequestInterface $request): ?bool - { - return true; - } + + } public function execute() From 3695fd21b898521b2bde70898b024de9d4ac8f3a Mon Sep 17 00:00:00 2001 From: Christopher Silvey Date: Wed, 21 Aug 2019 13:06:14 -0500 Subject: [PATCH 026/107] IPN Fix This fixes issues where the IPN call is not successful on Magento 2.3.x --- Controller/Ipn/Handle.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Controller/Ipn/Handle.php b/Controller/Ipn/Handle.php index 0361997..1ad7870 100644 --- a/Controller/Ipn/Handle.php +++ b/Controller/Ipn/Handle.php @@ -7,8 +7,11 @@ use Magento\Framework\App\Action\Context; use Magento\Framework\Controller\Result\JsonFactory; use Magento\Sales\Model\Order; +use Magento\Framework\App\CsrfAwareActionInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\App\Request\InvalidRequestException; -class Handle extends Action +class Handle extends Action implements CsrfAwareActionInterface { protected $_orderModel; @@ -35,18 +38,34 @@ public function execute() { $requestData = (object)$this->getRequest()->getParams(); $hmac = $this->getRequest()->getHeaders()->get('HMAC')->getFieldValue(); + $result = $this->_jsonResultFactory->create(); + if (!$requestData || !$hmac) { $result->setData([ 'error' => __('Invalid Data Sent') ]); return $result; } + $errors = $this->_ipnModel->processIpnRequest($requestData, $hmac); + if (!empty($errors)) { $result->setData($errors); return $result; } + return $result->setData(['error' => 'OK']); } -} \ No newline at end of file + + public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException + { + return null; + } + + public function validateForCsrf(RequestInterface $request): ?bool + { + return true; + } + +} From a4d219baf7dfb29d85e21b13804198cbd2002ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crypto=C2=B2?= Date: Wed, 21 Aug 2019 21:58:54 -0400 Subject: [PATCH 027/107] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bb3fd76..0251205 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.5.0|~5.6.0|~7.0.0|~7.1" }, "type": "magento2-module", - "version": "1.1.0", + "version": "1.4.0", "license": [ "OSL-3.0" ], From 69a531eb62dd10cdb9c96ff3a6c1ac340ea65677 Mon Sep 17 00:00:00 2001 From: Christopher Silvey Date: Fri, 23 Aug 2019 23:11:13 -0500 Subject: [PATCH 028/107] Update README.md Updated the module name since the module is defined as Coinpayments_CoinPayments and not Coinpayments_Coinpayments. It will not enable without the capital P in the module name. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8db0287..80bae3e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Composer driven installation coming soon , for now please use manual approach de
    • Open your magento 2 dir - cd /your/magento2/dir
    • Add module to composer.json - composer require coinpaymentsnet/magento2
    • Reinstall composer - composer install
    • -
    • Enable Coinpayments module - bin/magento module:enable Coinpayments_Coinpayments
    • +
    • Enable Coinpayments module - bin/magento module:enable Coinpayments_CoinPayments
    • Upgrade your modules - bin/magento setup:upgrade
    • Flush cache - bin/magento c:f
    • From 7e742b56be180ce9a4e7bfc29cf837f5a1b5d881 Mon Sep 17 00:00:00 2001 From: Christopher Silvey Date: Sat, 24 Aug 2019 09:04:07 -0500 Subject: [PATCH 029/107] Obscured secret and private key settings Obscured the admin IPN secret and private key settings as this info should not be visible for security reasons. --- etc/adminhtml/system.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index fe68bdd..f490c0b 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -32,16 +32,16 @@ Account Settings -> Basic Settings -> Your Merchant ID.]]> - + - - + + - - + + @@ -74,4 +74,4 @@
    - \ No newline at end of file + From 83a4e77ed598252623fdf41bddb10ae4f0df2139 Mon Sep 17 00:00:00 2001 From: Christopher Silvey Date: Tue, 27 Aug 2019 03:48:57 -0500 Subject: [PATCH 030/107] Reverting Obscure I had to temporarily revert the obscure addition b/c I forgot to include the model type and to decrypt the secret keys afterwards. I'll put the full fix in soon. --- etc/adminhtml/system.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index f490c0b..1e575cd 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -32,7 +32,7 @@ Account Settings -> Basic Settings -> Your Merchant ID.]]> - + @@ -40,7 +40,7 @@ - + From c6ea258fc942ce24880a39dd508d9d1872d7ade5 Mon Sep 17 00:00:00 2001 From: letscode Date: Fri, 15 Nov 2019 00:05:57 +0200 Subject: [PATCH 031/107] Update release version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0251205..153fadd 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.5.0|~5.6.0|~7.0.0|~7.1" }, "type": "magento2-module", - "version": "1.4.0", + "version": "1.5.0", "license": [ "OSL-3.0" ], From 4cb94d7a0e7070a7c50696024219490d6e369438 Mon Sep 17 00:00:00 2001 From: letscode Date: Fri, 10 Jan 2020 13:50:47 +0200 Subject: [PATCH 032/107] Magento 2 api v2 integration without webhooks --- .gitignore | 2 + Api/CurrencyInterface.php | 30 + Api/InvoiceInterface.php | 36 + Api/WebHookInterface.php | 13 + Controller/Adminhtml/Validation/Invoice.php | 44 ++ .../Adminhtml/Validation/Validation.php | 52 ++ Controller/Adminhtml/Validation/WebHook.php | 96 +++ LICENSE | 674 ++++++++++++++++++ Model/Api/Currency.php | 161 +++++ Model/Api/Invoice.php | 107 +++ Model/Api/WebHook.php | 81 +++ Model/ApiProvider.php | 174 +++++ Model/CoinPaymentsConfigProvider.php | 99 +++ Model/Methods/Coinpayments.php | 61 ++ README.md | 0 composer.json | 21 + etc/acl.xml | 9 + etc/adminhtml/routes.xml | 8 + etc/adminhtml/system.xml | 75 ++ etc/config.xml | 21 + etc/di.xml | 6 + etc/frontend/di.xml | 13 + etc/frontend/routes.xml | 8 + etc/module.xml | 12 + etc/payment.xml | 14 + etc/webapi.xml | 22 + registration.php | 7 + .../layout/adminhtml_system_config_edit.xml | 14 + view/adminhtml/requirejs-config.js | 6 + view/adminhtml/templates/js_vars.phtml | 8 + view/adminhtml/web/images/logo.png | Bin 0 -> 6130 bytes view/adminhtml/web/js/invoice-validate.js | 38 + view/adminhtml/web/js/webhooks-validate.js | 48 ++ view/adminhtml/web/styles.css | 30 + view/frontend/layout/checkout_index_index.xml | 56 ++ view/frontend/web/images/logo.png | Bin 0 -> 2876 bytes .../web/js/action/set-payment-method.js | 56 ++ .../js/model/validate-selected-currency.js | 28 + .../web/js/view/payment/coin_payments.js | 22 + .../payment/method-renderer/coin-method.js | 275 +++++++ .../payment/validate-selected-currency.js | 16 + .../web/template/payment/coin_payment.html | 87 +++ 42 files changed, 2530 insertions(+) create mode 100644 .gitignore create mode 100644 Api/CurrencyInterface.php create mode 100644 Api/InvoiceInterface.php create mode 100644 Api/WebHookInterface.php create mode 100644 Controller/Adminhtml/Validation/Invoice.php create mode 100644 Controller/Adminhtml/Validation/Validation.php create mode 100644 Controller/Adminhtml/Validation/WebHook.php create mode 100644 LICENSE create mode 100644 Model/Api/Currency.php create mode 100644 Model/Api/Invoice.php create mode 100644 Model/Api/WebHook.php create mode 100644 Model/ApiProvider.php create mode 100644 Model/CoinPaymentsConfigProvider.php create mode 100644 Model/Methods/Coinpayments.php create mode 100644 README.md create mode 100644 composer.json create mode 100644 etc/acl.xml create mode 100644 etc/adminhtml/routes.xml create mode 100644 etc/adminhtml/system.xml create mode 100644 etc/config.xml create mode 100644 etc/di.xml create mode 100644 etc/frontend/di.xml create mode 100644 etc/frontend/routes.xml create mode 100644 etc/module.xml create mode 100644 etc/payment.xml create mode 100644 etc/webapi.xml create mode 100644 registration.php create mode 100644 view/adminhtml/layout/adminhtml_system_config_edit.xml create mode 100644 view/adminhtml/requirejs-config.js create mode 100644 view/adminhtml/templates/js_vars.phtml create mode 100644 view/adminhtml/web/images/logo.png create mode 100644 view/adminhtml/web/js/invoice-validate.js create mode 100644 view/adminhtml/web/js/webhooks-validate.js create mode 100644 view/adminhtml/web/styles.css create mode 100644 view/frontend/layout/checkout_index_index.xml create mode 100644 view/frontend/web/images/logo.png create mode 100644 view/frontend/web/js/action/set-payment-method.js create mode 100644 view/frontend/web/js/model/validate-selected-currency.js create mode 100644 view/frontend/web/js/view/payment/coin_payments.js create mode 100644 view/frontend/web/js/view/payment/method-renderer/coin-method.js create mode 100644 view/frontend/web/js/view/payment/validate-selected-currency.js create mode 100644 view/frontend/web/template/payment/coin_payment.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b9bd87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.bak diff --git a/Api/CurrencyInterface.php b/Api/CurrencyInterface.php new file mode 100644 index 0000000..0d0e648 --- /dev/null +++ b/Api/CurrencyInterface.php @@ -0,0 +1,30 @@ +getRequest()->getParams(); + + $response = []; + if (!empty($params['client_id'])) { + $clientId = $params['client_id']; + $invoice = $this->invoiceModel->createSimple($clientId); + if ($invoice) { + $response = [ + 'success' => $invoice + ]; + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Failed to create validation invoice!'), + ]; + } + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Enter Coinpaymnets.NET credentials!'), + ]; + } + + $result = $this->jsonResultFactory->create(); + $result->setData($response); + return $result; + } +} \ No newline at end of file diff --git a/Controller/Adminhtml/Validation/Validation.php b/Controller/Adminhtml/Validation/Validation.php new file mode 100644 index 0000000..5ab3f50 --- /dev/null +++ b/Controller/Adminhtml/Validation/Validation.php @@ -0,0 +1,52 @@ +jsonResultFactory = $jsonResultFactory; + $this->webHookModel = $webHook; + $this->invoiceModel = $invoice; + } + + public function execute() + { + + } +} \ No newline at end of file diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php new file mode 100644 index 0000000..0701536 --- /dev/null +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -0,0 +1,96 @@ + 'notif-url', +// "notifications" => [ +// 2, +// 4 +// ], +// ]) +// ) +// ]; +// +// $equal = sprintf('%s%s%s%s', chr(239), chr(187), chr(191), implode('', $signatureData)) == $signatureString; +// +// $imploded = implode('', $signatureData); +// $signature = $this->webHookModel->generateHmac($signatureData, 'secret'); + + $params = $this->getRequest()->getParams(); + $response = []; + + if (!empty($params['client_id']) && !empty($params['client_secret'])) { + + $client_id = $params['client_id']; + $client_secret = $params['client_secret']; + + $webHooksList = $this->webHookModel->getList($client_id, $client_secret); + + if (!empty($webHooksList)) { + + $webHooksUrlsList = []; + if (!empty($webHooksList['items'])) { + $webHooksUrlsList = array_map(function ($webHook) { + return $webHook['notificationsUrl']; + }, $webHooksList['items']); + } + + if (!in_array($this->webHookModel->getWebHookCallbackUrl(), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($client_id, $client_secret); + if (!empty($webHook)) { + $response = [ + 'success' => $webHook, + ]; + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Failed to create WebHook!'), + ]; + } + } else { + $response = [ + 'success' => true, + ]; + } + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Failed to get WebHooks list!'), + ]; + } + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Enter Coinpaymnets.NET credentials!'), + ]; + } + + + $result = $this->jsonResultFactory->create(); + $result->setData($response); + return $result; + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Model/Api/Currency.php b/Model/Api/Currency.php new file mode 100644 index 0000000..5aadb3c --- /dev/null +++ b/Model/Api/Currency.php @@ -0,0 +1,161 @@ +cart->getQuote(); + $currencyCode = $quote->getBaseCurrencyCode(); + $amount = $quote->getBaseGrandTotal(); + $response = []; + + if ($coinShopCurrency = $this->getFiatCurrency($currencyCode)) { + $currencyId = $coinShopCurrency['currencyId']; + $convertedAmount = $this->convertCurrencies($currencyId, $coinCurrencyId, $amount, $coinCurrencyPrecision); + } + + if (!empty($convertedAmount)) { + + $this->checkoutSession->setCoinpaymentsCurrency($coinCurrencyId); + $this->checkoutSession->setCoinpaymentsAmount($convertedAmount['value']); + + $response = [ + 'converted_amount' => $convertedAmount['displayValue'], + ]; + } + +// $result = $this->jsonResultFactory->create(); +// $result->setData($response); + return json_encode($response); + } + + + /** + * @return array|mixed + */ + public function getAllCryptoCurrencies() + { + + $currencies = []; + + $listData = $this->getCryptoCurrencies(); + + if (!empty($listData['items'])) { + $currencies = $listData['items']; + while (!empty($listData['next_page_params']) && $listData = $this->getCryptoCurrencies($listData['next_page_params'])) { + if (!empty($listData['items'])) { + $currencies = array_merge($currencies, $listData['items']); + } + } + } + return $currencies; + } + + + /** + * @param array $params + * @return array|mixed + */ + public function getCryptoCurrencies(array $params = []) + { + + $params = array_merge($params, [ + 'types' => self::CRYPTO_TYPE, + 'capabilities' => self::PAYMENT_CAPABILITY, + ]); + + $listData = $this->getCurrencies($params); + if (!empty($listData['paging']['next'])) { + $nextPage = parse_url($listData['paging']['next']); + $nextPage['query_params'] = Psr7\parse_query($nextPage['query']); + $listData['next_page_params'] = $nextPage['query_params']; + } + + return $listData; + } + + /** + * @param array $params + * @return array|mixed + */ + public function getFiatCurrency(string $name) + { + + $params = [ + 'types' => self::FIAT_TYPE, + 'q' => $name, + ]; + $items = []; + + $listData = $this->getCurrencies($params); + if (!empty($listData['items'])) { + $items = $listData['items']; + } + + return array_shift($items); + } + + + /** + * @param array $params + * @return mixed + */ + public function getCurrencies($params = []) + { + return $this->sendGetRequest('currencies', [], $params); + } + + /** + * @param int $currencyId + * @param $coinCurrencyId + * @param $amount + * @return bool + */ + public function convertCurrencies($currencyId, $coinCurrencyId, $amount, $precision) + { + $rate = $this->getCurrencyRate($currencyId, $coinCurrencyId); + + $data['displayValue'] = $amount * $rate; + $data['value'] = number_format($amount * $rate, $precision, '', ''); + + return $data; + } + + /** + * @param $currencyId + * @param $coinCurrencyId + * @return bool|mixed + */ + public function getCurrencyRate($currencyId, $coinCurrencyId) + { + + $rate = false; + + $params = [ + 'from' => $currencyId, + 'to' => $coinCurrencyId, + ]; + + $listData = $this->sendGetRequest('rates', [], $params); + + if (!empty($listData['items'])) { + $rateData = array_shift($listData['items']); + $rate = $rateData['rate']; + } + + return $rate; + } + +} \ No newline at end of file diff --git a/Model/Api/Invoice.php b/Model/Api/Invoice.php new file mode 100644 index 0000000..1dca75f --- /dev/null +++ b/Model/Api/Invoice.php @@ -0,0 +1,107 @@ +checkoutSession->getCoinpaymentsCurrency(); + $amount = $this->checkoutSession->getCoinpaymentsAmount(); + $order = $this->checkoutSession->getLastRealOrder(); + + $clientId = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_id'); + $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); + $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'webhooks'); + + if ($merchantWebHooks) { + $invoiceData = $this->createMerchant($clientId, $clientSecret, $currencyId, $order->getIncrementId(), intval($amount)); + } else { + $invoiceData = $this->createSimple($clientId, $currencyId, $order->getIncrementId(), intval($amount)); + } + + $response = []; + + if (!empty($invoiceData['id'])) { + $this->checkoutSession->setCoinpaymentsInvoiceId($invoiceData['id']); + $response = ['coinInvoiceId' => $invoiceData['id']]; + } + + return $response; + } + + /** + * @return boolean + */ + public function updateInvoice() + { + $response = false; + + return $response; + } + + /** + * @param $clientId + * @param $clientSecret + * @param $currencyId + * @param $invoiceId + * @param $amount + * @return mixed + * @throws \Exception + */ + public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount) + { + $requestData = [ + "invoiceId" => $invoiceId, + "amount" => [ + "currencyId" => $currencyId, + "value" => $amount + ], + ]; + + $action = sprintf('merchant/invoices', $clientId); + + $requestParams = [ + 'method' => 'POST', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $headers = $this->getRequestHeaders($requestParams, $requestData); + + return $this->sendPostRequest($action, $headers, $requestData); + } + + /** + * @param $clientId + * @param int $currencyId + * @param string $invoiceId + * @param int $amount + * @return mixed + */ + public function createSimple($clientId, $currencyId = 1, $invoiceId = 'Validate invoice', $amount = 1) + { + + $action = 'invoices'; + + $requestParams = [ + 'clientId' => $clientId, + 'invoiceId' => $invoiceId, + 'amount' => [ + 'currencyId' => $currencyId, + 'value' => $amount + ] + ]; + + return $this->sendPostRequest($action, [], $requestParams); + } +} \ No newline at end of file diff --git a/Model/Api/WebHook.php b/Model/Api/WebHook.php new file mode 100644 index 0000000..1970857 --- /dev/null +++ b/Model/Api/WebHook.php @@ -0,0 +1,81 @@ +urlBuilder->getUrl('rest/V1/coinpayments/invoice/notification', ['_direct' => null]); + } + + public function createWebHook($clientId, $clientSecret) + { + + return [ // TODO delete test data + "id" => "testId", + "notificationsUrl" => $this->getWebHookCallbackUrl(), + "notifications" => [ + "invoiceCreated", + ] + ]; + + $action = sprintf('merchant/clients/%s/webhooks', $clientId); + + $requestParams = [ + 'method' => 'POST', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $requestData = [ + "notificationsUrl" => $this->getWebHookCallbackUrl(), + "notifications" => [ + "invoiceCreated", + "invoicePaymentsReceived", + "invoicePaymentsConfirmed", + "invoiceCompleted", + "invoiceExpired", + ], + ]; + + $headers = $this->getRequestHeaders($requestParams, $requestData); + return $this->sendPostRequest($action, $headers, $requestData); + } + + public function getList($clientId, $clientSecret) + { + + return [ // TODO delete test data + "items" => [ + [ + "id" => "testId", + "notificationsUrl" => "https://magento2.test/rest/V1/coinpayments/invoice/notification/", + "notificationsUrl" => "https://magento2.test/rest/V1/coinpayments/", + "notifications" => [ + "invoiceCreated", + ] + ] + ] + ]; + + $action = sprintf('merchant/clients/%s/webhooks', $clientId); + $requestParams = [ + 'method' => 'GET', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $headers = $this->getRequestHeaders($requestParams); + + return $this->sendGetRequest($action, $headers); + } + + +} \ No newline at end of file diff --git a/Model/ApiProvider.php b/Model/ApiProvider.php new file mode 100644 index 0000000..0598db3 --- /dev/null +++ b/Model/ApiProvider.php @@ -0,0 +1,174 @@ + 'application/json' + ]; + + /* @var Cart */ + protected $cart; + + /** + * @var Url + */ + protected $urlBuilder; + + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ + protected $jsonResultFactory; + + /** + * @var mixed + */ + protected $baseConf; + + public function __construct( + Session $checkoutSession, + Cart $cart, + Curl $curl, + ScopeConfigInterface $scopeConfig, + \Magento\Framework\Controller\Result\JsonFactory $jsonResultFactory, + Url $urlBuilder + ) + { + $this->cart = $cart; + $this->checkoutSession = $checkoutSession; + $this->curl = $curl; + $this->scopeConfig = $scopeConfig; + $this->urlBuilder = $urlBuilder; + $this->jsonResultFactory = $jsonResultFactory; + $this->baseConf = $this->getBaseConfig(); + } + + public function getRequestHeaders($requestParams, $requestData = []) + { + + $date = new \Datetime(); + + $headerData = [ + 'method' => $requestParams['method'], + 'url' => $this->getApiUrl($requestParams['action']), + 'clientId' => $requestParams['clientId'], + 'timestamp' => $date->format('c'), + ]; + + if (!empty($requestData)) { + $headerData['params'] = json_encode($requestData); + } + + return [ + 'X-CoinPayments-Client' => $requestParams['clientId'], + 'X-CoinPayments-Timestamp' => $date->format('c'), + 'X-CoinPayments-Signature' => $this->generateHmac($headerData, $requestParams['clientSecret']), + ]; + } + + /** + * @param $action + * @param $headers + * @param $requestData + * @return mixed + */ + public function sendPostRequest($action, $headers, $requestData) + { + + $headers = array_merge($headers, $this->defaultHeaders); + foreach ($headers as $name => $value) { + $this->curl->addHeader($name, $value); + } + + $this->curl->setOption(CURLOPT_SSL_VERIFYHOST, 0); + $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, 0); + + $requestUrl = $this->getApiUrl($action); + $this->curl->post($requestUrl, $requestData); + return json_decode($this->curl->getBody(), true); + } + + /** + * @param $action + * @param $headers + * @param array $requestData + * @return mixed + */ + public function sendGetRequest($action, $headers, $requestData = []) + { + + $headers = array_merge($headers, $this->defaultHeaders); + foreach ($headers as $name => $value) { + $this->curl->addHeader($name, $value); + } + + $this->curl->setOption(CURLOPT_SSL_VERIFYHOST, 0); + $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, 0); + + $requestUrl = $this->getApiUrl($action); + if (!empty($requestData)) { + $requestUrl .= '?' . http_build_query($requestData); + } + + $this->curl->get($requestUrl); + return json_decode($this->curl->getBody(), true); + } + + /** + * @param $baseConf + * @param $action + * @return string + */ + public function getApiUrl($action) + { + return sprintf('%s/v%s/%s', $this->baseConf['api_url'], $this->baseConf['api_version'], $action); + } + + /** + * @param $requestData + * @param null $secretKey + * @return string + */ + public function generateHmac($requestData, $secretKey = null) + { + return base64_encode(hash_hmac('sha256', chr(239) . implode('', $requestData), $secretKey, true)); + } + + /** + * @param $base + * @param $field + * @return mixed + */ + protected function getConfig($base, $field = false) + { + if ($field) { + return $this->scopeConfig->getValue($base . DIRECTORY_SEPARATOR . $field); + } + return $this->scopeConfig->getValue($base); + } + + /** + * @param null $field + * @return mixed + */ + protected function getBaseConfig($field = null) + { + return $this->getConfig('coinpayment/conf', $field); + } +} diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php new file mode 100644 index 0000000..2574cb9 --- /dev/null +++ b/Model/CoinPaymentsConfigProvider.php @@ -0,0 +1,99 @@ +curl = $curl; + $this->_scopeConfig = $scopeConfig; + $this->_assetRepo = $assetRepo; + $this->_apiCurrency = $apiCurrency; + } + + /** + * @return array + */ + public function getConfig() + { + $currencies = $this->getCryptoCurrencies(); + + return [ + 'payment' => [ + 'coinpayments' => [ + 'currencies' => $currencies, + 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), + ] + ] + ]; + } + + /** + * @return array + */ + public function getCryptoCurrencies() + { + $currencies = []; + + $apiCurrencies = $this->_apiCurrency->getAllCryptoCurrencies(); + + if (!empty($apiCurrencies)) { + foreach ($apiCurrencies as $key => $item) { + $elm = [ + 'value' => $item['currencyId'], + 'name' => $item['name'], + 'body' => $item, + ]; + $currencies[] = $elm; + } + } else { + $currencies = [ + 'error' => [ + 'name' => 'Cannot load Coinpayments.Net currencies', + 'value' => 'error', + 'attr' => [ + 'disabled' => true, + ], + ], + ]; + } + + return $currencies; + } +} diff --git a/Model/Methods/Coinpayments.php b/Model/Methods/Coinpayments.php new file mode 100644 index 0000000..ccbfce1 --- /dev/null +++ b/Model/Methods/Coinpayments.php @@ -0,0 +1,61 @@ + + */ + +namespace Coinpayments\CoinPayments\Model\Methods; + +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Framework\HTTP\ZendClientFactory; +use Magento\Payment\Model\Method\ConfigInterface; +use Magento\Payment\Model\Method\TransparentInterface; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Payment\Model\Method\AbstractMethod; +use Magento\Sales\Model\Order; + +class Coinpayments extends AbstractMethod +{ + + /** + * Method code + */ + const CODE = 'coin_payments'; + + /** + * @var string + */ + protected $_code = self::CODE; + + + /* Uncomment if need using blocks + + protected $_formBlockType = 'Coinpayments\CoinPayments\Block\Form\Coinpayments'; + + protected $_infoBlockType = 'Coinpayments\CoinPayments\Block\Info';*/ + + + /** + * @param CartInterface|null $quote + * @return bool + */ + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) + { + return parent::isAvailable($quote); + } + + /** + * @param null $storeId + * @return bool + */ + public function isActive($storeId = null) + { + return (bool)(int)$this->getConfigData('active', $storeId); + } + + public function getCode() + { + return $this->_code; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..266a15a --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "coinpaymentsnet/magento2", + "description": "Add new payment method for CoinPayments.net", + "require": { + "php": "~5.5.0|~5.6.0|~7.0.0|~7.1", + "lusitanian/oauth": "~0.8.10" + }, + "type": "magento2-module", + "version": "2.0.0", + "license": [ + "OSL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "coinpaymentsnet\\magento2\\": "" + } + } +} diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100644 index 0000000..2350630 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml new file mode 100644 index 0000000..32b7201 --- /dev/null +++ b/etc/adminhtml/routes.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..e59e408 --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,75 @@ + + + +
    + + complex coin-payment-section + Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment + + + + + Magento\Config\Model\Config\Source\Yesno + + + + + required-entry validate-length minimum-length-22 maximum-length-32 coin-invoice-validate + + + 1 + + + + + + Magento\Config\Model\Config\Source\Yesno + + 1 + + + + + + + required-entry validate-length minimum-length-22 maximum-length-44 coin-webhooks-validate + + + 1 + 1 + + + + + + Magento\Sales\Model\Config\Source\Order\Status + required-entry + + + + + 1 + 1 + + + + +
    +
    +
    diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..ed6f3b1 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,21 @@ + + + + + + 0 + Coinpayments\CoinPayments\Model\Methods\Coinpayments + Coin Payments + 0 + coinpayments + + + + + https://orion-api-testnet.starhermit.com/api + 1 + + + ` + \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml new file mode 100644 index 0000000..c1e61f3 --- /dev/null +++ b/etc/di.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml new file mode 100644 index 0000000..fca8dd9 --- /dev/null +++ b/etc/frontend/di.xml @@ -0,0 +1,13 @@ + + + + + + + Coinpayments\CoinPayments\Model\CoinPaymentsConfigProvider + + + + + \ No newline at end of file diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml new file mode 100644 index 0000000..b040362 --- /dev/null +++ b/etc/frontend/routes.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml new file mode 100644 index 0000000..75bebe6 --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/etc/payment.xml b/etc/payment.xml new file mode 100644 index 0000000..34905c1 --- /dev/null +++ b/etc/payment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + 1 + + + \ No newline at end of file diff --git a/etc/webapi.xml b/etc/webapi.xml new file mode 100644 index 0000000..c6bb512 --- /dev/null +++ b/etc/webapi.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/registration.php b/registration.php new file mode 100644 index 0000000..cb2090d --- /dev/null +++ b/registration.php @@ -0,0 +1,7 @@ + + + + + + + + + + + + + diff --git a/view/adminhtml/requirejs-config.js b/view/adminhtml/requirejs-config.js new file mode 100644 index 0000000..281fef8 --- /dev/null +++ b/view/adminhtml/requirejs-config.js @@ -0,0 +1,6 @@ +var config = { + 'paths': { + 'coin-invoice-validate': 'Coinpayments_CoinPayments/js/invoice-validate', + 'coin-webhooks-validate': 'Coinpayments_CoinPayments/js/webhooks-validate' + } +}; diff --git a/view/adminhtml/templates/js_vars.phtml b/view/adminhtml/templates/js_vars.phtml new file mode 100644 index 0000000..e29940d --- /dev/null +++ b/view/adminhtml/templates/js_vars.phtml @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/view/adminhtml/web/images/logo.png b/view/adminhtml/web/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..9bc9e035f6dee7e38112f825e1509d19e805a71f GIT binary patch literal 6130 zcmV~C-@6Nf3>R6zYZ4NQns~pZKX15^fr^&mXr}&bLMk=MerlvyYD(x& z%B&E^{H19VW?Fek*zlT~;1v}wv|@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m#Xd^rHI(w0O&6jrwKGrFKFn)~I^FZs%Cs(s9D;NIkqx z*xl=$?b(3aITmGyC6nQ_tfBHsMv&8}fJ0uy#!D!8W7b(2g<0dtqrqJ}Py68E~F8YHG})_JgYC=H`mNKuBHX zNhu_k9w~AXDN^bYT<;z{n@CMv0~PHFYt(V%4=+Y^3`ylMoKx7=K*Q{7hu)vFfKo(9 zCX@}VG@X5g5h?QNnL6%{b5QC8++&S;JQig{#K({S2btuilsps?5dZ)H07*qoM6N<$ Ef_fF>OaK4? literal 0 HcmV?d00001 diff --git a/view/adminhtml/web/js/invoice-validate.js b/view/adminhtml/web/js/invoice-validate.js new file mode 100644 index 0000000..904f287 --- /dev/null +++ b/view/adminhtml/web/js/invoice-validate.js @@ -0,0 +1,38 @@ +require([ + 'jquery', + 'jquery/ui', + 'jquery/validate', + 'mage/translate' +], function ($) { + + $.validator.addMethod( + "coin-invoice-validate", + function (client_id) { + + var web_hooks = $('[data-ui-id="select-groups-coin-payments-fields-webhooks-value"]'); + var is_success = false; + + if (web_hooks.length && web_hooks.val() === '1') { + is_success = true; + } else { + var params = { + client_id: client_id, + }; + $.ajax({ + showLoader: true, + url: coin_validate_invoice, + data: params, + async: false, + type: "POST", + dataType: 'json' + }).done(function (data) { + is_success = data.success; + }); + } + + return is_success; + }, + $.mage.__("Please enter a valid Coinpayments.NET credentials.") + ); + +}); \ No newline at end of file diff --git a/view/adminhtml/web/js/webhooks-validate.js b/view/adminhtml/web/js/webhooks-validate.js new file mode 100644 index 0000000..292d3f7 --- /dev/null +++ b/view/adminhtml/web/js/webhooks-validate.js @@ -0,0 +1,48 @@ +require([ + 'jquery', + 'jquery/ui', + 'jquery/validate', + 'mage/translate' +], function ($) { + + var validationError = "Please enter a valid Coinpayments.NET credentials."; + + $.validator.addMethod( + "coin-webhooks-validate", + function (client_secret, elem) { + + var is_success = false; + var validator = this; + var client_id_field = $('[data-ui-id="text-groups-coin-payments-fields-client-id-value"]'); + var client_secret_field = $('[data-ui-id="text-groups-coin-payments-fields-client-secret-value"]'); + var web_hooks = $('[data-ui-id="select-groups-coin-payments-fields-webhooks-value"]'); + + if (client_id_field.length && web_hooks.length && client_secret_field.length) { + + var params = { + client_id: client_id_field.val(), + client_secret: client_secret_field.val(), + }; + + $.ajax({ + showLoader: true, + url: coin_validate_webhooks, + data: params, + async: false, + type: "POST", + dataType: 'json' + }).done(function (data) { + is_success = data.success; + if (!is_success) { + var errors = {}; + errors[client_id_field.attr('name').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')] = validationError; + validator.showErrors(errors); + } + }); + } + + return is_success; + }, + $.mage.__(validationError) + ); +}); \ No newline at end of file diff --git a/view/adminhtml/web/styles.css b/view/adminhtml/web/styles.css new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/view/adminhtml/web/styles.css @@ -0,0 +1,30 @@ +.complex.coin-payment-section .coin-payment-logo { + display: inline-block; + vertical-align: middle; + margin: 0 20px 0 0px; + width: 180px; + height: 60px; + background-repeat: no-repeat, no-repeat, no-repeat; + background-size: 100% auto; + background-position: center top; + background-image: url('images/logo.png'); +} + +.section-config.with-button.coin-payment-section .config-heading strong { + font-weight: normal; +} + +.complex.coin-payment-section .button-container { + float: right; +} + +.complex.coin-payment-section .coin-payment-description { + display: inline-block; + vertical-align: middle; + width: 50%; +} + +.coin-payment-section.section-config.active > .admin__collapsible-block + input + fieldset { + margin-left: 40px; +} + diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml new file mode 100644 index 0000000..fe26359 --- /dev/null +++ b/view/frontend/layout/checkout_index_index.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + uiComponent + + + + + + + + Coinpayments_CoinPayments/js/view/payment/validate-selected-currency + + + + + + + + + Coinpayments_CoinPayments/js/view/payment/coin_payments + + + + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/view/frontend/web/images/logo.png b/view/frontend/web/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4cc78a80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J%v{DGak{kSWUlMLsKEuCk6FbCH*^U`D8)gy>MmXfG z^@UBEsMWl33l)9&Rzq6NHV9+dZ?SKOElMXAWAn3o*`tz)rq{Faf0tY&R43s{uNsoc z$rfl^#NO|etbjQ_I_nJn_3f?dy12;l$9>^zFAcoY8`c3+6gvc*b_z>!Ui+3=MM>wG z?^9K9A%J@X2-lW=A-1A*0B9@3GhM7VsextZ2)Ge+q;>xHmG9cBw$ut{gsWaFLj$|h z$Hn!Y$KJ(>OyMFUlA9Uf=8ox_btu{3|$P84RK5p>YgD(Em^ zcm1Uefp5coJL)Y+7&VhQ+NFuzvN#J#iykq^r>{PztTUa{OF-1(28%5o|1nC9&_kZs X%U{10%(AcjF};_KEsZJ--D3X-tYJ+I literal 0 HcmV?d00001 diff --git a/view/frontend/web/js/action/set-payment-method.js b/view/frontend/web/js/action/set-payment-method.js new file mode 100644 index 0000000..332081c --- /dev/null +++ b/view/frontend/web/js/action/set-payment-method.js @@ -0,0 +1,56 @@ +/** + * @copyright: Copyright © 2017 Firebear Studio. All rights reserved. + * @author : Firebear Studio + */ +define( + [ + 'jquery', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/url-builder', + 'mage/storage', + 'Magento_Checkout/js/model/error-processor', + 'Magento_Customer/js/model/customer', + 'Magento_Checkout/js/model/full-screen-loader' + ], + function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) { + 'use strict'; + + return function (messageContainer) { + var serviceUrl, + payload, + method = 'put', + paymentData = quote.paymentMethod(); + + /** + * Checkout for guest and registered customer. + */ + if (!customer.isLoggedIn()) { + serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', { + cartId: quote.getQuoteId() + }); + payload = { + cartId: quote.getQuoteId(), + email: quote.guestEmail, + paymentMethod: paymentData + }; + method = 'post'; + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/selected-payment-method', {}); + payload = { + cartId: quote.getQuoteId(), + method: paymentData + }; + } + fullScreenLoader.startLoader(); + + return storage[method]( + serviceUrl, JSON.stringify(payload) + ).fail( + function (response) { + errorProcessor.process(response, messageContainer); + fullScreenLoader.stopLoader(); + } + ); + }; + } +); \ No newline at end of file diff --git a/view/frontend/web/js/model/validate-selected-currency.js b/view/frontend/web/js/model/validate-selected-currency.js new file mode 100644 index 0000000..6c8d6b9 --- /dev/null +++ b/view/frontend/web/js/model/validate-selected-currency.js @@ -0,0 +1,28 @@ +define( + ['jquery'], + function ($) { + 'use strict'; + return { + getCode: function () { + return 'coin_payments'; + }, + /** + * @returns {boolean} + */ + validate: function () { + var valid = true; + + var selector = $("#" + this.getCode() + "_crypto_currency"); + + if (!selector.find('option:selected').val()) { + selector.addClass('mage-error'); + valid = false; + } else { + selector.removeClass('mage-error'); + } + + return valid; + } + } + } +); \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/coin_payments.js b/view/frontend/web/js/view/payment/coin_payments.js new file mode 100644 index 0000000..45b950b --- /dev/null +++ b/view/frontend/web/js/view/payment/coin_payments.js @@ -0,0 +1,22 @@ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/payment/renderer-list' + ], + function ( + Component, + rendererList + ) { + 'use strict'; + + console.log('method-renderer/coin-method'); + + rendererList.push( + { + type: 'coin_payments', + component: 'Coinpayments_CoinPayments/js/view/payment/method-renderer/coin-method' + } + ); + return Component.extend({}); + } +); \ No newline at end of file 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 new file mode 100644 index 0000000..4cf9476 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/coin-method.js @@ -0,0 +1,275 @@ +define( + [ + 'ko', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'jquery', + 'Magento_Checkout/js/action/place-order', + 'Magento_Checkout/js/action/select-payment-method', + 'Magento_Customer/js/model/customer', + 'Magento_Checkout/js/checkout-data', + 'Magento_Checkout/js/model/payment/additional-validators', + 'mage/url', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/model/error-processor', + 'Magento_Checkout/js/model/totals', + ], + function (ko, + Component, + quote, + $, + placeOrderAction, + selectPaymentMethodAction, + customer, + checkoutData, + additionalValidators, + url, + fullScreenLoader, + errorProcessor, + totals + ) { + 'use strict'; + + window.fullScreenLoader = fullScreenLoader; + + return Component.extend({ + defaults: { + template: 'Coinpayments_CoinPayments/payment/coin_payment' + }, + /** + * @returns {string} + */ + getCode: function () { + return 'coin_payments'; + }, + afterPlaceOrder: function () { + this.createInvoice( + window.checkoutConfig.payment.coinpayments.currentData.currency, + window.checkoutConfig.payment.coinpayments.currentData.total, + url.build('checkout/onepage/success') + ); + }, + getCaption: function () { + var caption = 'Select Coinpayments.Net currency'; + if (window.checkoutConfig.payment.coinpayments.currencies.error) { + caption = window.checkoutConfig.payment.coinpayments.currencies.error.name; + } + return caption; + }, + getCurrencies: function () { + if (!window.checkoutConfig.payment.coinpayments.currencies.error) { + return ko.observableArray(window.checkoutConfig.payment.coinpayments.currencies); + } + return []; + }, + /** + * + * @returns {boolean} + */ + selectPaymentMethod: function () { + selectPaymentMethodAction(this.getData()); + checkoutData.setSelectedPaymentMethod(this.item.method); + return true; + }, + /** + * + * @param data + * @param event + * @returns {boolean} + */ + placeOrder: function (data, event) { + + if (event) { + event.preventDefault(); + } + var self = this, + placeOrder, + emailValidationResult = customer.isLoggedIn(), + loginFormSelector = 'form[data-role=email-with-possible-login]'; + if (!customer.isLoggedIn()) { + $(loginFormSelector).validation(); + emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid()); + } + + if (emailValidationResult && this.validate() && additionalValidators.validate()) { + this.isPlaceOrderActionAllowed(false); + placeOrder = placeOrderAction(this.getData(), false, this.messageContainer); + + $.when(placeOrder).fail(function () { + self.isPlaceOrderActionAllowed(true); + }).done(this.afterPlaceOrder.bind(this)); + return true; + } + return false; + }, + getBaseGrandTotal: function () { + if (totals.totals()) { + var grandTotal = parseFloat(totals.totals()['grand_total']); + return grandTotal; + } + return window.checkoutConfig.totalsData.base_grand_total; + }, + getPaymentAcceptanceMarkSrc: function () { + return window.checkoutConfig.payment.coinpayments.logo; + }, + getCurrencyCode: function () { + return window.checkoutConfig.totalsData.quote_currency_code; + }, + /** + * + * @param element + * @param event + */ + getConvertedAmount: function (element, event) { + var elemToChange = $('#converted_amount_coinpayments'); + var coinCurrencyId = $(event.target).find('option:selected').val(); + var coinCurrencyCode = false; + var coinCurrencyPrecision = false; + + window.checkoutConfig.payment.coinpayments.currencies.forEach(function (val, index) { + if (val.body.currencyId == coinCurrencyId) { + coinCurrencyCode = val.body.symbol; + coinCurrencyPrecision = val.body.decimalPlaces; + } + }) + + if (coinCurrencyId) { + var url = '/rest/V1/coinpayments/currency/set'; + var data = { + coinCurrencyId: coinCurrencyId, + coinCurrencyPrecision: coinCurrencyPrecision, + }; + $.ajax({ + type: "POST", + encoding: 'UTF-8', + url: url, + showLoader: true, + contentType: "application/json", + data: JSON.stringify(data), + dataType: 'json', + success: function (result) { + result = JSON.parse(result); + var total = result.converted_amount; + total = total.toFixed(coinCurrencyPrecision); + elemToChange.val(total + ' ' + coinCurrencyCode); + window.checkoutConfig.payment.coinpayments.currentData = { + total: total, + currency: coinCurrencyCode + }; + }, + error: function (err) { + //TODO error logic + } + }); + } + }, + /** + * @returns {boolean} + */ + getAllowPlaceOrder: function () { + return this.getCode() === this.isChecked(); + }, + /** + * + * @param currency + * @param value + * @param redirect + */ + createInvoice: function (currency, value, redirect) { + + var url = '/rest/V1/coinpayments/invoice/create'; + + $.ajax({ + type: "POST", + url: url, + contentType: "application/json", + success: function (result) { + var invoiceId = result[0]; + + try { + window.popup = undefined; + showPaymentsPopup(invoiceId, redirect); + } catch (e) { + console.error(e); + } + + }, + error: function (err) { + console.log(error); + if (redirect) { + window.location.replace(redirect); + } + } + }); + } + }) + ; + } +) +; + + +function showPaymentsPopup(invoiceId, redirect) { + + window.fullScreenLoader.startLoader(); + var apiBaseUrl = "https://orion-api-testnet.starhermit.com"; + var id = "Checkout_Magento2_" + (Math.random() * 9007199254740991).toString(16); + var checkoutAppUrl = apiBaseUrl + "/checkout"; + + var popupWidth = 480 + 20; + var popupHeight = 620 + 60; + + var popupFeatures = { + width: popupWidth, + height: popupHeight, + status: 1, + toolbar: 0, + menubar: 0, + resizable: 1, + scrollbars: 1 + }; + var features = Object.keys(popupFeatures) + .map(function (key) { + return key + "=" + popupFeatures[key]; + }) + .join(","); + + window.popup = window.open(checkoutAppUrl, id, features); + + var interval = setInterval(function () { + if (!window.popup || window.popup.closed) { + clearInterval(interval); + window.fullScreenLoader.stopLoader(true); + window.popup = undefined; + if (redirect) { + window.location.replace(redirect); + } + } + }, 1000); + + window.addEventListener("message", function (event) { + switch (event.data.action) { + case "CoinPaymentsCheckoutAppInitialized": + var msg = { + action: "CoinPaymentsCheckoutAppInitializeInvoice", + data: { + apiBaseUrl: apiBaseUrl, + invoiceId: invoiceId + } + }; + window.popup.postMessage(msg, "*"); + return false; + case "CoinPaymentsPaymentButtonModalClosePressed": + case "CoinPaymentsCheckoutAppInvoiceCancelled": + case "CoinPaymentsCheckoutAppInvoiceConfirmed": + window.fullScreenLoader.stopLoader(true); + popup.close(); + if (redirect) { + window.location.replace(redirect); + } + return false; + } + }, true); + + window.popup; +} \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/validate-selected-currency.js b/view/frontend/web/js/view/payment/validate-selected-currency.js new file mode 100644 index 0000000..cdb8c8c --- /dev/null +++ b/view/frontend/web/js/view/payment/validate-selected-currency.js @@ -0,0 +1,16 @@ +define( + [ + 'uiComponent', + 'Magento_Checkout/js/model/payment/additional-validators', + 'Coinpayments_CoinPayments/js/model/validate-selected-currency' + ], + function ( + Component, + additionalValidators, + validateSelectedCurrency + ) { + 'use strict'; + additionalValidators.registerValidator(validateSelectedCurrency); + return Component.extend({}); + } +); \ No newline at end of file diff --git a/view/frontend/web/template/payment/coin_payment.html b/view/frontend/web/template/payment/coin_payment.html new file mode 100644 index 0000000..d36cac6 --- /dev/null +++ b/view/frontend/web/template/payment/coin_payment.html @@ -0,0 +1,87 @@ +
    +
    + + +
    +
    + + + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +
    + +
    +
    +
    +
    \ No newline at end of file From 53619ee1a85d235b5199de59d78e1dc1f8ddc2b6 Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 15 Jan 2020 13:19:36 +0200 Subject: [PATCH 033/107] Deletion of redundant functionality, preparation for testing. --- Api/CurrencyInterface.php | 30 ---- Api/InvoiceInterface.php | 9 - Api/WebHookInterface.php | 15 +- .../Adminhtml/Validation/Validation.php | 28 ++- Controller/Adminhtml/Validation/WebHook.php | 38 ++-- Controller/Checkout/Failure.php | 59 ++++++ Controller/Invoice/Create.php | 153 ++++++++++++++++ Controller/WebHooks/Notification.php | 94 ++++++++++ Model/{ApiProvider.php => AbstractApi.php} | 105 +++++++---- Model/Api/Currency.php | 161 ----------------- Model/Api/Invoice.php | 107 ----------- Model/Api/WebHook.php | 81 --------- Model/CoinPaymentsConfigProvider.php | 57 +----- Model/Invoice.php | 69 +++++++ Model/Methods/Coinpayments.php | 8 - Model/WebHook.php | 143 +++++++++++++++ etc/config.xml | 2 +- etc/di.xml | 1 - etc/webapi.xml | 22 --- view/frontend/layout/checkout_index_index.xml | 9 - .../layout/coinpayments_checkout_failure.xml | 19 ++ .../js/model/validate-selected-currency.js | 28 --- .../web/js/view/payment/coin_payments.js | 2 - .../payment/method-renderer/coin-method.js | 168 ++---------------- .../payment/validate-selected-currency.js | 16 -- .../web/template/payment/coin_payment.html | 50 ------ 26 files changed, 665 insertions(+), 809 deletions(-) delete mode 100644 Api/CurrencyInterface.php create mode 100644 Controller/Checkout/Failure.php create mode 100644 Controller/Invoice/Create.php create mode 100644 Controller/WebHooks/Notification.php rename Model/{ApiProvider.php => AbstractApi.php} (65%) delete mode 100644 Model/Api/Currency.php delete mode 100644 Model/Api/Invoice.php delete mode 100644 Model/Api/WebHook.php create mode 100644 Model/Invoice.php create mode 100644 Model/WebHook.php delete mode 100644 etc/webapi.xml create mode 100644 view/frontend/layout/coinpayments_checkout_failure.xml delete mode 100644 view/frontend/web/js/model/validate-selected-currency.js delete mode 100644 view/frontend/web/js/view/payment/validate-selected-currency.js diff --git a/Api/CurrencyInterface.php b/Api/CurrencyInterface.php deleted file mode 100644 index 0d0e648..0000000 --- a/Api/CurrencyInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - 'notif-url', -// "notifications" => [ -// 2, -// 4 -// ], -// ]) -// ) -// ]; -// -// $equal = sprintf('%s%s%s%s', chr(239), chr(187), chr(191), implode('', $signatureData)) == $signatureString; -// -// $imploded = implode('', $signatureData); -// $signature = $this->webHookModel->generateHmac($signatureData, 'secret'); - $params = $this->getRequest()->getParams(); $response = []; @@ -58,8 +34,8 @@ public function execute() }, $webHooksList['items']); } - if (!in_array($this->webHookModel->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($client_id, $client_secret); + if (!in_array($this->getWebHookCallbackUrl(), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->getWebHookCallbackUrl()); if (!empty($webHook)) { $response = [ 'success' => $webHook, @@ -93,4 +69,14 @@ public function execute() $result->setData($response); return $result; } + + + /** + * @return string + */ + protected function getWebHookCallbackUrl() + { +// return $this->urlBuilder->getUrl('coinpayments/webhooks/notification', ['_direct' => null]); + return 'http://34.95.25.102/'; // TODO delete test data + } } \ No newline at end of file diff --git a/Controller/Checkout/Failure.php b/Controller/Checkout/Failure.php new file mode 100644 index 0000000..4583dea --- /dev/null +++ b/Controller/Checkout/Failure.php @@ -0,0 +1,59 @@ +checkoutSession = $checkoutSession; + $this->orderFactory = $orderFactory; + $this->orderRepository = $orderRepository; + $this->resultPageFactory = $resultPageFactory; + $this->logger = $logger; + $this->cacheTypeList = $cacheTypeList; + $this->cacheFrontendPool = $cacheFrontendPool; + parent::__construct($context); + } + + + public function execute() + { + $lastOrderId = $this->getRealOrderId(); + $order = $this->orderRepository->get($lastOrderId); + $order->setStatus(Order::STATE_CANCELED)->setState(Order::STATE_CANCELED); + $this->orderRepository->save($order); + $this->logger->info('ORDER INFO: ' . $order->getStatus() . $order->getState()); + + return $this->resultPageFactory->create(); + } + + public function getRealOrderId() + { + $lastorderId = $this->checkoutSession->getLastOrderId(); + + return $lastorderId; + } + +} diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php new file mode 100644 index 0000000..5e2a61f --- /dev/null +++ b/Controller/Invoice/Create.php @@ -0,0 +1,153 @@ +urlBuilder = $urlBuilder; + $this->invoiceModel = $invoice; + $this->scopeConfig = $scopeConfig; + $this->checkoutSession = $checkoutSession; + $this->jsonResultFactory = $jsonResultFactory; + parent::__construct($context); + } + + public function execute() + { + + + $response = [ + 'successUrl' => $this->urlBuilder->getUrl('checkout/onepage/success'), + 'cancelUrl' => $this->urlBuilder->getUrl('coinpayments/checkout/failure'), + ]; + + $order = $this->checkoutSession->getLastRealOrder(); + + if ($order->getIncrementId()) { + + $coinInvoiceCacheId = Invoice::INVOICE_CACHE_PREFIX . $order->getIncrementId(); + $coinInvoiceId = $this->checkoutSession->{'get' . $coinInvoiceCacheId}(); + + if (empty($coinInvoiceId)) { + + $currencyCode = $order->getBaseCurrencyCode(); + $coinCurrency = $this->getCoinCurrency($currencyCode); + $amount = number_format($order->getGrandTotal(), $coinCurrency['decimalPlaces'], '', ''); + + if (!empty($coinCurrency)) { + + $clientId = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_id'); + $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); + $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'webhooks'); + + if ($merchantWebHooks) { + $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $order->getIncrementId(), intval($amount)); + } else { + $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $order->getIncrementId(), intval($amount)); + } + + if (!empty($invoiceData['id'])) { + $this->checkoutSession->{'set' . $coinInvoiceCacheId}($invoiceData['id']); + $coinInvoiceId = $invoiceData['id']; + } + } + + } + + if (!empty($coinInvoiceId)) { + $response['coinInvoiceId'] = $coinInvoiceId; + $response['redirectUrl'] = $this->getCoinCheckoutRedirectUrl($coinInvoiceId, $response['successUrl'], $response['cancelUrl']); + } + } + + $result = $this->jsonResultFactory->create(); + $result->setData($response); + return $result; + } + + /** + * @param $coinInvoiceId + * @param $successUrl + * @param $cancelUrl + * @return string + */ + protected function getCoinCheckoutRedirectUrl($coinInvoiceId, $successUrl, $cancelUrl) + { + return sprintf('%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', $this->invoiceModel->getBaseConfig('api_url'), $coinInvoiceId, $successUrl, $cancelUrl); + } + + /** + * @param string $name + * @return array|mixed + */ + protected function getCoinCurrency(string $name) + { + + $params = [ + 'types' => Invoice::FIAT_TYPE, + 'q' => $name, + ]; + $items = []; + + $listData = $this->invoiceModel->getCurrencies($params); + if (!empty($listData['items'])) { + $items = $listData['items']; + } + + return array_shift($items); + } + + public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException + { + return null; + } + + public function validateForCsrf(RequestInterface $request): ?bool + { + return true; + } + +} diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php new file mode 100644 index 0000000..c5f7b0e --- /dev/null +++ b/Controller/WebHooks/Notification.php @@ -0,0 +1,94 @@ +urlBuilder = $urlBuilder; + $this->webHookModel = $webHookModel; + $this->scopeConfig = $scopeConfig; + parent::__construct($context); + } + + + public function execute() + { + + $content = $this->getRequest()->getContent(); + $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); + + if ($this->checkDataSignature($signature, $content)) { + $requestData = json_decode($content, true); + + // TODO delete test data + $requestData['invoice']['invoiceId'] = '000000019'; + $requestData['status'] = 'Completed'; + + if ($requestData['status'] == 'Completed') { + $this->webHookModel->completeOrder($requestData); + } elseif ($requestData['status'] == 'Expired') { + $this->webHookModel->cancelOrder($requestData); + } + } + + } + + /** + * @param $signature + * @param $content + * @return bool + */ + protected function checkDataSignature($signature, $content) + { + + $requestUrl = $this->urlBuilder->getCurrentUrl(); + $requestUrl = 'http://34.95.25.102/'; // TODO delete test data + + $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); + $encodedPure = $this->webHookModel->generateHmac([$requestUrl, $content], $clientSecret); + return $signature == $encodedPure; + } + + public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException + { + return null; + } + + public function validateForCsrf(RequestInterface $request): ?bool + { + return true; + } +} diff --git a/Model/ApiProvider.php b/Model/AbstractApi.php similarity index 65% rename from Model/ApiProvider.php rename to Model/AbstractApi.php index 0598db3..15d6e53 100644 --- a/Model/ApiProvider.php +++ b/Model/AbstractApi.php @@ -2,16 +2,18 @@ namespace Coinpayments\CoinPayments\Model; -use Magento\Checkout\Model\Session; -use \Magento\Checkout\Model\Cart; +use Coinpayments\CoinPayments\Model\Methods\Coinpayments; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\HTTP\Client\Curl; -use Magento\Framework\Url; +use Magento\Sales\Model\Order; -class ApiProvider +abstract class AbstractApi { - /* @var Session */ - protected $checkoutSession; + + const FIAT_TYPE = 'fiat'; + + const INVOICE_CACHE_PREFIX = 'CoinpaymentsInvoice'; + /* @var Curl */ protected $curl; @@ -20,45 +22,48 @@ class ApiProvider /* @var array */ protected $defaultHeaders = [ - 'Content-Type' => 'application/json' + 'Content-Type' => 'application/json;' ]; - /* @var Cart */ - protected $cart; - /** - * @var Url + * @var mixed */ - protected $urlBuilder; - + protected $baseConf; /** - * @var \Magento\Framework\Controller\Result\JsonFactory + * @var Order */ - protected $jsonResultFactory; - + protected $orderModel; /** - * @var mixed + * @var Coinpayments */ - protected $baseConf; + protected $coinPaymentsMethod; + /** + * @var Order\Payment\Transaction\BuilderInterface + */ + protected $transactionBuilder; public function __construct( - Session $checkoutSession, - Cart $cart, Curl $curl, ScopeConfigInterface $scopeConfig, - \Magento\Framework\Controller\Result\JsonFactory $jsonResultFactory, - Url $urlBuilder + Order $orderModel, + Coinpayments $coinPaymentsMethod, + Order\Payment\Transaction\BuilderInterface $transactionBuilder ) { - $this->cart = $cart; - $this->checkoutSession = $checkoutSession; $this->curl = $curl; $this->scopeConfig = $scopeConfig; - $this->urlBuilder = $urlBuilder; - $this->jsonResultFactory = $jsonResultFactory; + $this->orderModel = $orderModel; + $this->coinPaymentsMethod = $coinPaymentsMethod; + $this->transactionBuilder = $transactionBuilder; $this->baseConf = $this->getBaseConfig(); } + /** + * @param $requestParams + * @param array $requestData + * @return array + * @throws \Exception + */ public function getRequestHeaders($requestParams, $requestData = []) { @@ -78,7 +83,7 @@ public function getRequestHeaders($requestParams, $requestData = []) return [ 'X-CoinPayments-Client' => $requestParams['clientId'], 'X-CoinPayments-Timestamp' => $date->format('c'), - 'X-CoinPayments-Signature' => $this->generateHmac($headerData, $requestParams['clientSecret']), + 'X-CoinPayments-Signature' => $this->generateHmac($headerData, $requestParams['clientSecret'], true), ]; } @@ -100,7 +105,7 @@ public function sendPostRequest($action, $headers, $requestData) $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, 0); $requestUrl = $this->getApiUrl($action); - $this->curl->post($requestUrl, $requestData); + $this->curl->post($requestUrl, json_encode($requestData)); return json_decode($this->curl->getBody(), true); } @@ -137,38 +142,60 @@ public function sendGetRequest($action, $headers, $requestData = []) */ public function getApiUrl($action) { - return sprintf('%s/v%s/%s', $this->baseConf['api_url'], $this->baseConf['api_version'], $action); + return sprintf('%s/api/v%s/%s', 'http://192.168.80.205:18003', $this->baseConf['api_version'], $action); +// return sprintf('%s/v%s/%s', $this->baseConf['api_url'], $this->baseConf['api_version'], $action); } /** * @param $requestData * @param null $secretKey + * @param bool $useAdditional * @return string */ - public function generateHmac($requestData, $secretKey = null) + public function generateHmac($requestData, $secretKey = null, $useAdditional = false) { - return base64_encode(hash_hmac('sha256', chr(239) . implode('', $requestData), $secretKey, true)); + if ($useAdditional) { + $requestData = array_merge([chr(239), chr(187), chr(191)], $requestData); + } + + return base64_encode( + hash_hmac( + 'sha256', + implode('', $requestData), + $secretKey, + true + ) + ); } /** - * @param $base - * @param $field + * @param array $params * @return mixed */ - protected function getConfig($base, $field = false) + public function getCurrencies($params = []) { - if ($field) { - return $this->scopeConfig->getValue($base . DIRECTORY_SEPARATOR . $field); - } - return $this->scopeConfig->getValue($base); + return $this->sendGetRequest('currencies', [], $params); } /** * @param null $field * @return mixed */ - protected function getBaseConfig($field = null) + public function getBaseConfig($field = null) { return $this->getConfig('coinpayment/conf', $field); } + + /** + * @param $base + * @param $field + * @return mixed + */ + protected function getConfig($base, $field = false) + { + if ($field) { + return $this->scopeConfig->getValue($base . DIRECTORY_SEPARATOR . $field); + } + return $this->scopeConfig->getValue($base); + } } diff --git a/Model/Api/Currency.php b/Model/Api/Currency.php deleted file mode 100644 index 5aadb3c..0000000 --- a/Model/Api/Currency.php +++ /dev/null @@ -1,161 +0,0 @@ -cart->getQuote(); - $currencyCode = $quote->getBaseCurrencyCode(); - $amount = $quote->getBaseGrandTotal(); - $response = []; - - if ($coinShopCurrency = $this->getFiatCurrency($currencyCode)) { - $currencyId = $coinShopCurrency['currencyId']; - $convertedAmount = $this->convertCurrencies($currencyId, $coinCurrencyId, $amount, $coinCurrencyPrecision); - } - - if (!empty($convertedAmount)) { - - $this->checkoutSession->setCoinpaymentsCurrency($coinCurrencyId); - $this->checkoutSession->setCoinpaymentsAmount($convertedAmount['value']); - - $response = [ - 'converted_amount' => $convertedAmount['displayValue'], - ]; - } - -// $result = $this->jsonResultFactory->create(); -// $result->setData($response); - return json_encode($response); - } - - - /** - * @return array|mixed - */ - public function getAllCryptoCurrencies() - { - - $currencies = []; - - $listData = $this->getCryptoCurrencies(); - - if (!empty($listData['items'])) { - $currencies = $listData['items']; - while (!empty($listData['next_page_params']) && $listData = $this->getCryptoCurrencies($listData['next_page_params'])) { - if (!empty($listData['items'])) { - $currencies = array_merge($currencies, $listData['items']); - } - } - } - return $currencies; - } - - - /** - * @param array $params - * @return array|mixed - */ - public function getCryptoCurrencies(array $params = []) - { - - $params = array_merge($params, [ - 'types' => self::CRYPTO_TYPE, - 'capabilities' => self::PAYMENT_CAPABILITY, - ]); - - $listData = $this->getCurrencies($params); - if (!empty($listData['paging']['next'])) { - $nextPage = parse_url($listData['paging']['next']); - $nextPage['query_params'] = Psr7\parse_query($nextPage['query']); - $listData['next_page_params'] = $nextPage['query_params']; - } - - return $listData; - } - - /** - * @param array $params - * @return array|mixed - */ - public function getFiatCurrency(string $name) - { - - $params = [ - 'types' => self::FIAT_TYPE, - 'q' => $name, - ]; - $items = []; - - $listData = $this->getCurrencies($params); - if (!empty($listData['items'])) { - $items = $listData['items']; - } - - return array_shift($items); - } - - - /** - * @param array $params - * @return mixed - */ - public function getCurrencies($params = []) - { - return $this->sendGetRequest('currencies', [], $params); - } - - /** - * @param int $currencyId - * @param $coinCurrencyId - * @param $amount - * @return bool - */ - public function convertCurrencies($currencyId, $coinCurrencyId, $amount, $precision) - { - $rate = $this->getCurrencyRate($currencyId, $coinCurrencyId); - - $data['displayValue'] = $amount * $rate; - $data['value'] = number_format($amount * $rate, $precision, '', ''); - - return $data; - } - - /** - * @param $currencyId - * @param $coinCurrencyId - * @return bool|mixed - */ - public function getCurrencyRate($currencyId, $coinCurrencyId) - { - - $rate = false; - - $params = [ - 'from' => $currencyId, - 'to' => $coinCurrencyId, - ]; - - $listData = $this->sendGetRequest('rates', [], $params); - - if (!empty($listData['items'])) { - $rateData = array_shift($listData['items']); - $rate = $rateData['rate']; - } - - return $rate; - } - -} \ No newline at end of file diff --git a/Model/Api/Invoice.php b/Model/Api/Invoice.php deleted file mode 100644 index 1dca75f..0000000 --- a/Model/Api/Invoice.php +++ /dev/null @@ -1,107 +0,0 @@ -checkoutSession->getCoinpaymentsCurrency(); - $amount = $this->checkoutSession->getCoinpaymentsAmount(); - $order = $this->checkoutSession->getLastRealOrder(); - - $clientId = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_id'); - $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); - $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'webhooks'); - - if ($merchantWebHooks) { - $invoiceData = $this->createMerchant($clientId, $clientSecret, $currencyId, $order->getIncrementId(), intval($amount)); - } else { - $invoiceData = $this->createSimple($clientId, $currencyId, $order->getIncrementId(), intval($amount)); - } - - $response = []; - - if (!empty($invoiceData['id'])) { - $this->checkoutSession->setCoinpaymentsInvoiceId($invoiceData['id']); - $response = ['coinInvoiceId' => $invoiceData['id']]; - } - - return $response; - } - - /** - * @return boolean - */ - public function updateInvoice() - { - $response = false; - - return $response; - } - - /** - * @param $clientId - * @param $clientSecret - * @param $currencyId - * @param $invoiceId - * @param $amount - * @return mixed - * @throws \Exception - */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount) - { - $requestData = [ - "invoiceId" => $invoiceId, - "amount" => [ - "currencyId" => $currencyId, - "value" => $amount - ], - ]; - - $action = sprintf('merchant/invoices', $clientId); - - $requestParams = [ - 'method' => 'POST', - 'action' => $action, - 'clientId' => $clientId, - 'clientSecret' => $clientSecret, - ]; - - $headers = $this->getRequestHeaders($requestParams, $requestData); - - return $this->sendPostRequest($action, $headers, $requestData); - } - - /** - * @param $clientId - * @param int $currencyId - * @param string $invoiceId - * @param int $amount - * @return mixed - */ - public function createSimple($clientId, $currencyId = 1, $invoiceId = 'Validate invoice', $amount = 1) - { - - $action = 'invoices'; - - $requestParams = [ - 'clientId' => $clientId, - 'invoiceId' => $invoiceId, - 'amount' => [ - 'currencyId' => $currencyId, - 'value' => $amount - ] - ]; - - return $this->sendPostRequest($action, [], $requestParams); - } -} \ No newline at end of file diff --git a/Model/Api/WebHook.php b/Model/Api/WebHook.php deleted file mode 100644 index 1970857..0000000 --- a/Model/Api/WebHook.php +++ /dev/null @@ -1,81 +0,0 @@ -urlBuilder->getUrl('rest/V1/coinpayments/invoice/notification', ['_direct' => null]); - } - - public function createWebHook($clientId, $clientSecret) - { - - return [ // TODO delete test data - "id" => "testId", - "notificationsUrl" => $this->getWebHookCallbackUrl(), - "notifications" => [ - "invoiceCreated", - ] - ]; - - $action = sprintf('merchant/clients/%s/webhooks', $clientId); - - $requestParams = [ - 'method' => 'POST', - 'action' => $action, - 'clientId' => $clientId, - 'clientSecret' => $clientSecret, - ]; - - $requestData = [ - "notificationsUrl" => $this->getWebHookCallbackUrl(), - "notifications" => [ - "invoiceCreated", - "invoicePaymentsReceived", - "invoicePaymentsConfirmed", - "invoiceCompleted", - "invoiceExpired", - ], - ]; - - $headers = $this->getRequestHeaders($requestParams, $requestData); - return $this->sendPostRequest($action, $headers, $requestData); - } - - public function getList($clientId, $clientSecret) - { - - return [ // TODO delete test data - "items" => [ - [ - "id" => "testId", - "notificationsUrl" => "https://magento2.test/rest/V1/coinpayments/invoice/notification/", - "notificationsUrl" => "https://magento2.test/rest/V1/coinpayments/", - "notifications" => [ - "invoiceCreated", - ] - ] - ] - ]; - - $action = sprintf('merchant/clients/%s/webhooks', $clientId); - $requestParams = [ - 'method' => 'GET', - 'action' => $action, - 'clientId' => $clientId, - 'clientSecret' => $clientSecret, - ]; - - $headers = $this->getRequestHeaders($requestParams); - - return $this->sendGetRequest($action, $headers); - } - - -} \ No newline at end of file diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 2574cb9..ddcf514 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -6,27 +6,14 @@ use Magento\Framework\HTTP\Client\Curl; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\View\Asset\Repository; -use Coinpayments\CoinPayments\Model\Api\Currency as CurrencyApi; class CoinPaymentsConfigProvider implements ConfigProviderInterface { - /** - * @var Curl - */ - protected $curl; - /** - * @var ScopeConfigInterface - */ - protected $_scopeConfig; /** * @var Repository */ protected $_assetRepo; - /** - * @var CurrencyApi - */ - protected $_apiCurrency; /** * @var string */ @@ -34,17 +21,11 @@ class CoinPaymentsConfigProvider implements ConfigProviderInterface /** * CoinPaymentsConfigProvider constructor. - * @param Curl $curl - * @param ScopeConfigInterface $scopeConfig * @param Repository $assetRepo - * @param CurrencyApi $apiCurrency */ - public function __construct(Curl $curl, ScopeConfigInterface $scopeConfig, Repository $assetRepo, CurrencyApi $apiCurrency) + public function __construct(Curl $curl, ScopeConfigInterface $scopeConfig, Repository $assetRepo) { - $this->curl = $curl; - $this->_scopeConfig = $scopeConfig; $this->_assetRepo = $assetRepo; - $this->_apiCurrency = $apiCurrency; } /** @@ -52,48 +33,12 @@ public function __construct(Curl $curl, ScopeConfigInterface $scopeConfig, Repos */ public function getConfig() { - $currencies = $this->getCryptoCurrencies(); - return [ 'payment' => [ 'coinpayments' => [ - 'currencies' => $currencies, 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), ] ] ]; } - - /** - * @return array - */ - public function getCryptoCurrencies() - { - $currencies = []; - - $apiCurrencies = $this->_apiCurrency->getAllCryptoCurrencies(); - - if (!empty($apiCurrencies)) { - foreach ($apiCurrencies as $key => $item) { - $elm = [ - 'value' => $item['currencyId'], - 'name' => $item['name'], - 'body' => $item, - ]; - $currencies[] = $elm; - } - } else { - $currencies = [ - 'error' => [ - 'name' => 'Cannot load Coinpayments.Net currencies', - 'value' => 'error', - 'attr' => [ - 'disabled' => true, - ], - ], - ]; - } - - return $currencies; - } } diff --git a/Model/Invoice.php b/Model/Invoice.php new file mode 100644 index 0000000..416030b --- /dev/null +++ b/Model/Invoice.php @@ -0,0 +1,69 @@ + $invoiceId, + "amount" => [ + "currencyId" => $currencyId, + "value" => $amount + ], + ]; + + $action = 'merchant/invoices'; + + $requestParams = [ + 'method' => 'POST', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $headers = $this->getRequestHeaders($requestParams, $requestData); + + return $this->sendPostRequest($action, $headers, $requestData); + } + + /** + * @param $clientId + * @param int $currencyId + * @param string $invoiceId + * @param int $amount + * @return mixed + */ + public function createSimple($clientId, $currencyId = 1, $invoiceId = 'Validate invoice', $amount = 1) + { + + $action = 'invoices'; + + $requestParams = [ + 'clientId' => $clientId, + 'invoiceId' => $invoiceId, + 'amount' => [ + 'currencyId' => $currencyId, + 'value' => $amount + ] + ]; + + return $this->sendPostRequest($action, [], $requestParams); + } + + +} \ No newline at end of file diff --git a/Model/Methods/Coinpayments.php b/Model/Methods/Coinpayments.php index ccbfce1..6513256 100644 --- a/Model/Methods/Coinpayments.php +++ b/Model/Methods/Coinpayments.php @@ -28,14 +28,6 @@ class Coinpayments extends AbstractMethod */ protected $_code = self::CODE; - - /* Uncomment if need using blocks - - protected $_formBlockType = 'Coinpayments\CoinPayments\Block\Form\Coinpayments'; - - protected $_infoBlockType = 'Coinpayments\CoinPayments\Block\Info';*/ - - /** * @param CartInterface|null $quote * @return bool diff --git a/Model/WebHook.php b/Model/WebHook.php new file mode 100644 index 0000000..27e028f --- /dev/null +++ b/Model/WebHook.php @@ -0,0 +1,143 @@ + 'POST', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $requestData = [ + "notificationsUrl" => $webHookCallbackUrl, + "notifications" => [ + "invoiceCreated", + "invoicePaymentsReceived", + "invoicePaymentsConfirmed", + "invoiceCompleted", + "invoiceExpired", + ], + ]; + + $headers = $this->getRequestHeaders($requestParams, $requestData); + return $this->sendPostRequest($action, $headers, $requestData); + } + + /** + * @param $clientId + * @param $clientSecret + * @return mixed + * @throws \Exception + */ + public function getList($clientId, $clientSecret) + { + + $action = sprintf('merchant/clients/%s/webhooks', $clientId); + $requestParams = [ + 'method' => 'GET', + 'action' => $action, + 'clientId' => $clientId, + 'clientSecret' => $clientSecret, + ]; + + $headers = $this->getRequestHeaders($requestParams); + + return $this->sendGetRequest($action, $headers); + } + + /** + * @param $requestData + * @throws \Exception + */ + public function cancelOrder($requestData) + { + $order = $this->orderModel->loadByIncrementId($requestData['invoice']['invoiceId']); + if ($order->getId()) { + $order + ->setStatus(Order::STATE_CANCELED) + ->setState(Order::STATE_CANCELED) + ->save(); + } + } + + /** + * @param $order + * @param $requestData + * @return bool + */ + public function completeOrder($requestData) + { + $order = $this->orderModel->loadByIncrementId($requestData['invoice']['invoiceId']); + if ($order->getId()) { + $order->setTotalPaid($requestData['invoice']['amount']['displayValue']); + + $order + ->setState($this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'status_order_paid')) + ->setStatus($this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'status_order_paid')); + + $str = 'CoinPayments.net Payment Status: ' . $requestData['status'] . ' ' . $requestData['status'] . '
    '; + + $str .= 'Transaction ID: ' . $requestData['invoice']['invoiceId'] . '
    '; + $str .= 'Received Amount: ' . sprintf('%s %s', $requestData['invoice']['amount']['displayValue'], $requestData['invoice']['currency']['symbol']); + + $order->addStatusToHistory($order->getStatus(), $str); + + + try { + $payment = $order->getPayment(); + $payment->setMethod($this->coinPaymentsMethod->getCode()); + $payment->setLastTransId($requestData['invoice']['invoiceId']); + $payment->setTransactionId($requestData['invoice']['invoiceId']); + $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$requestData]); + + $formatedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal()); + + /* @var Order\Payment\Transaction\BuilderInterface */ + $transaction = $this->transactionBuilder + ->setPayment($payment) + ->setOrder($order) + ->setTransactionId($requestData['invoice']['invoiceId']) + ->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$requestData]) + ->setFailSafe(true) + ->build(Order\Payment\Transaction::TYPE_CAPTURE); + + // Add transaction to payment + $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); + $payment->setParentTransactionId(null); + + // Save payment, transaction and order + $payment->save(); + $order->save(); + $transaction->save(); + return $transaction->getTransactionId(); + + } catch (\Exception $e) { + + } + + } + + return true; + } + + +} \ No newline at end of file diff --git a/etc/config.xml b/etc/config.xml index ed6f3b1..2abb88a 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - https://orion-api-testnet.starhermit.com/api + https://orion-api-testnet.starhermit.com 1 diff --git a/etc/di.xml b/etc/di.xml index c1e61f3..0444908 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,6 +1,5 @@ - \ No newline at end of file diff --git a/etc/webapi.xml b/etc/webapi.xml deleted file mode 100644 index c6bb512..0000000 --- a/etc/webapi.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index fe26359..213bf9d 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -15,15 +15,6 @@ - - - - - Coinpayments_CoinPayments/js/view/payment/validate-selected-currency - - - - diff --git a/view/frontend/layout/coinpayments_checkout_failure.xml b/view/frontend/layout/coinpayments_checkout_failure.xml new file mode 100644 index 0000000..71e3b5b --- /dev/null +++ b/view/frontend/layout/coinpayments_checkout_failure.xml @@ -0,0 +1,19 @@ + + + + + + + We received your order! + + + + + + + diff --git a/view/frontend/web/js/model/validate-selected-currency.js b/view/frontend/web/js/model/validate-selected-currency.js deleted file mode 100644 index 6c8d6b9..0000000 --- a/view/frontend/web/js/model/validate-selected-currency.js +++ /dev/null @@ -1,28 +0,0 @@ -define( - ['jquery'], - function ($) { - 'use strict'; - return { - getCode: function () { - return 'coin_payments'; - }, - /** - * @returns {boolean} - */ - validate: function () { - var valid = true; - - var selector = $("#" + this.getCode() + "_crypto_currency"); - - if (!selector.find('option:selected').val()) { - selector.addClass('mage-error'); - valid = false; - } else { - selector.removeClass('mage-error'); - } - - return valid; - } - } - } -); \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/coin_payments.js b/view/frontend/web/js/view/payment/coin_payments.js index 45b950b..0d2585d 100644 --- a/view/frontend/web/js/view/payment/coin_payments.js +++ b/view/frontend/web/js/view/payment/coin_payments.js @@ -9,8 +9,6 @@ define( ) { 'use strict'; - console.log('method-renderer/coin-method'); - rendererList.push( { type: 'coin_payments', 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 4cf9476..2e4d0b5 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 @@ -31,8 +31,9 @@ define( 'use strict'; window.fullScreenLoader = fullScreenLoader; + window.url = url; - return Component.extend({ + var a = Component.extend({ defaults: { template: 'Coinpayments_CoinPayments/payment/coin_payment' }, @@ -43,24 +44,7 @@ define( return 'coin_payments'; }, afterPlaceOrder: function () { - this.createInvoice( - window.checkoutConfig.payment.coinpayments.currentData.currency, - window.checkoutConfig.payment.coinpayments.currentData.total, - url.build('checkout/onepage/success') - ); - }, - getCaption: function () { - var caption = 'Select Coinpayments.Net currency'; - if (window.checkoutConfig.payment.coinpayments.currencies.error) { - caption = window.checkoutConfig.payment.coinpayments.currencies.error.name; - } - return caption; - }, - getCurrencies: function () { - if (!window.checkoutConfig.payment.coinpayments.currencies.error) { - return ko.observableArray(window.checkoutConfig.payment.coinpayments.currencies); - } - return []; + this.createInvoice(); }, /** * @@ -112,57 +96,6 @@ define( getPaymentAcceptanceMarkSrc: function () { return window.checkoutConfig.payment.coinpayments.logo; }, - getCurrencyCode: function () { - return window.checkoutConfig.totalsData.quote_currency_code; - }, - /** - * - * @param element - * @param event - */ - getConvertedAmount: function (element, event) { - var elemToChange = $('#converted_amount_coinpayments'); - var coinCurrencyId = $(event.target).find('option:selected').val(); - var coinCurrencyCode = false; - var coinCurrencyPrecision = false; - - window.checkoutConfig.payment.coinpayments.currencies.forEach(function (val, index) { - if (val.body.currencyId == coinCurrencyId) { - coinCurrencyCode = val.body.symbol; - coinCurrencyPrecision = val.body.decimalPlaces; - } - }) - - if (coinCurrencyId) { - var url = '/rest/V1/coinpayments/currency/set'; - var data = { - coinCurrencyId: coinCurrencyId, - coinCurrencyPrecision: coinCurrencyPrecision, - }; - $.ajax({ - type: "POST", - encoding: 'UTF-8', - url: url, - showLoader: true, - contentType: "application/json", - data: JSON.stringify(data), - dataType: 'json', - success: function (result) { - result = JSON.parse(result); - var total = result.converted_amount; - total = total.toFixed(coinCurrencyPrecision); - elemToChange.val(total + ' ' + coinCurrencyCode); - window.checkoutConfig.payment.coinpayments.currentData = { - total: total, - currency: coinCurrencyCode - }; - }, - error: function (err) { - //TODO error logic - } - }); - } - }, /** * @returns {boolean} */ @@ -175,24 +108,20 @@ define( * @param value * @param redirect */ - createInvoice: function (currency, value, redirect) { - - var url = '/rest/V1/coinpayments/invoice/create'; - + createInvoice: function () { $.ajax({ type: "POST", - url: url, + dataType: 'json', contentType: "application/json", + url: url.build('coinpayments/invoice/create'), success: function (result) { - var invoiceId = result[0]; - - try { - window.popup = undefined; - showPaymentsPopup(invoiceId, redirect); - } catch (e) { - console.error(e); + result = JSON.parse(result); + console.log(result) + if (result.coinInvoiceId) { + window.location.href = result.redirectUrl; + } else { + window.location.href = result.cancelUrl; } - }, error: function (err) { console.log(error); @@ -202,74 +131,9 @@ define( } }); } - }) - ; + }); + window.a = a; + return a; } ) -; - - -function showPaymentsPopup(invoiceId, redirect) { - - window.fullScreenLoader.startLoader(); - var apiBaseUrl = "https://orion-api-testnet.starhermit.com"; - var id = "Checkout_Magento2_" + (Math.random() * 9007199254740991).toString(16); - var checkoutAppUrl = apiBaseUrl + "/checkout"; - - var popupWidth = 480 + 20; - var popupHeight = 620 + 60; - - var popupFeatures = { - width: popupWidth, - height: popupHeight, - status: 1, - toolbar: 0, - menubar: 0, - resizable: 1, - scrollbars: 1 - }; - var features = Object.keys(popupFeatures) - .map(function (key) { - return key + "=" + popupFeatures[key]; - }) - .join(","); - - window.popup = window.open(checkoutAppUrl, id, features); - - var interval = setInterval(function () { - if (!window.popup || window.popup.closed) { - clearInterval(interval); - window.fullScreenLoader.stopLoader(true); - window.popup = undefined; - if (redirect) { - window.location.replace(redirect); - } - } - }, 1000); - - window.addEventListener("message", function (event) { - switch (event.data.action) { - case "CoinPaymentsCheckoutAppInitialized": - var msg = { - action: "CoinPaymentsCheckoutAppInitializeInvoice", - data: { - apiBaseUrl: apiBaseUrl, - invoiceId: invoiceId - } - }; - window.popup.postMessage(msg, "*"); - return false; - case "CoinPaymentsPaymentButtonModalClosePressed": - case "CoinPaymentsCheckoutAppInvoiceCancelled": - case "CoinPaymentsCheckoutAppInvoiceConfirmed": - window.fullScreenLoader.stopLoader(true); - popup.close(); - if (redirect) { - window.location.replace(redirect); - } - return false; - } - }, true); - - window.popup; -} \ No newline at end of file +; \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/validate-selected-currency.js b/view/frontend/web/js/view/payment/validate-selected-currency.js deleted file mode 100644 index cdb8c8c..0000000 --- a/view/frontend/web/js/view/payment/validate-selected-currency.js +++ /dev/null @@ -1,16 +0,0 @@ -define( - [ - 'uiComponent', - 'Magento_Checkout/js/model/payment/additional-validators', - 'Coinpayments_CoinPayments/js/model/validate-selected-currency' - ], - function ( - Component, - additionalValidators, - validateSelectedCurrency - ) { - 'use strict'; - additionalValidators.registerValidator(validateSelectedCurrency); - return Component.extend({}); - } -); \ No newline at end of file diff --git a/view/frontend/web/template/payment/coin_payment.html b/view/frontend/web/template/payment/coin_payment.html index d36cac6..295bbdc 100644 --- a/view/frontend/web/template/payment/coin_payment.html +++ b/view/frontend/web/template/payment/coin_payment.html @@ -14,56 +14,6 @@ -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    From 9ae071f773361518a7b48fb9d2c6e11e2736039c Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 15 Jan 2020 13:44:14 +0200 Subject: [PATCH 034/107] Fix test data & api_host --- Controller/Adminhtml/Validation/WebHook.php | 3 +-- Controller/Invoice/Create.php | 14 ++++++++++---- Controller/WebHooks/Notification.php | 7 +------ Model/AbstractApi.php | 3 +-- Model/WebHook.php | 4 ++-- etc/config.xml | 5 +++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 8e618e0..e9145d1 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -76,7 +76,6 @@ public function execute() */ protected function getWebHookCallbackUrl() { -// return $this->urlBuilder->getUrl('coinpayments/webhooks/notification', ['_direct' => null]); - return 'http://34.95.25.102/'; // TODO delete test data + return $this->urlBuilder->getUrl('coinpayments/webhooks/notification', ['_direct' => null]); } } \ No newline at end of file diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 5e2a61f..89034dd 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -79,9 +79,9 @@ public function execute() if (!empty($coinCurrency)) { - $clientId = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_id'); - $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); - $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'webhooks'); + $clientId = $this->scopeConfig->getValue('payment/coin_payments/client_id'); + $clientSecret = $this->scopeConfig->getValue('payment/coin_payments/client_secret'); + $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments/webhooks'); if ($merchantWebHooks) { $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $order->getIncrementId(), intval($amount)); @@ -116,7 +116,13 @@ public function execute() */ protected function getCoinCheckoutRedirectUrl($coinInvoiceId, $successUrl, $cancelUrl) { - return sprintf('%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', $this->invoiceModel->getBaseConfig('api_url'), $coinInvoiceId, $successUrl, $cancelUrl); + return sprintf( + '%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', + $this->invoiceModel->getBaseConfig('api_host'), + $coinInvoiceId, + $successUrl, + $cancelUrl + ); } /** diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index c5f7b0e..f9bc9a0 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -53,10 +53,6 @@ public function execute() if ($this->checkDataSignature($signature, $content)) { $requestData = json_decode($content, true); - // TODO delete test data - $requestData['invoice']['invoiceId'] = '000000019'; - $requestData['status'] = 'Completed'; - if ($requestData['status'] == 'Completed') { $this->webHookModel->completeOrder($requestData); } elseif ($requestData['status'] == 'Expired') { @@ -75,9 +71,8 @@ protected function checkDataSignature($signature, $content) { $requestUrl = $this->urlBuilder->getCurrentUrl(); - $requestUrl = 'http://34.95.25.102/'; // TODO delete test data - $clientSecret = $this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'client_secret'); + $clientSecret = $this->scopeConfig->getValue('payment/coin_payments/client_secret'); $encodedPure = $this->webHookModel->generateHmac([$requestUrl, $content], $clientSecret); return $signature == $encodedPure; } diff --git a/Model/AbstractApi.php b/Model/AbstractApi.php index 15d6e53..111f423 100644 --- a/Model/AbstractApi.php +++ b/Model/AbstractApi.php @@ -142,8 +142,7 @@ public function sendGetRequest($action, $headers, $requestData = []) */ public function getApiUrl($action) { - return sprintf('%s/api/v%s/%s', 'http://192.168.80.205:18003', $this->baseConf['api_version'], $action); -// return sprintf('%s/v%s/%s', $this->baseConf['api_url'], $this->baseConf['api_version'], $action); + return sprintf('%s/api/v%s/%s', $this->baseConf['api_host'], $this->baseConf['api_version'], $action); } /** diff --git a/Model/WebHook.php b/Model/WebHook.php index 27e028f..e782424 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -91,8 +91,8 @@ public function completeOrder($requestData) $order->setTotalPaid($requestData['invoice']['amount']['displayValue']); $order - ->setState($this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'status_order_paid')) - ->setStatus($this->scopeConfig->getValue('payment/coin_payments' . DIRECTORY_SEPARATOR . 'status_order_paid')); + ->setState($this->scopeConfig->getValue('payment/coin_payments/status_order_paid')) + ->setStatus($this->scopeConfig->getValue('payment/coin_payments/status_order_paid')); $str = 'CoinPayments.net Payment Status: ' . $requestData['status'] . ' ' . $requestData['status'] . '
    '; diff --git a/etc/config.xml b/etc/config.xml index 2abb88a..834a9db 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,9 +13,10 @@ - https://orion-api-testnet.starhermit.com + http://192.168.80.205:18003 1 - ` + + ` \ No newline at end of file From 1c067f7721c435e8ab5a6f61078ffb33a4a60da4 Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 15 Jan 2020 19:18:09 +0200 Subject: [PATCH 035/107] dev release --- Api/InvoiceInterface.php | 3 +- Controller/Adminhtml/Validation/Invoice.php | 8 +- .../Adminhtml/Validation/Validation.php | 17 +-- Controller/Adminhtml/Validation/WebHook.php | 22 ++-- Controller/Checkout/Failure.php | 46 +++---- Controller/Invoice/Create.php | 51 ++++---- Controller/WebHooks/Notification.php | 30 +++-- Helper/Data.php | 122 ++++++++++++++++++ Model/AbstractApi.php | 44 ++----- Model/CoinPaymentsConfigProvider.php | 6 +- Model/Invoice.php | 13 +- Model/WebHook.php | 19 ++- README.md | 11 ++ view/adminhtml/templates/js_vars.phtml | 4 +- view/frontend/layout/checkout_index_index.xml | 6 + view/frontend/templates/js_vars.phtml | 7 + .../payment/method-renderer/coin-method.js | 2 +- 17 files changed, 275 insertions(+), 136 deletions(-) create mode 100644 Helper/Data.php create mode 100644 view/frontend/templates/js_vars.phtml diff --git a/Api/InvoiceInterface.php b/Api/InvoiceInterface.php index c1b3821..0d81431 100644 --- a/Api/InvoiceInterface.php +++ b/Api/InvoiceInterface.php @@ -20,8 +20,9 @@ public function createSimple($clientId, $currencyId, $invoiceId, $amount); * @param $currencyId * @param $invoiceId * @param $amount + * @param $displayValue * @return mixed */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount); + public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $displayValue); } \ No newline at end of file diff --git a/Controller/Adminhtml/Validation/Invoice.php b/Controller/Adminhtml/Validation/Invoice.php index 5bcf293..09d5e29 100644 --- a/Controller/Adminhtml/Validation/Invoice.php +++ b/Controller/Adminhtml/Validation/Invoice.php @@ -17,10 +17,11 @@ public function execute() $params = $this->getRequest()->getParams(); $response = []; - if (!empty($params['client_id'])) { + if (!empty($params['client_id']) && $this->helper->getConfig('validated') != $params['client_id']) { $clientId = $params['client_id']; $invoice = $this->invoiceModel->createSimple($clientId); if ($invoice) { + $this->helper->setConfig('validated', $params['client_id']); $response = [ 'success' => $invoice ]; @@ -30,6 +31,10 @@ public function execute() 'errorText' => sprintf('Failed to create validation invoice!'), ]; } + } elseif ($this->helper->getConfig('validated') == $params['client_id']) { + $response = [ + 'success' => $params['client_id'] + ]; } else { $response = [ 'success' => false, @@ -37,6 +42,7 @@ public function execute() ]; } + $result = $this->jsonResultFactory->create(); $result->setData($response); return $result; diff --git a/Controller/Adminhtml/Validation/Validation.php b/Controller/Adminhtml/Validation/Validation.php index 33caa64..eed92a5 100644 --- a/Controller/Adminhtml/Validation/Validation.php +++ b/Controller/Adminhtml/Validation/Validation.php @@ -2,6 +2,7 @@ namespace Coinpayments\CoinPayments\Controller\Adminhtml\Validation; +use Coinpayments\CoinPayments\Helper\Data; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\Framework\Url; @@ -20,11 +21,6 @@ class Validation extends Action */ protected $jsonResultFactory; - /** - * @var Url - */ - protected $urlBuilder; - /** * @var WebHook */ @@ -34,27 +30,32 @@ class Validation extends Action * @var Invoice */ protected $invoiceModel; + /** + * @var Data + */ + protected $helper; /** * Authenticate constructor. * @param Context $context * @param JsonFactory $jsonResultFactory - * @param Url $urlBuilder * @param WebHook $webHook * @param Invoice $invoice + * @param Data $helper */ public function __construct( Context $context, JsonFactory $jsonResultFactory, - Url $urlBuilder, WebHook $webHook, - Invoice $invoice + Invoice $invoice, + Data $helper ) { parent::__construct($context); $this->jsonResultFactory = $jsonResultFactory; $this->webHookModel = $webHook; $this->invoiceModel = $invoice; + $this->helper = $helper; } public function execute() diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index e9145d1..9f14a2e 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -2,6 +2,7 @@ namespace Coinpayments\CoinPayments\Controller\Adminhtml\Validation; +use Coinpayments\CoinPayments\Helper\Data; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; @@ -18,7 +19,7 @@ public function execute() $params = $this->getRequest()->getParams(); $response = []; - if (!empty($params['client_id']) && !empty($params['client_secret'])) { + if (!empty($params['client_id']) && !empty($params['client_secret']) && $this->helper->getConfig('validated') != ($params['client_id'] . $params['client_secret'])) { $client_id = $params['client_id']; $client_secret = $params['client_secret']; @@ -34,9 +35,10 @@ public function execute() }, $webHooksList['items']); } - if (!in_array($this->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->getWebHookCallbackUrl()); + if (!in_array($this->webHookModel->getWebHookCallbackUrl(), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->webHookModel->getWebHookCallbackUrl()); if (!empty($webHook)) { + $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ 'success' => $webHook, ]; @@ -47,6 +49,7 @@ public function execute() ]; } } else { + $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ 'success' => true, ]; @@ -57,6 +60,10 @@ public function execute() 'errorText' => sprintf('Failed to get WebHooks list!'), ]; } + } elseif ($this->helper->getConfig('validated') == ($params['client_id'] . $params['client_secret'])) { + $response = [ + 'success' => true, + ]; } else { $response = [ 'success' => false, @@ -69,13 +76,4 @@ public function execute() $result->setData($response); return $result; } - - - /** - * @return string - */ - protected function getWebHookCallbackUrl() - { - return $this->urlBuilder->getUrl('coinpayments/webhooks/notification', ['_direct' => null]); - } } \ No newline at end of file diff --git a/Controller/Checkout/Failure.php b/Controller/Checkout/Failure.php index 4583dea..bcefdb5 100644 --- a/Controller/Checkout/Failure.php +++ b/Controller/Checkout/Failure.php @@ -4,36 +4,36 @@ use Magento\Sales\Model\OrderRepository; use Magento\Sales\Model\Order; -use Psr\Log\LoggerInterface; +use Magento\Checkout\Model\Session; +use Magento\Framework\App\Action\Context; +use Magento\Framework\View\Result\PageFactory; +use Magento\Framework\App\Action\Action; -class Failure extends \Magento\Framework\App\Action\Action +class Failure extends Action { - private $checkoutSession; - private $orderFactory; - private $orderRepository; - private $resultPageFactory; - private $logger; - private $cacheTypeList; - private $cacheFrontendPool; + /** + * @var Session + */ + protected $checkoutSession; + /** + * @var OrderRepository + */ + protected $orderRepository; + /** + * @var PageFactory + */ + protected $resultPageFactory; public function __construct( - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Sales\Model\OrderFactory $orderFactory, + Session $checkoutSession, OrderRepository $orderRepository, - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\View\Result\PageFactory $resultPageFactory, - LoggerInterface $logger, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool + Context $context, + PageFactory $resultPageFactory ) { $this->checkoutSession = $checkoutSession; - $this->orderFactory = $orderFactory; $this->orderRepository = $orderRepository; $this->resultPageFactory = $resultPageFactory; - $this->logger = $logger; - $this->cacheTypeList = $cacheTypeList; - $this->cacheFrontendPool = $cacheFrontendPool; parent::__construct($context); } @@ -44,16 +44,12 @@ public function execute() $order = $this->orderRepository->get($lastOrderId); $order->setStatus(Order::STATE_CANCELED)->setState(Order::STATE_CANCELED); $this->orderRepository->save($order); - $this->logger->info('ORDER INFO: ' . $order->getStatus() . $order->getState()); - return $this->resultPageFactory->create(); } public function getRealOrderId() { - $lastorderId = $this->checkoutSession->getLastOrderId(); - - return $lastorderId; + return $this->checkoutSession->getLastOrderId(); } } diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 89034dd..d5f5c4c 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -2,6 +2,7 @@ namespace Coinpayments\CoinPayments\Controller\Invoice; +use Coinpayments\CoinPayments\Helper\Data; use Coinpayments\CoinPayments\Model\Invoice; use Magento\Framework\App\Action\Context; use Magento\Framework\App\Action\Action; @@ -36,10 +37,25 @@ class Create extends Action implements CsrfAwareActionInterface * @var JsonFactory */ protected $jsonResultFactory; + /** + * @var Data + */ + private $helper; + /** + * Create constructor. + * @param Context $context + * @param Invoice $invoice + * @param Data $helper + * @param Session $checkoutSession + * @param ScopeConfigInterface $scopeConfig + * @param Url $urlBuilder + * @param JsonFactory $jsonResultFactory + */ public function __construct( Context $context, Invoice $invoice, + Data $helper, \Magento\Checkout\Model\Session $checkoutSession, ScopeConfigInterface $scopeConfig, Url $urlBuilder, @@ -49,6 +65,7 @@ public function __construct( $this->urlBuilder = $urlBuilder; $this->invoiceModel = $invoice; + $this->helper = $helper; $this->scopeConfig = $scopeConfig; $this->checkoutSession = $checkoutSession; $this->jsonResultFactory = $jsonResultFactory; @@ -58,7 +75,6 @@ public function __construct( public function execute() { - $response = [ 'successUrl' => $this->urlBuilder->getUrl('checkout/onepage/success'), 'cancelUrl' => $this->urlBuilder->getUrl('coinpayments/checkout/failure'), @@ -68,7 +84,7 @@ public function execute() if ($order->getIncrementId()) { - $coinInvoiceCacheId = Invoice::INVOICE_CACHE_PREFIX . $order->getIncrementId(); + $coinInvoiceCacheId = Data::INVOICE_CACHE_PREFIX . $order->getIncrementId(); $coinInvoiceId = $this->checkoutSession->{'get' . $coinInvoiceCacheId}(); if (empty($coinInvoiceId)) { @@ -79,14 +95,14 @@ public function execute() if (!empty($coinCurrency)) { - $clientId = $this->scopeConfig->getValue('payment/coin_payments/client_id'); - $clientSecret = $this->scopeConfig->getValue('payment/coin_payments/client_secret'); - $merchantWebHooks = $this->scopeConfig->getValue('payment/coin_payments/webhooks'); + $clientId = $this->helper->getConfig(Data::CLIENT_ID_KEY); + $clientSecret = $this->helper->getConfig(Data::CLIENT_SECRET_KEY); + $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); if ($merchantWebHooks) { - $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $order->getIncrementId(), intval($amount)); + $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $order->getIncrementId(), intval($amount), $order->getGrandTotal()); } else { - $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $order->getIncrementId(), intval($amount)); + $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $order->getIncrementId(), intval($amount), $order->getGrandTotal()); } if (!empty($invoiceData['id'])) { @@ -99,7 +115,7 @@ public function execute() if (!empty($coinInvoiceId)) { $response['coinInvoiceId'] = $coinInvoiceId; - $response['redirectUrl'] = $this->getCoinCheckoutRedirectUrl($coinInvoiceId, $response['successUrl'], $response['cancelUrl']); + $response['redirectUrl'] = $this->helper->getCoinCheckoutRedirectUrl($coinInvoiceId, $response['successUrl'], $response['cancelUrl']); } } @@ -108,23 +124,6 @@ public function execute() return $result; } - /** - * @param $coinInvoiceId - * @param $successUrl - * @param $cancelUrl - * @return string - */ - protected function getCoinCheckoutRedirectUrl($coinInvoiceId, $successUrl, $cancelUrl) - { - return sprintf( - '%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', - $this->invoiceModel->getBaseConfig('api_host'), - $coinInvoiceId, - $successUrl, - $cancelUrl - ); - } - /** * @param string $name * @return array|mixed @@ -133,7 +132,7 @@ protected function getCoinCurrency(string $name) { $params = [ - 'types' => Invoice::FIAT_TYPE, + 'types' => Data::FIAT_TYPE, 'q' => $name, ]; $items = []; diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index f9bc9a0..ad9d637 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -2,6 +2,7 @@ namespace Coinpayments\CoinPayments\Controller\WebHooks; +use Coinpayments\CoinPayments\Helper\Data; use Coinpayments\CoinPayments\Model\WebHook; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Action\Context; @@ -26,19 +27,21 @@ class Notification extends Action implements CsrfAwareActionInterface /* @var ScopeConfigInterface */ protected $scopeConfig; /** - * @var JsonFactory + * @var Data */ - protected $jsonResultFactory; + protected $helper; public function __construct( Context $context, WebHook $webHookModel, + Data $helper, Url $urlBuilder, ScopeConfigInterface $scopeConfig ) { $this->urlBuilder = $urlBuilder; $this->webHookModel = $webHookModel; + $this->helper = $helper; $this->scopeConfig = $scopeConfig; parent::__construct($context); } @@ -47,17 +50,21 @@ public function __construct( public function execute() { - $content = $this->getRequest()->getContent(); - $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); - if ($this->checkDataSignature($signature, $content)) { - $requestData = json_decode($content, true); + if ($this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY)) { - if ($requestData['status'] == 'Completed') { - $this->webHookModel->completeOrder($requestData); - } elseif ($requestData['status'] == 'Expired') { - $this->webHookModel->cancelOrder($requestData); + $content = $this->getRequest()->getContent(); + $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); + + if ($this->checkDataSignature($signature, $content)) { + $requestData = json_decode($content, true); + if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { + $this->webHookModel->completeOrder($requestData); + } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_EXPIRED) { + $this->webHookModel->cancelOrder($requestData); + } } + } } @@ -71,8 +78,7 @@ protected function checkDataSignature($signature, $content) { $requestUrl = $this->urlBuilder->getCurrentUrl(); - - $clientSecret = $this->scopeConfig->getValue('payment/coin_payments/client_secret'); + $clientSecret = $this->helper->getConfig(Data::CLIENT_SECRET_KEY); $encodedPure = $this->webHookModel->generateHmac([$requestUrl, $content], $clientSecret); return $signature == $encodedPure; } diff --git a/Helper/Data.php b/Helper/Data.php new file mode 100644 index 0000000..377fefd --- /dev/null +++ b/Helper/Data.php @@ -0,0 +1,122 @@ + + */ + +namespace Coinpayments\CoinPayments\Helper; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Helper\AbstractHelper; +use Magento\Framework\App\Helper\Context; +use Magento\Store\Model\ScopeInterface; +use Magento\Config\Model\ResourceModel\Config; + +class Data extends AbstractHelper +{ + + + const FIAT_TYPE = 'fiat'; + const INVOICE_CACHE_PREFIX = 'CoinpaymentsInvoice'; + + const XML_PATH_CONFIG_COINPAYMENTS = 'payment/coin_payments/'; + + const CLIENT_ID_KEY = 'client_id'; + const CLIENT_SECRET_KEY = 'client_secret'; + const CLIENT_WEBHOOKS_KEY = 'webhooks'; + const CLIENT_ORDER_STATUS_KEY = 'status_order_paid'; + + const API_WEBHOOK_ACTION = 'merchant/clients/%s/webhooks'; + const API_SIMPLE_INVOICE_ACTION = 'invoices'; + const API_MERCHANT_INVOICE_ACTION = 'merchant/invoices'; + + const VALIDATE_SIMPLE_URL = 'coinpayments/validation/invoice'; + const VALIDATE_MERCHANT_URL = 'coinpayments/validation/webhook'; + + const CREATE_INVOICE_URL = 'coinpayments/invoice/create'; + const WEBHOOK_NOTIFICATION_URL = 'coinpayments/webhooks/notification'; + + const API_INVOICE_COMPLETED = 'Completed'; + const API_INVOICE_EXPIRED = 'Expired'; + + /** + * @var Config + */ + protected $resourceConfig; + protected $baseConf; + + /** + * Data constructor. + * + * @param Context $context + * @param Config $resourceConfig + */ + public function __construct(Context $context, + \Magento\Framework\App\Config\ConfigResource\ConfigInterface $resourceConfig) + { + parent::__construct($context); + $this->resourceConfig = $resourceConfig; + $this->baseConf = $this->getBaseConfig(); + } + + /** + * @param $param + * @return mixed + */ + public function getConfig($param) + { + return $this->scopeConfig->getValue(self::XML_PATH_CONFIG_COINPAYMENTS . $param); + } + + /** + * @param $param + * @param $value + * @return mixed + */ + public function setConfig($param, $value) + { + return $this->resourceConfig->saveConfig(self::XML_PATH_CONFIG_COINPAYMENTS . $param, $value); + } + + /** + * @return mixed + */ + public function getBaseConfig() + { + return $this->scopeConfig->getValue('coinpayment/conf'); + } + + /** + * @param $action + * @return string + */ + public function getApiUrl($action) + { + return sprintf('%s/api/v%s/%s', $this->baseConf['api_host'], $this->baseConf['api_version'], $action); + } + + /** + * @return string + */ + public function getWebHookCallbackUrl() + { + return $this->_getUrl(Data::WEBHOOK_NOTIFICATION_URL, ['_direct' => null]); + } + + /** + * @param $coinInvoiceId + * @param $successUrl + * @param $cancelUrl + * @return string + */ + public function getCoinCheckoutRedirectUrl($coinInvoiceId, $successUrl, $cancelUrl) + { + return sprintf( + '%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', + $this->baseConf['api_host'], + $coinInvoiceId, + $successUrl, + $cancelUrl + ); + } +} diff --git a/Model/AbstractApi.php b/Model/AbstractApi.php index 111f423..4184c2c 100644 --- a/Model/AbstractApi.php +++ b/Model/AbstractApi.php @@ -6,29 +6,19 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\HTTP\Client\Curl; use Magento\Sales\Model\Order; +use Coinpayments\CoinPayments\Helper\Data; abstract class AbstractApi { - const FIAT_TYPE = 'fiat'; - - const INVOICE_CACHE_PREFIX = 'CoinpaymentsInvoice'; - /* @var Curl */ protected $curl; - /* @var ScopeConfigInterface */ protected $scopeConfig; - /* @var array */ protected $defaultHeaders = [ 'Content-Type' => 'application/json;' ]; - - /** - * @var mixed - */ - protected $baseConf; /** * @var Order */ @@ -41,9 +31,14 @@ abstract class AbstractApi * @var Order\Payment\Transaction\BuilderInterface */ protected $transactionBuilder; + /** + * @var Data + */ + protected $helper; public function __construct( Curl $curl, + Data $helper, ScopeConfigInterface $scopeConfig, Order $orderModel, Coinpayments $coinPaymentsMethod, @@ -51,11 +46,11 @@ public function __construct( ) { $this->curl = $curl; + $this->helper = $helper; $this->scopeConfig = $scopeConfig; $this->orderModel = $orderModel; $this->coinPaymentsMethod = $coinPaymentsMethod; $this->transactionBuilder = $transactionBuilder; - $this->baseConf = $this->getBaseConfig(); } /** @@ -71,7 +66,7 @@ public function getRequestHeaders($requestParams, $requestData = []) $headerData = [ 'method' => $requestParams['method'], - 'url' => $this->getApiUrl($requestParams['action']), + 'url' => $this->helper->getApiUrl($requestParams['action']), 'clientId' => $requestParams['clientId'], 'timestamp' => $date->format('c'), ]; @@ -104,7 +99,7 @@ public function sendPostRequest($action, $headers, $requestData) $this->curl->setOption(CURLOPT_SSL_VERIFYHOST, 0); $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, 0); - $requestUrl = $this->getApiUrl($action); + $requestUrl = $this->helper->getApiUrl($action); $this->curl->post($requestUrl, json_encode($requestData)); return json_decode($this->curl->getBody(), true); } @@ -126,7 +121,7 @@ public function sendGetRequest($action, $headers, $requestData = []) $this->curl->setOption(CURLOPT_SSL_VERIFYHOST, 0); $this->curl->setOption(CURLOPT_SSL_VERIFYPEER, 0); - $requestUrl = $this->getApiUrl($action); + $requestUrl = $this->helper->getApiUrl($action); if (!empty($requestData)) { $requestUrl .= '?' . http_build_query($requestData); } @@ -135,16 +130,6 @@ public function sendGetRequest($action, $headers, $requestData = []) return json_decode($this->curl->getBody(), true); } - /** - * @param $baseConf - * @param $action - * @return string - */ - public function getApiUrl($action) - { - return sprintf('%s/api/v%s/%s', $this->baseConf['api_host'], $this->baseConf['api_version'], $action); - } - /** * @param $requestData * @param null $secretKey @@ -176,15 +161,6 @@ public function getCurrencies($params = []) return $this->sendGetRequest('currencies', [], $params); } - /** - * @param null $field - * @return mixed - */ - public function getBaseConfig($field = null) - { - return $this->getConfig('coinpayment/conf', $field); - } - /** * @param $base * @param $field diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index ddcf514..7b72c68 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -14,16 +14,12 @@ class CoinPaymentsConfigProvider implements ConfigProviderInterface * @var Repository */ protected $_assetRepo; - /** - * @var string - */ - protected $_methodCode = 'coin_payments'; /** * CoinPaymentsConfigProvider constructor. * @param Repository $assetRepo */ - public function __construct(Curl $curl, ScopeConfigInterface $scopeConfig, Repository $assetRepo) + public function __construct(Repository $assetRepo) { $this->_assetRepo = $assetRepo; } diff --git a/Model/Invoice.php b/Model/Invoice.php index 416030b..6e5810b 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -4,6 +4,7 @@ use Coinpayments\CoinPayments\Api\InvoiceInterface; use Magento\Sales\Model\Order; +use Coinpayments\CoinPayments\Helper\Data; class Invoice extends AbstractApi implements InvoiceInterface { @@ -14,20 +15,22 @@ class Invoice extends AbstractApi implements InvoiceInterface * @param $currencyId * @param $invoiceId * @param $amount + * @param $dispayValue * @return mixed * @throws \Exception */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount) + public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $dispayValue) { $requestData = [ "invoiceId" => $invoiceId, "amount" => [ "currencyId" => $currencyId, + "displayValue" => $dispayValue, "value" => $amount ], ]; - $action = 'merchant/invoices'; + $action = Data::API_MERCHANT_INVOICE_ACTION; $requestParams = [ 'method' => 'POST', @@ -46,18 +49,20 @@ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId * @param int $currencyId * @param string $invoiceId * @param int $amount + * @param string $displayValue * @return mixed */ - public function createSimple($clientId, $currencyId = 1, $invoiceId = 'Validate invoice', $amount = 1) + public function createSimple($clientId, $currencyId = 5057, $invoiceId = 'Validate invoice', $amount = 1, $displayValue = '0.01') { - $action = 'invoices'; + $action = Data::API_SIMPLE_INVOICE_ACTION; $requestParams = [ 'clientId' => $clientId, 'invoiceId' => $invoiceId, 'amount' => [ 'currencyId' => $currencyId, + "displayValue" => $displayValue, 'value' => $amount ] ]; diff --git a/Model/WebHook.php b/Model/WebHook.php index e782424..947c6ec 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -3,6 +3,7 @@ namespace Coinpayments\CoinPayments\Model; use Coinpayments\CoinPayments\Api\WebHookInterface; +use Coinpayments\CoinPayments\Helper\Data; use Magento\Sales\Model\Order; class WebHook extends AbstractApi implements WebHookInterface @@ -18,7 +19,7 @@ class WebHook extends AbstractApi implements WebHookInterface public function createWebHook($clientId, $clientSecret, $webHookCallbackUrl) { - $action = sprintf('merchant/clients/%s/webhooks', $clientId); + $action = sprintf(Data::API_WEBHOOK_ACTION, $clientId); $requestParams = [ 'method' => 'POST', @@ -51,7 +52,7 @@ public function createWebHook($clientId, $clientSecret, $webHookCallbackUrl) public function getList($clientId, $clientSecret) { - $action = sprintf('merchant/clients/%s/webhooks', $clientId); + $action = sprintf(Data::API_WEBHOOK_ACTION, $clientId); $requestParams = [ 'method' => 'GET', 'action' => $action, @@ -91,10 +92,10 @@ public function completeOrder($requestData) $order->setTotalPaid($requestData['invoice']['amount']['displayValue']); $order - ->setState($this->scopeConfig->getValue('payment/coin_payments/status_order_paid')) - ->setStatus($this->scopeConfig->getValue('payment/coin_payments/status_order_paid')); + ->setState($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)) + ->setStatus($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)); - $str = 'CoinPayments.net Payment Status: ' . $requestData['status'] . ' ' . $requestData['status'] . '
    '; + $str = 'CoinPayments.net Payment Status: ' . $requestData['invoice']['status'] . ' ' . $requestData['invoice']['status'] . '
    '; $str .= 'Transaction ID: ' . $requestData['invoice']['invoiceId'] . '
    '; $str .= 'Received Amount: ' . sprintf('%s %s', $requestData['invoice']['amount']['displayValue'], $requestData['invoice']['currency']['symbol']); @@ -139,5 +140,13 @@ public function completeOrder($requestData) return true; } + /** + * @return string + */ + public function getWebHookCallbackUrl() + { + return $this->helper->getWebHookCallbackUrl(); + } + } \ No newline at end of file diff --git a/README.md b/README.md index e69de29..deb6284 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,11 @@ +#install + +Clone source to "app/code/Coinpayments/CoinPayments" directory. + +To enable module run: "bin/magento module:enable Coinpayments_CoinPayments" + +In admin backend on STORES > Configuration > SALES > Payment Methods page enter clientId to send invoices and enable webHooks and enter clientSecret to receive webHook notification. + +On your first saving of configurations you create validating invoice with $ 0.01 cost, or creating webHook notification, if enabled. + +On /checkout/#payment page after placing orders you'll gonna be redirected to coin checkout page. \ No newline at end of file diff --git a/view/adminhtml/templates/js_vars.phtml b/view/adminhtml/templates/js_vars.phtml index e29940d..d876cdc 100644 --- a/view/adminhtml/templates/js_vars.phtml +++ b/view/adminhtml/templates/js_vars.phtml @@ -2,7 +2,7 @@ require([ 'prototype' ], function ($) { - window.coin_validate_invoice = 'getUrl('coinpayments/validation/invoice');?>'; - window.coin_validate_webhooks = 'getUrl('coinpayments/validation/webhook');?>'; + window.coin_validate_invoice = 'getUrl(\Coinpayments\CoinPayments\Helper\Data::VALIDATE_SIMPLE_URL);?>'; + window.coin_validate_webhooks = 'getUrl(\Coinpayments\CoinPayments\Helper\Data::VALIDATE_MERCHANT_URL);?>'; }); \ No newline at end of file diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 213bf9d..5a7494b 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -2,6 +2,12 @@ + + + diff --git a/view/frontend/templates/js_vars.phtml b/view/frontend/templates/js_vars.phtml new file mode 100644 index 0000000..a0ff978 --- /dev/null +++ b/view/frontend/templates/js_vars.phtml @@ -0,0 +1,7 @@ + \ No newline at end of file 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 2e4d0b5..41f9f56 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 @@ -113,7 +113,7 @@ define( type: "POST", dataType: 'json', contentType: "application/json", - url: url.build('coinpayments/invoice/create'), + url: url.build(coin_invoice_create_url), success: function (result) { result = JSON.parse(result); console.log(result) From 3f23da57c033b1af59aafaf351268c5b68985ee3 Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 15 Jan 2020 19:34:20 +0200 Subject: [PATCH 036/107] fix api host --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 834a9db..532e120 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - http://192.168.80.205:18003 + https://orion-api-testnet.starhermit.com 1 From 0feb0914a5029a88eb76469d0a00bdb2e4e64499 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 16 Jan 2020 14:44:13 +0200 Subject: [PATCH 037/107] fix js --- .../frontend/web/js/view/payment/method-renderer/coin-method.js | 2 -- 1 file changed, 2 deletions(-) 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 41f9f56..9104cff 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 @@ -115,8 +115,6 @@ define( contentType: "application/json", url: url.build(coin_invoice_create_url), success: function (result) { - result = JSON.parse(result); - console.log(result) if (result.coinInvoiceId) { window.location.href = result.redirectUrl; } else { From 4f8b269a4d1608ff62a81a4eef410f036ad0369d Mon Sep 17 00:00:00 2001 From: letscode Date: Fri, 31 Jan 2020 15:35:54 +0200 Subject: [PATCH 038/107] Updated invoice binding to order --- Controller/Adminhtml/Validation/WebHook.php | 4 +- Controller/Invoice/Create.php | 10 +- Controller/WebHooks/Notification.php | 11 +- Helper/Data.php | 4 - Model/AbstractApi.php | 22 ++-- Model/Invoice.php | 14 ++- Model/WebHook.php | 121 ++++++++++---------- 7 files changed, 95 insertions(+), 91 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 9f14a2e..454e885 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -35,8 +35,8 @@ public function execute() }, $webHooksList['items']); } - if (!in_array($this->webHookModel->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->webHookModel->getWebHookCallbackUrl()); + if (!in_array($this->helper->getWebHookCallbackUrl(), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->helper->getWebHookCallbackUrl()); if (!empty($webHook)) { $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index d5f5c4c..68397ed 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -41,6 +41,10 @@ class Create extends Action implements CsrfAwareActionInterface * @var Data */ private $helper; + /** + * @var Order\Payment\Transaction\BuilderInterface + */ + protected $transactionBuilder; /** * Create constructor. @@ -98,16 +102,18 @@ public function execute() $clientId = $this->helper->getConfig(Data::CLIENT_ID_KEY); $clientSecret = $this->helper->getConfig(Data::CLIENT_SECRET_KEY); $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); + $invoiceId = sprintf('%s|%s',$order->getIncrementId(), $order->getPayment()->getId()); if ($merchantWebHooks) { - $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $order->getIncrementId(), intval($amount), $order->getGrandTotal()); + $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); } else { - $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $order->getIncrementId(), intval($amount), $order->getGrandTotal()); + $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); } if (!empty($invoiceData['id'])) { $this->checkoutSession->{'set' . $coinInvoiceCacheId}($invoiceData['id']); $coinInvoiceId = $invoiceData['id']; + $this->invoiceModel->createOrderTransaction($order, $coinInvoiceId); } } diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index ad9d637..eb5abff 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -49,22 +49,13 @@ public function __construct( public function execute() { - - if ($this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY)) { - $content = $this->getRequest()->getContent(); $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); - if ($this->checkDataSignature($signature, $content)) { $requestData = json_decode($content, true); - if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { - $this->webHookModel->completeOrder($requestData); - } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_EXPIRED) { - $this->webHookModel->cancelOrder($requestData); - } + $this->webHookModel->receiveNotification($requestData); } - } } diff --git a/Helper/Data.php b/Helper/Data.php index 377fefd..b3ae012 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,8 +1,4 @@ - */ namespace Coinpayments\CoinPayments\Helper; diff --git a/Model/AbstractApi.php b/Model/AbstractApi.php index 4184c2c..cf73a30 100644 --- a/Model/AbstractApi.php +++ b/Model/AbstractApi.php @@ -35,6 +35,10 @@ abstract class AbstractApi * @var Data */ protected $helper; + /** + * @var Order\Payment\Transaction\Repository + */ + protected $transactionRepository; public function __construct( Curl $curl, @@ -42,7 +46,8 @@ public function __construct( ScopeConfigInterface $scopeConfig, Order $orderModel, Coinpayments $coinPaymentsMethod, - Order\Payment\Transaction\BuilderInterface $transactionBuilder + Order\Payment\Transaction\BuilderInterface $transactionBuilder, + Order\Payment\Transaction\Repository $transactionRepository ) { $this->curl = $curl; @@ -51,6 +56,8 @@ public function __construct( $this->orderModel = $orderModel; $this->coinPaymentsMethod = $coinPaymentsMethod; $this->transactionBuilder = $transactionBuilder; + $this->transactionRepository = $transactionRepository; + } /** @@ -160,17 +167,4 @@ public function getCurrencies($params = []) { return $this->sendGetRequest('currencies', [], $params); } - - /** - * @param $base - * @param $field - * @return mixed - */ - protected function getConfig($base, $field = false) - { - if ($field) { - return $this->scopeConfig->getValue($base . DIRECTORY_SEPARATOR . $field); - } - return $this->scopeConfig->getValue($base); - } } diff --git a/Model/Invoice.php b/Model/Invoice.php index 6e5810b..4852605 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -70,5 +70,17 @@ public function createSimple($clientId, $currencyId = 5057, $invoiceId = 'Valida return $this->sendPostRequest($action, [], $requestParams); } - + public function createOrderTransaction($order, $coinInvoiceId) + { + $payment = $order->getPayment(); + /* @var Order\Payment\Transaction\BuilderInterface */ + $transaction = $this->transactionBuilder + ->setPayment($payment) + ->setOrder($order) + ->setTransactionId($coinInvoiceId) + ->setFailSafe(true) + ->build(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE); + $transaction->save(); + return $transaction->getTransactionId(); + } } \ No newline at end of file diff --git a/Model/WebHook.php b/Model/WebHook.php index 947c6ec..fd068d9 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -66,87 +66,92 @@ public function getList($clientId, $clientSecret) } /** - * @param $requestData + * @param Order $order * @throws \Exception */ - public function cancelOrder($requestData) + public function cancelOrder($order) { - $order = $this->orderModel->loadByIncrementId($requestData['invoice']['invoiceId']); - if ($order->getId()) { - $order - ->setStatus(Order::STATE_CANCELED) - ->setState(Order::STATE_CANCELED) - ->save(); - } + $order + ->setStatus(Order::STATE_CANCELED) + ->setState(Order::STATE_CANCELED) + ->save(); } /** - * @param $order * @param $requestData - * @return bool + * @throws \Magento\Framework\Exception\InputException */ - public function completeOrder($requestData) + public function receiveNotification($requestData) { - $order = $this->orderModel->loadByIncrementId($requestData['invoice']['invoiceId']); - if ($order->getId()) { - $order->setTotalPaid($requestData['invoice']['amount']['displayValue']); - $order - ->setState($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)) - ->setStatus($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)); - - $str = 'CoinPayments.net Payment Status: ' . $requestData['invoice']['status'] . ' ' . $requestData['invoice']['status'] . '
    '; + $orderData = explode('|', $requestData['invoice']['invoiceId']); + $orderId = array_shift($orderData); + $paymentId = array_shift($orderData); + + $coinInvoiceId = $requestData['invoice']['id']; + + $transaction = $this->transactionRepository->getByTransactionId( + $coinInvoiceId, + $paymentId, + $orderId + ); + + if (!empty($transaction)) { + /** @var Order $order */ + $order = $transaction->getOrder(); + if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { + $this->completeOrder($requestData['invoice'], $order, $transaction); + } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_EXPIRED) { + $this->cancelOrder($order); + } + } - $str .= 'Transaction ID: ' . $requestData['invoice']['invoiceId'] . '
    '; - $str .= 'Received Amount: ' . sprintf('%s %s', $requestData['invoice']['amount']['displayValue'], $requestData['invoice']['currency']['symbol']); + } - $order->addStatusToHistory($order->getStatus(), $str); + /** + * @param $rawDetails + * @param Order $order + * @param Order\Payment\Transaction $transaction + * @return bool + */ + public function completeOrder($rawDetails, $order, $transaction) + { + $rawDetails['amount'] = $rawDetails['amount']['displayValue']; + $rawDetails['currency'] = $rawDetails['currency']['symbol']; - try { - $payment = $order->getPayment(); - $payment->setMethod($this->coinPaymentsMethod->getCode()); - $payment->setLastTransId($requestData['invoice']['invoiceId']); - $payment->setTransactionId($requestData['invoice']['invoiceId']); - $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$requestData]); - $formatedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal()); + $order->setTotalPaid($rawDetails['amount']); + $order + ->setState($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)) + ->setStatus($this->helper->getConfig(Data::CLIENT_ORDER_STATUS_KEY)); - /* @var Order\Payment\Transaction\BuilderInterface */ - $transaction = $this->transactionBuilder - ->setPayment($payment) - ->setOrder($order) - ->setTransactionId($requestData['invoice']['invoiceId']) - ->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => (array)$requestData]) - ->setFailSafe(true) - ->build(Order\Payment\Transaction::TYPE_CAPTURE); + $str = 'CoinPayments.net Payment Status: ' . $rawDetails['status'] . ' ' . $rawDetails['status'] . '
    '; + $str .= 'Transaction ID: ' . $rawDetails['id'] . '
    '; + $str .= 'Received Amount: ' . sprintf('%s %s', $rawDetails['amount'], $rawDetails['currency']); + $order->addStatusToHistory($order->getStatus(), $str); - // Add transaction to payment - $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); - $payment->setParentTransactionId(null); - // Save payment, transaction and order - $payment->save(); - $order->save(); - $transaction->save(); - return $transaction->getTransactionId(); + $transaction->setAdditionalInformation(Order\Payment\Transaction::RAW_DETAILS, $rawDetails); - } catch (\Exception $e) { + try { + $formatedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal()); - } + $payment = $order->getPayment(); + $payment->setMethod($this->coinPaymentsMethod->getCode()); + $payment->setLastTransId($transaction->getId()); + $payment->setTransactionId($transaction->getTransactionId()); + $payment->setAdditionalInformation([Order\Payment\Transaction::RAW_DETAILS => $rawDetails]); + $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); + $payment->setParentTransactionId(null); + $payment->save(); + $order->save(); + $transaction->save(); + return $transaction->getTransactionId(); + } catch (\Exception $e) { } - return true; } - /** - * @return string - */ - public function getWebHookCallbackUrl() - { - return $this->helper->getWebHookCallbackUrl(); - } - - } \ No newline at end of file From 4aedeec5153e924c929f08b990827c5dce2de3fd Mon Sep 17 00:00:00 2001 From: letscode Date: Sat, 1 Feb 2020 19:13:18 +0200 Subject: [PATCH 039/107] Fix typo --- Model/Invoice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Model/Invoice.php b/Model/Invoice.php index 4852605..a706539 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -15,17 +15,17 @@ class Invoice extends AbstractApi implements InvoiceInterface * @param $currencyId * @param $invoiceId * @param $amount - * @param $dispayValue + * @param $displayValue * @return mixed * @throws \Exception */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $dispayValue) + public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $displayValue) { $requestData = [ "invoiceId" => $invoiceId, "amount" => [ "currencyId" => $currencyId, - "displayValue" => $dispayValue, + "displayValue" => $displayValue, "value" => $amount ], ]; From 8f980491cd6089f669b4a967c63435093246effc Mon Sep 17 00:00:00 2001 From: letscode Date: Sat, 1 Feb 2020 19:28:22 +0200 Subject: [PATCH 040/107] Fix typo --- Controller/Adminhtml/Validation/Invoice.php | 2 +- Controller/Adminhtml/Validation/WebHook.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/Adminhtml/Validation/Invoice.php b/Controller/Adminhtml/Validation/Invoice.php index 09d5e29..45e47b5 100644 --- a/Controller/Adminhtml/Validation/Invoice.php +++ b/Controller/Adminhtml/Validation/Invoice.php @@ -38,7 +38,7 @@ public function execute() } else { $response = [ 'success' => false, - 'errorText' => sprintf('Enter Coinpaymnets.NET credentials!'), + 'errorText' => sprintf('Enter Coinpayments.NET credentials!'), ]; } diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 454e885..eb6221e 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -67,7 +67,7 @@ public function execute() } else { $response = [ 'success' => false, - 'errorText' => sprintf('Enter Coinpaymnets.NET credentials!'), + 'errorText' => sprintf('Enter Coinpayments.NET credentials!'), ]; } From d91bc3b5ebfc3f234ce8225f4ea782512eb612e2 Mon Sep 17 00:00:00 2001 From: letscode Date: Sun, 2 Feb 2020 02:40:40 +0200 Subject: [PATCH 041/107] Fix docs --- Controller/Adminhtml/Validation/Invoice.php | 3 -- .../Adminhtml/Validation/Validation.php | 3 +- Controller/Checkout/Failure.php | 7 ++++ Controller/Invoice/Create.php | 10 ++---- Controller/WebHooks/Notification.php | 2 +- Helper/Data.php | 9 +++-- Model/AbstractApi.php | 26 +++++++++++--- Model/CoinPaymentsConfigProvider.php | 7 ++-- Model/Invoice.php | 29 ++++++++++------ Model/Methods/Coinpayments.php | 15 ++++---- Model/WebHook.php | 34 +++++++++++-------- 11 files changed, 89 insertions(+), 56 deletions(-) diff --git a/Controller/Adminhtml/Validation/Invoice.php b/Controller/Adminhtml/Validation/Invoice.php index 45e47b5..aa2d7d2 100644 --- a/Controller/Adminhtml/Validation/Invoice.php +++ b/Controller/Adminhtml/Validation/Invoice.php @@ -2,9 +2,6 @@ namespace Coinpayments\CoinPayments\Controller\Adminhtml\Validation; -use Magento\Backend\App\Action; -use Magento\Backend\App\Action\Context; - /** * Class Invoice * @package Coinpayments\CoinPayments\Controller\Adminhtml\Validation diff --git a/Controller/Adminhtml/Validation/Validation.php b/Controller/Adminhtml/Validation/Validation.php index eed92a5..367c09d 100644 --- a/Controller/Adminhtml/Validation/Validation.php +++ b/Controller/Adminhtml/Validation/Validation.php @@ -5,7 +5,6 @@ use Coinpayments\CoinPayments\Helper\Data; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; -use Magento\Framework\Url; use Magento\Framework\Controller\Result\JsonFactory; use Coinpayments\CoinPayments\Model\WebHook; use Coinpayments\CoinPayments\Model\Invoice; @@ -36,7 +35,7 @@ class Validation extends Action protected $helper; /** - * Authenticate constructor. + * Validation constructor. * @param Context $context * @param JsonFactory $jsonResultFactory * @param WebHook $webHook diff --git a/Controller/Checkout/Failure.php b/Controller/Checkout/Failure.php index bcefdb5..83197be 100644 --- a/Controller/Checkout/Failure.php +++ b/Controller/Checkout/Failure.php @@ -24,6 +24,13 @@ class Failure extends Action */ protected $resultPageFactory; + /** + * Failure constructor. + * @param Session $checkoutSession + * @param OrderRepository $orderRepository + * @param Context $context + * @param PageFactory $resultPageFactory + */ public function __construct( Session $checkoutSession, OrderRepository $orderRepository, diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 68397ed..60a2d0d 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -40,11 +40,7 @@ class Create extends Action implements CsrfAwareActionInterface /** * @var Data */ - private $helper; - /** - * @var Order\Payment\Transaction\BuilderInterface - */ - protected $transactionBuilder; + protected $helper; /** * Create constructor. @@ -60,7 +56,7 @@ public function __construct( Context $context, Invoice $invoice, Data $helper, - \Magento\Checkout\Model\Session $checkoutSession, + Session $checkoutSession, ScopeConfigInterface $scopeConfig, Url $urlBuilder, JsonFactory $jsonResultFactory @@ -102,7 +98,7 @@ public function execute() $clientId = $this->helper->getConfig(Data::CLIENT_ID_KEY); $clientSecret = $this->helper->getConfig(Data::CLIENT_SECRET_KEY); $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); - $invoiceId = sprintf('%s|%s',$order->getIncrementId(), $order->getPayment()->getId()); + $invoiceId = sprintf('%s|%s', $order->getId(), $order->getPayment()->getId()); if ($merchantWebHooks) { $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index eb5abff..c84fa29 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -49,7 +49,7 @@ public function __construct( public function execute() { - if ($this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY)) { + if (!empty($this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY)) && !empty($this->getRequest()->getHeaders()->get('X-CoinPayments-Signature'))) { $content = $this->getRequest()->getContent(); $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); if ($this->checkDataSignature($signature, $content)) { diff --git a/Helper/Data.php b/Helper/Data.php index b3ae012..638927b 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -2,12 +2,15 @@ namespace Coinpayments\CoinPayments\Helper; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; -use Magento\Store\Model\ScopeInterface; use Magento\Config\Model\ResourceModel\Config; +use Magento\Framework\App\Config\ConfigResource\ConfigInterface; +/** + * Class Data + * @package Coinpayments\CoinPayments\Helper + */ class Data extends AbstractHelper { @@ -48,7 +51,7 @@ class Data extends AbstractHelper * @param Config $resourceConfig */ public function __construct(Context $context, - \Magento\Framework\App\Config\ConfigResource\ConfigInterface $resourceConfig) + ConfigInterface $resourceConfig) { parent::__construct($context); $this->resourceConfig = $resourceConfig; diff --git a/Model/AbstractApi.php b/Model/AbstractApi.php index cf73a30..3005fb2 100644 --- a/Model/AbstractApi.php +++ b/Model/AbstractApi.php @@ -3,11 +3,17 @@ namespace Coinpayments\CoinPayments\Model; use Coinpayments\CoinPayments\Model\Methods\Coinpayments; +use Coinpayments\CoinPayments\Helper\Data; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\HTTP\Client\Curl; use Magento\Sales\Model\Order; -use Coinpayments\CoinPayments\Helper\Data; +use Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface; +use Magento\Sales\Model\Order\Payment\Transaction\Repository; +/** + * Class AbstractApi + * @package Coinpayments\CoinPayments\Model + */ abstract class AbstractApi { @@ -28,7 +34,7 @@ abstract class AbstractApi */ protected $coinPaymentsMethod; /** - * @var Order\Payment\Transaction\BuilderInterface + * @var BuilderInterface */ protected $transactionBuilder; /** @@ -36,18 +42,28 @@ abstract class AbstractApi */ protected $helper; /** - * @var Order\Payment\Transaction\Repository + * @var Repository */ protected $transactionRepository; + /** + * AbstractApi constructor. + * @param Curl $curl + * @param Data $helper + * @param ScopeConfigInterface $scopeConfig + * @param Order $orderModel + * @param Coinpayments $coinPaymentsMethod + * @param BuilderInterface $transactionBuilder + * @param Repository $transactionRepository + */ public function __construct( Curl $curl, Data $helper, ScopeConfigInterface $scopeConfig, Order $orderModel, Coinpayments $coinPaymentsMethod, - Order\Payment\Transaction\BuilderInterface $transactionBuilder, - Order\Payment\Transaction\Repository $transactionRepository + BuilderInterface $transactionBuilder, + Repository $transactionRepository ) { $this->curl = $curl; diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 7b72c68..e3481c6 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -3,11 +3,12 @@ namespace Coinpayments\CoinPayments\Model; use Magento\Checkout\Model\ConfigProviderInterface; -use Magento\Framework\HTTP\Client\Curl; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\View\Asset\Repository; - +/** + * Class CoinPaymentsConfigProvider + * @package Coinpayments\CoinPayments\Model + */ class CoinPaymentsConfigProvider implements ConfigProviderInterface { /** diff --git a/Model/Invoice.php b/Model/Invoice.php index a706539..eef17d1 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -3,9 +3,13 @@ namespace Coinpayments\CoinPayments\Model; use Coinpayments\CoinPayments\Api\InvoiceInterface; -use Magento\Sales\Model\Order; use Coinpayments\CoinPayments\Helper\Data; +use Magento\Sales\Model\Order; +/** + * Class Invoice + * @package Coinpayments\CoinPayments\Model + */ class Invoice extends AbstractApi implements InvoiceInterface { @@ -21,14 +25,6 @@ class Invoice extends AbstractApi implements InvoiceInterface */ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $displayValue) { - $requestData = [ - "invoiceId" => $invoiceId, - "amount" => [ - "currencyId" => $currencyId, - "displayValue" => $displayValue, - "value" => $amount - ], - ]; $action = Data::API_MERCHANT_INVOICE_ACTION; @@ -39,8 +35,16 @@ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId 'clientSecret' => $clientSecret, ]; - $headers = $this->getRequestHeaders($requestParams, $requestData); + $requestData = [ + "invoiceId" => $invoiceId, + "amount" => [ + "currencyId" => $currencyId, + "displayValue" => $displayValue, + "value" => $amount + ], + ]; + $headers = $this->getRequestHeaders($requestParams, $requestData); return $this->sendPostRequest($action, $headers, $requestData); } @@ -70,6 +74,11 @@ public function createSimple($clientId, $currencyId = 5057, $invoiceId = 'Valida return $this->sendPostRequest($action, [], $requestParams); } + /** + * @param $order + * @param $coinInvoiceId + * @return int + */ public function createOrderTransaction($order, $coinInvoiceId) { $payment = $order->getPayment(); diff --git a/Model/Methods/Coinpayments.php b/Model/Methods/Coinpayments.php index 6513256..8a131d5 100644 --- a/Model/Methods/Coinpayments.php +++ b/Model/Methods/Coinpayments.php @@ -6,15 +6,13 @@ namespace Coinpayments\CoinPayments\Model\Methods; -use Magento\Framework\Pricing\PriceCurrencyInterface; -use Magento\Framework\HTTP\ZendClientFactory; -use Magento\Payment\Model\Method\ConfigInterface; -use Magento\Payment\Model\Method\TransparentInterface; -use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Quote\Api\Data\CartInterface; use Magento\Payment\Model\Method\AbstractMethod; -use Magento\Sales\Model\Order; +/** + * Class Coinpayments + * @package Coinpayments\CoinPayments\Model\Methods + */ class Coinpayments extends AbstractMethod { @@ -32,7 +30,7 @@ class Coinpayments extends AbstractMethod * @param CartInterface|null $quote * @return bool */ - public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) + public function isAvailable(CartInterface $quote = null) { return parent::isAvailable($quote); } @@ -46,6 +44,9 @@ public function isActive($storeId = null) return (bool)(int)$this->getConfigData('active', $storeId); } + /** + * @return string + */ public function getCode() { return $this->_code; diff --git a/Model/WebHook.php b/Model/WebHook.php index fd068d9..23219dd 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -6,6 +6,10 @@ use Coinpayments\CoinPayments\Helper\Data; use Magento\Sales\Model\Order; +/** + * Class WebHook + * @package Coinpayments\CoinPayments\Model + */ class WebHook extends AbstractApi implements WebHookInterface { @@ -53,6 +57,7 @@ public function getList($clientId, $clientSecret) { $action = sprintf(Data::API_WEBHOOK_ACTION, $clientId); + $requestParams = [ 'method' => 'GET', 'action' => $action, @@ -61,22 +66,9 @@ public function getList($clientId, $clientSecret) ]; $headers = $this->getRequestHeaders($requestParams); - return $this->sendGetRequest($action, $headers); } - /** - * @param Order $order - * @throws \Exception - */ - public function cancelOrder($order) - { - $order - ->setStatus(Order::STATE_CANCELED) - ->setState(Order::STATE_CANCELED) - ->save(); - } - /** * @param $requestData * @throws \Magento\Framework\Exception\InputException @@ -110,8 +102,8 @@ public function receiveNotification($requestData) /** * @param $rawDetails - * @param Order $order - * @param Order\Payment\Transaction $transaction + * @param $order + * @param $transaction * @return bool */ public function completeOrder($rawDetails, $order, $transaction) @@ -154,4 +146,16 @@ public function completeOrder($rawDetails, $order, $transaction) return true; } + /** + * @param Order $order + * @throws \Exception + */ + public function cancelOrder($order) + { + $order + ->setStatus(Order::STATE_CANCELED) + ->setState(Order::STATE_CANCELED) + ->save(); + } + } \ No newline at end of file From 5a586261e13535dcc6b85c1ef9056985f0da5d26 Mon Sep 17 00:00:00 2001 From: letscode Date: Sun, 2 Feb 2020 03:26:38 +0200 Subject: [PATCH 042/107] Fix var names --- Controller/Adminhtml/Validation/WebHook.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index eb6221e..13825a6 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -21,10 +21,10 @@ public function execute() if (!empty($params['client_id']) && !empty($params['client_secret']) && $this->helper->getConfig('validated') != ($params['client_id'] . $params['client_secret'])) { - $client_id = $params['client_id']; - $client_secret = $params['client_secret']; + $clientId = $params['client_id']; + $clientSecret = $params['client_secret']; - $webHooksList = $this->webHookModel->getList($client_id, $client_secret); + $webHooksList = $this->webHookModel->getList($clientId, $clientSecret); if (!empty($webHooksList)) { @@ -36,7 +36,7 @@ public function execute() } if (!in_array($this->helper->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($client_id, $client_secret, $this->helper->getWebHookCallbackUrl()); + $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getWebHookCallbackUrl()); if (!empty($webHook)) { $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ From 9e145c96c88a60b7aeeada60da98b52cab82dc66 Mon Sep 17 00:00:00 2001 From: letscode Date: Sun, 2 Feb 2020 16:35:09 +0200 Subject: [PATCH 043/107] Fix API host --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 532e120..a853d22 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - https://orion-api-testnet.starhermit.com + https://orion-api.starhermit.com 1 From c5a954aa61339f63c7d1a46388ae73e6b7ab1aed Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 4 Feb 2020 11:02:26 +0200 Subject: [PATCH 044/107] Fix abstract access --- Controller/Adminhtml/Validation/Validation.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Controller/Adminhtml/Validation/Validation.php b/Controller/Adminhtml/Validation/Validation.php index 367c09d..c12ed22 100644 --- a/Controller/Adminhtml/Validation/Validation.php +++ b/Controller/Adminhtml/Validation/Validation.php @@ -13,7 +13,7 @@ * Class Validation * @package Coinpayments\CoinPayments\Controller\Adminhtml\Validation */ -class Validation extends Action +abstract class Validation extends Action { /** * @var JsonFactory @@ -57,8 +57,5 @@ public function __construct( $this->helper = $helper; } - public function execute() - { - - } + abstract public function execute(); } \ No newline at end of file From 8e23f87ecbd7d36afc9a47a1eeb4aa9279a2a605 Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 4 Feb 2020 11:04:11 +0200 Subject: [PATCH 045/107] Fix webhook validation conditions --- Controller/Adminhtml/Validation/WebHook.php | 60 +++++++++++---------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 13825a6..7813985 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -19,52 +19,54 @@ public function execute() $params = $this->getRequest()->getParams(); $response = []; - if (!empty($params['client_id']) && !empty($params['client_secret']) && $this->helper->getConfig('validated') != ($params['client_id'] . $params['client_secret'])) { + if (!empty($params['client_id']) && !empty($params['client_secret'])) { + if ($this->helper->getConfig('validated') != ($params['client_id'] . $params['client_secret'])) { - $clientId = $params['client_id']; - $clientSecret = $params['client_secret']; + $clientId = $params['client_id']; + $clientSecret = $params['client_secret']; - $webHooksList = $this->webHookModel->getList($clientId, $clientSecret); + $webHooksList = $this->webHookModel->getList($clientId, $clientSecret); - if (!empty($webHooksList)) { + if (!empty($webHooksList)) { - $webHooksUrlsList = []; - if (!empty($webHooksList['items'])) { - $webHooksUrlsList = array_map(function ($webHook) { - return $webHook['notificationsUrl']; - }, $webHooksList['items']); - } + $webHooksUrlsList = []; + if (!empty($webHooksList['items'])) { + $webHooksUrlsList = array_map(function ($webHook) { + return $webHook['notificationsUrl']; + }, $webHooksList['items']); + } - if (!in_array($this->helper->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getWebHookCallbackUrl()); - if (!empty($webHook)) { - $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); - $response = [ - 'success' => $webHook, - ]; + if (!in_array($this->helper->getWebHookCallbackUrl(), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getWebHookCallbackUrl()); + if (!empty($webHook)) { + $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); + $response = [ + 'success' => $webHook, + ]; + } else { + $response = [ + 'success' => false, + 'errorText' => sprintf('Failed to create WebHook!'), + ]; + } } else { + $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ - 'success' => false, - 'errorText' => sprintf('Failed to create WebHook!'), + 'success' => true, ]; } } else { - $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ - 'success' => true, + 'success' => false, + 'errorText' => sprintf('Failed to get WebHooks list!'), ]; } } else { $response = [ - 'success' => false, - 'errorText' => sprintf('Failed to get WebHooks list!'), + 'success' => true, ]; } - } elseif ($this->helper->getConfig('validated') == ($params['client_id'] . $params['client_secret'])) { - $response = [ - 'success' => true, - ]; - } else { + }else { $response = [ 'success' => false, 'errorText' => sprintf('Enter Coinpayments.NET credentials!'), From 4ea9b25b190316164b3d4fdfcb90ef261599c992 Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 4 Feb 2020 11:39:26 +0200 Subject: [PATCH 046/107] Update readme --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index deb6284..2b68b42 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,20 @@ -#install +# Coinpayments_CoinPayments Module -Clone source to "app/code/Coinpayments/CoinPayments" directory. +The Coinpayments_CoinPayments module provides the "Coinpayments.NET" payment method. -To enable module run: "bin/magento module:enable Coinpayments_CoinPayments" +## About CoinPayments Module -In admin backend on STORES > Configuration > SALES > Payment Methods page enter clientId to send invoices and enable webHooks and enter clientSecret to receive webHook notification. +CoinPayments module provides integration of your Magento 2 store with Coinpaymnets.NET services. This helps your customers shop quickly, safely and securely. +Your customers can pay on your website without re-entering their payment and address details. +All CoinPayments module transactions are protected. -On your first saving of configurations you create validating invoice with $ 0.01 cost, or creating webHook notification, if enabled. +## Dependencies -On /checkout/#payment page after placing orders you'll gonna be redirected to coin checkout page. \ No newline at end of file +You can find a list of modules in the require section of the `composer.json` file located in the +same directory as this `README.md` file. + +## Extension Points + +There are no extension points or service contracts for this module. + +## Additional Information \ No newline at end of file From ec60076c267b93a7fc9500dcdef9b3b8f562e345 Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 11 Feb 2020 11:31:23 +0200 Subject: [PATCH 047/107] Update transaction status --- Helper/Data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index 638927b..796cc05 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -36,7 +36,7 @@ class Data extends AbstractHelper const WEBHOOK_NOTIFICATION_URL = 'coinpayments/webhooks/notification'; const API_INVOICE_COMPLETED = 'Completed'; - const API_INVOICE_EXPIRED = 'Expired'; + const API_INVOICE_EXPIRED = 'Cancelled'; /** * @var Config From 097ad4a13cd67064f65e5765aef78086730e135a Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 13 Feb 2020 11:33:51 +0200 Subject: [PATCH 048/107] Fix invoices statuses --- Helper/Data.php | 2 +- Model/WebHook.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 796cc05..5463e03 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -36,7 +36,7 @@ class Data extends AbstractHelper const WEBHOOK_NOTIFICATION_URL = 'coinpayments/webhooks/notification'; const API_INVOICE_COMPLETED = 'Completed'; - const API_INVOICE_EXPIRED = 'Cancelled'; + const API_INVOICE_CANCELLED = 'Cancelled'; /** * @var Config diff --git a/Model/WebHook.php b/Model/WebHook.php index 23219dd..f7a0413 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -36,10 +36,10 @@ public function createWebHook($clientId, $clientSecret, $webHookCallbackUrl) "notificationsUrl" => $webHookCallbackUrl, "notifications" => [ "invoiceCreated", - "invoicePaymentsReceived", - "invoicePaymentsConfirmed", + "invoicePending", + "invoicePaid", "invoiceCompleted", - "invoiceExpired", + "invoiceCancelled", ], ]; @@ -93,7 +93,7 @@ public function receiveNotification($requestData) $order = $transaction->getOrder(); if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { $this->completeOrder($requestData['invoice'], $order, $transaction); - } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_EXPIRED) { + } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_CANCELLED) { $this->cancelOrder($order); } } From e7c06a188552ab68eaef26dabafb28cc698b85c4 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 13 Feb 2020 11:35:40 +0200 Subject: [PATCH 049/107] Add invoice metadata --- Controller/Adminhtml/Validation/WebHook.php | 4 ++-- Helper/Data.php | 19 +++++++++++++++++-- Model/Invoice.php | 19 ++++++++++++++++--- etc/config.xml | 1 + 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 7813985..9b9bac9 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -36,8 +36,8 @@ public function execute() }, $webHooksList['items']); } - if (!in_array($this->helper->getWebHookCallbackUrl(), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getWebHookCallbackUrl()); + if (!in_array($this->helper->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL), $webHooksUrlsList)) { + $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL)); if (!empty($webHook)) { $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ diff --git a/Helper/Data.php b/Helper/Data.php index 5463e03..eaae446 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -24,6 +24,7 @@ class Data extends AbstractHelper const CLIENT_SECRET_KEY = 'client_secret'; const CLIENT_WEBHOOKS_KEY = 'webhooks'; const CLIENT_ORDER_STATUS_KEY = 'status_order_paid'; + const PACKAGE_VERSION = 'package_version'; const API_WEBHOOK_ACTION = 'merchant/clients/%s/webhooks'; const API_SIMPLE_INVOICE_ACTION = 'invoices'; @@ -95,11 +96,25 @@ public function getApiUrl($action) } /** + * @param $param + * @return mixed + */ + public function getBaseConfigParam($param) + { + $value = null; + if (isset($this->baseConf[$param])) { + $value = $this->baseConf[$param]; + } + return $value; + } + + /** + * @param string $route * @return string */ - public function getWebHookCallbackUrl() + public function getHostUrl($route = '') { - return $this->_getUrl(Data::WEBHOOK_NOTIFICATION_URL, ['_direct' => null]); + return $this->_getUrl($route, ['_direct' => null]); } /** diff --git a/Model/Invoice.php b/Model/Invoice.php index eef17d1..b2a06b6 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -44,6 +44,7 @@ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId ], ]; + $requestData = $this->appendInvoiceMetadata($requestData); $headers = $this->getRequestHeaders($requestParams, $requestData); return $this->sendPostRequest($action, $headers, $requestData); } @@ -61,17 +62,18 @@ public function createSimple($clientId, $currencyId = 5057, $invoiceId = 'Valida $action = Data::API_SIMPLE_INVOICE_ACTION; - $requestParams = [ + $requestData = [ 'clientId' => $clientId, 'invoiceId' => $invoiceId, 'amount' => [ 'currencyId' => $currencyId, "displayValue" => $displayValue, 'value' => $amount - ] + ], ]; - return $this->sendPostRequest($action, [], $requestParams); + $requestData = $this->appendInvoiceMetadata($requestData); + return $this->sendPostRequest($action, [], $requestData); } /** @@ -92,4 +94,15 @@ public function createOrderTransaction($order, $coinInvoiceId) $transaction->save(); return $transaction->getTransactionId(); } + + protected function appendInvoiceMetadata($requestData) + { + + $requestData['metadata'] = [ + "integration" => sprintf("Magento_v%s", $this->helper->getBaseConfigParam(Data::PACKAGE_VERSION)), + "hostname" => $this->helper->getHostUrl(), + ]; + + return $requestData; + } } \ No newline at end of file diff --git a/etc/config.xml b/etc/config.xml index a853d22..4908558 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -15,6 +15,7 @@ https://orion-api.starhermit.com 1 + 2.0.0 From e3516baf27ae3bc0835bb563dd7a3614965041c9 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 13 Feb 2020 11:36:29 +0200 Subject: [PATCH 050/107] Format module code --- Controller/Adminhtml/Validation/WebHook.php | 2 +- etc/adminhtml/routes.xml | 3 ++- etc/di.xml | 7 ++++--- etc/frontend/routes.xml | 5 +++-- etc/module.xml | 17 +++++++++-------- .../layout/adminhtml_system_config_edit.xml | 3 ++- .../layout/coinpayments_checkout_failure.xml | 6 ++++-- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 9b9bac9..5a179fd 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -66,7 +66,7 @@ public function execute() 'success' => true, ]; } - }else { + } else { $response = [ 'success' => false, 'errorText' => sprintf('Enter Coinpayments.NET credentials!'), diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 32b7201..bff2f1a 100644 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -1,5 +1,6 @@ - + diff --git a/etc/di.xml b/etc/di.xml index 0444908..2b0a1b9 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,5 +1,6 @@ - - + + \ No newline at end of file diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index b040362..e4e6805 100644 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,8 +1,9 @@ - + - + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index 75bebe6..70b380d 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,12 +1,13 @@ - - + + - - - - - - + + + + + + \ No newline at end of file diff --git a/view/adminhtml/layout/adminhtml_system_config_edit.xml b/view/adminhtml/layout/adminhtml_system_config_edit.xml index 0741871..af483a5 100644 --- a/view/adminhtml/layout/adminhtml_system_config_edit.xml +++ b/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -8,7 +8,8 @@ - +
    diff --git a/view/frontend/layout/coinpayments_checkout_failure.xml b/view/frontend/layout/coinpayments_checkout_failure.xml index 71e3b5b..7831f24 100644 --- a/view/frontend/layout/coinpayments_checkout_failure.xml +++ b/view/frontend/layout/coinpayments_checkout_failure.xml @@ -5,7 +5,8 @@ * See COPYING.txt for license details. */ --> - + @@ -13,7 +14,8 @@ - + From eda27217f740de85274f0ea6c9c96f1f6cfd3c08 Mon Sep 17 00:00:00 2001 From: Albert Meyburgh Date: Fri, 24 Apr 2020 14:47:05 +0300 Subject: [PATCH 051/107] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b68b42..a01c083 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ +IMPORTANT NOTE: + +This is only for use with: https://alpha.coinpayments.net/ + +NOT for use with https://coinpayments.net + +Demonstration Website Disclaimer: The information presented on alpha.coinpayments.net (the "Demo Site") is for demonstration purposes only. All content on the Demo Site is considered “in development” and should be used at your own risk. CoinPayments Inc. assumes no responsibility or liability for any errors or omissions in the content of the Demo Site. The information contained in the Demo Site is provided on an "as is" basis with no guarantees of completeness, accuracy, usefulness or timeliness and without any warranties of any kind whatsoever, express or implied. CoinPayments Inc. does not warrant that the Demo Site and any information or material downloaded from the Demo Site, will be uninterrupted, error-free, omission-free or free of viruses or other harmful items. + +In no event will CoinPayments Inc. or its directors, officers, employees, shareholders, service providers or agents, be liable to you, or anyone else, for any decision(s) made or action(s) taken in reliance upon the information contained in the Demo Site, nor for any direct, indirect, incidental, special, exemplary, punitive, consequential, or other damages whatsoever (including, but not limited to, liability for loss of use, funds, data or profits) whether in an action of contract, statute, tort or otherwise, relating to the use of the Demo Site." + # Coinpayments_CoinPayments Module The Coinpayments_CoinPayments module provides the "Coinpayments.NET" payment method. @@ -17,4 +27,4 @@ same directory as this `README.md` file. There are no extension points or service contracts for this module. -## Additional Information \ No newline at end of file +## Additional Information From e06797d189a9857fbcb724ffc798dd183c8c2420 Mon Sep 17 00:00:00 2001 From: dima Date: Tue, 30 Jun 2020 16:26:34 +0300 Subject: [PATCH 052/107] update logo --- Model/CoinPaymentsConfigProvider.php | 2 +- view/frontend/web/images/logo.svg | 75 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 view/frontend/web/images/logo.svg diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index fd0789e..fa4022a 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -90,7 +90,7 @@ public function getConfig() 'coinpayments' => [ 'available_currencies' => $currencies, 'accepted_currencies' => $acceptedCurrencies, - 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), + 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.svg'), 'direct_mode' => (int)$isDirect, 'url' => $coinpaymentsDomain, 'api_url' => $coinpaymentsApi diff --git a/view/frontend/web/images/logo.svg b/view/frontend/web/images/logo.svg new file mode 100644 index 0000000..d8b21d9 --- /dev/null +++ b/view/frontend/web/images/logo.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + Black_Make_Easy_CoinPayments_Updated_logo_2 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 6efd31a226891e38970ee3e4187cef8e7f8d6d4f Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 14 Jul 2020 04:25:25 +0300 Subject: [PATCH 053/107] Fix merchant invoice response --- Controller/Invoice/Create.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 60a2d0d..68fdff2 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -101,7 +101,8 @@ public function execute() $invoiceId = sprintf('%s|%s', $order->getId(), $order->getPayment()->getId()); if ($merchantWebHooks) { - $invoiceData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); + $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); + $invoiceData = array_shift($invoicesData); } else { $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); } From 2bc2b71da501afd3ca1db9fbe622a6fd44111eb4 Mon Sep 17 00:00:00 2001 From: letscode Date: Sun, 9 Aug 2020 00:35:38 +0300 Subject: [PATCH 054/107] fix api host --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 4908558..789364f 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - https://orion-api.starhermit.com + https://alpha-api.coinpayments.net 1 2.0.0 From d9989ad8b06fced6cc496a7016779908728b512b Mon Sep 17 00:00:00 2001 From: letscode Date: Fri, 25 Sep 2020 10:30:05 +0300 Subject: [PATCH 055/107] update api domain --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index 789364f..bfc8a83 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - https://alpha-api.coinpayments.net + https://api.coinpayments.net 1 2.0.0 From 883e0a2c924cf6628d1fa5cbc7b2802ff892fa27 Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 28 Sep 2020 22:43:03 +0300 Subject: [PATCH 056/107] Unify the naming of configuration fields --- etc/adminhtml/system.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index e59e408..58f0925 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -25,7 +25,7 @@ - + required-entry validate-length minimum-length-22 maximum-length-32 coin-invoice-validate @@ -45,7 +45,7 @@ - + required-entry validate-length minimum-length-22 maximum-length-44 coin-webhooks-validate From 9f02b6374476ef01c3edad28d9fe247d293ddb14 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Oct 2020 18:21:42 -0400 Subject: [PATCH 057/107] Bugfix --- Model/CoinPaymentsConfigProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index fd0789e..c6f4f20 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -60,7 +60,7 @@ public function getConfig() 'version' => 1, 'cmd' => 'rates', 'key' => $publicKey, - 'accepted' => 1, + 'accepted' => 2, ]; $this->_curl->addHeader('HMAC', hash_hmac('sha512', http_build_query($data), $secretKey)); @@ -69,6 +69,7 @@ public function getConfig() $response = json_decode($this->_curl->getBody()); $currencies = ['error' => $response->error]; + $acceptedCurrencies = ['error' => $response->error]; if ($response->error == 'ok') { $currencies = []; $acceptedCurrencies = []; From e1137661217b6c97d280552a84e4e7944050286b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Oct 2020 18:24:21 -0400 Subject: [PATCH 058/107] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 153fadd..4c3ba09 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.5.0|~5.6.0|~7.0.0|~7.1" }, "type": "magento2-module", - "version": "1.5.0", + "version": "1.6.0", "license": [ "OSL-3.0" ], From 4a6611668865376bbececc8de9aba1d558c91c40 Mon Sep 17 00:00:00 2001 From: USS-Worker Date: Fri, 23 Oct 2020 00:27:18 -0700 Subject: [PATCH 059/107] Changing api-url on checkout - url --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index bfc8a83..aef307e 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -13,7 +13,7 @@ - https://api.coinpayments.net + https://checkout.coinpayments.net 1 2.0.0 From 7ff3dde276373dd24b40577d6a8c1f5cadbebafd Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 9 Nov 2020 21:26:12 +0200 Subject: [PATCH 060/107] Add hostname check to webhooks notifications --- Controller/Invoice/Create.php | 2 +- Model/WebHook.php | 39 ++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 68fdff2..a372b06 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -98,7 +98,7 @@ public function execute() $clientId = $this->helper->getConfig(Data::CLIENT_ID_KEY); $clientSecret = $this->helper->getConfig(Data::CLIENT_SECRET_KEY); $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); - $invoiceId = sprintf('%s|%s', $order->getId(), $order->getPayment()->getId()); + $invoiceId = sprintf('%s|%s|%s', md5($this->helper->getHostUrl()), $order->getId(), $order->getPayment()->getId()); if ($merchantWebHooks) { $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); diff --git a/Model/WebHook.php b/Model/WebHook.php index f7a0413..a12640e 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -77,24 +77,25 @@ public function receiveNotification($requestData) { $orderData = explode('|', $requestData['invoice']['invoiceId']); - $orderId = array_shift($orderData); - $paymentId = array_shift($orderData); - - $coinInvoiceId = $requestData['invoice']['id']; - - $transaction = $this->transactionRepository->getByTransactionId( - $coinInvoiceId, - $paymentId, - $orderId - ); - - if (!empty($transaction)) { - /** @var Order $order */ - $order = $transaction->getOrder(); - if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { - $this->completeOrder($requestData['invoice'], $order, $transaction); - } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_CANCELLED) { - $this->cancelOrder($order); + $host = array_shift($orderData); + if ($host == md5($this->helper->getHostUrl())) { + $orderId = array_shift($orderData); + $paymentId = array_shift($orderData); + $coinInvoiceId = $requestData['invoice']['id']; + $transaction = $this->transactionRepository->getByTransactionId( + $coinInvoiceId, + $paymentId, + $orderId + ); + + if (!empty($transaction)) { + /** @var Order $order */ + $order = $transaction->getOrder(); + if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { + $this->completeOrder($requestData['invoice'], $order, $transaction); + } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_CANCELLED) { + $this->cancelOrder($order); + } } } @@ -158,4 +159,4 @@ public function cancelOrder($order) ->save(); } -} \ No newline at end of file +} From ca6d621b904902664817c9d9f7288dbfd55a391c Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 9 Nov 2020 21:27:38 +0200 Subject: [PATCH 061/107] Fix merchant invoice response --- Controller/Invoice/Create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index a372b06..1b42d52 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -102,7 +102,7 @@ public function execute() if ($merchantWebHooks) { $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); - $invoiceData = array_shift($invoicesData); + $invoiceData = array_shift($invoicesData['invoices']); } else { $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); } From 9646b3fc7287ffe42e458665b59a43b2b9201aff Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 9 Nov 2020 21:39:35 +0200 Subject: [PATCH 062/107] Update redirect host --- Helper/Data.php | 2 +- etc/config.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index eaae446..8a14983 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -127,7 +127,7 @@ public function getCoinCheckoutRedirectUrl($coinInvoiceId, $successUrl, $cancelU { return sprintf( '%s/checkout/?invoice-id=%s&success-url=%s&cancel-url=%s', - $this->baseConf['api_host'], + $this->baseConf['checkout_host'], $coinInvoiceId, $successUrl, $cancelUrl diff --git a/etc/config.xml b/etc/config.xml index bfc8a83..8fa1ab7 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -14,6 +14,7 @@ https://api.coinpayments.net + https://checkout.coinpayments.net 1 2.0.0 From 0a3dd0c1aadb16de76aec75a63d0748fc8ae8273 Mon Sep 17 00:00:00 2001 From: USS-Worker Date: Tue, 8 Dec 2020 01:49:37 -0800 Subject: [PATCH 063/107] Changing logo --- etc/config.xml | 1 - view/adminhtml/web/images/logo.png | Bin 6130 -> 50003 bytes view/frontend/web/images/logo.png | Bin 2876 -> 1475 bytes 3 files changed, 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index aef307e..565d631 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -19,5 +19,4 @@ - ` \ No newline at end of file diff --git a/view/adminhtml/web/images/logo.png b/view/adminhtml/web/images/logo.png index 9bc9e035f6dee7e38112f825e1509d19e805a71f..eefad06b81254f836b05b5eabe257879f4733cc2 100644 GIT binary patch literal 50003 zcmeFY z^pG>a)VcA|=Xd^s^WuEI_Z#4jy;tnD_O-6HdG|<1o#rCTMGy!?qw(PWV-Sc!7z82{ zyg&imsS4FB1AdTrK2}!-74=_R2mTC zJb~3e+Ie#xwDTAw1mY%ne?|3)aV5 zfh|EFpQ?hqz*Q_~U|q~y(@y{4GkDQ0GC;onUH`Md|19u73;fRl|FgjVEb#wZ3n(cb zCr)#iScL4ms*6+oQIr2(mLtg1plUm_FG0OOu%i~-4_Au(YXhF^uSj|q;+@SWt6gw| zl8)h3r&~4lH~&2Ta)(^_Rod+;HU;07oenDFcR<GV=4KXj=jY^1a8t@TgcqHk+FTV=leD%8F<0Y`f zfe-KcA30tH+yHKR3{{>NGL;Hh>sxoz^LZHgS2+n45LqxMtDr-ejO)x@-}L{~a(EA- zaM0ylx2@*?BgvW&x$q<7NjJR~+cxR{lLG?GIc52OZ0gCGUpx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_&3`nWUi|mi4dbwmfja9T^mjNO5r@RW; z#oIid$_nQHllL{}#Pw^OUj)GZS)Q9Yl1GjIhTOQlI@l$ULW*?+$)euP#nSET)ZSjz z=>#n3GVPMril{i90`+bUrL9@KRUpx>qp;DvN=UsEZg~5Htd7Ia@*eC}Z41ot^PXBF z>2}(ba6z0%C=r_lYHMq^T|I0<;&?d68ntK4m5(3QRCaIUh=_94)7FNIVG}}i=jND2 z?E{^F2XX6XRK@IwXpitCCm#Xd^rHI(w0O&6jrwKGrFKFn)~I^FZs%Cs(s9D;NIkqx z*xl=$?b(3aITmGyC6nQ_tfBHsMv&8}fJ0uy#!D!8W7b(2g<0dtqrqJ}Py68E~F8YHG})_JgYC=H`mNKuBHX zNhu_k9w~AXDN^bYT<;z{n@CMv0~PHFYt(V%4=+Y^3`ylMoKx7=K*Q{7hu)vFfKo(9 zCX@}VG@X5g5h?QNnL6%{b5QC8++&S;JQig{#K({S2btuilsps?5dZ)H07*qoM6N<$ Ef_fF>OaK4? diff --git a/view/frontend/web/images/logo.png b/view/frontend/web/images/logo.png index 4cc78a80875d05fc8e0d8f6a4d030724e502a0ef..3467c9da139249e45da9958f21b564601bac1a01 100644 GIT binary patch literal 1475 zcmV;!1w8tRP)Px#1ZP1_K>z@;j|==^1pojAZAnByR9Hu~R%>h&RTMsVX13eiZowku(H3gEYYS?L z4G@T;z#kDqC=rXM5{eZ?i}4Xn^pB9n#Q2CY22{Y<1{z`niNqL{VnPVgV!#I$Td*yZ zy6v{m7P{?rAG0&p@6OHww!3t@z?baKz31Gy=R1#k?l8I?DCKfadfRN$c#iun_s>+d zG;C@{K{B7W6xojR^O(j;ILVpRw1k`Dn7CyGa?8)BW>%hdh%qOgiJzS$&gmXZ4e*%J zz9j^**0;>iNMCL7rMbkM=`bvw#I=0Sx%BLHt;=UVePNoAjl@k6nEU)m%Z&AH4@sOo z1^)^a(quyc%bb{s?Yqp?N+suayD93}?bkyGBXigCV->w1@G zXO>?S1e98sONhv5Bt&4#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Ui+3=MM>wG z?^9K9A%J@X2-lW=A-1A*0B9@3GhM7VsextZ2)Ge+q;>xHmG9cBw$ut{gsWaFLj$|h z$Hn!Y$KJ(>OyMFUlA9Uf=8ox_btu{3|$P84RK5p>YgD(Em^ zcm1Uefp5coJL)Y+7&VhQ+NFuzvN#J#iykq^r>{PztTUa{OF-1(28%5o|1nC9&_kZs X%U{10%(AcjF};_KEsZJ--D3X-tYJ+I From cf13153d402735f1c4cbe0b0fc32b1722674cab8 Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 8 Dec 2020 18:22:06 +0200 Subject: [PATCH 064/107] Ignore .idea --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5b9bd87..779cf88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ - +.idea *.bak From ef60a5233de3bea871771b58870fa69362e16f06 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 28 Jan 2021 18:06:42 +0200 Subject: [PATCH 065/107] webhook notification url unique for each user & event --- Controller/Adminhtml/Validation/WebHook.php | 16 ++++++++++++---- Controller/WebHooks/Notification.php | 2 +- Helper/Data.php | 19 +++++++++++++++++-- Model/WebHook.php | 19 +++++++++---------- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 5a179fd..6239b5c 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -36,12 +36,20 @@ public function execute() }, $webHooksList['items']); } - if (!in_array($this->helper->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL), $webHooksUrlsList)) { - $webHook = $this->webHookModel->createWebHook($clientId, $clientSecret, $this->helper->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL)); - if (!empty($webHook)) { + if ( + !in_array($this->helper->getNotificationUrl($clientId, DATA::PAID_EVENT), $webHooksUrlsList) || + !in_array($this->helper->getNotificationUrl($clientId, DATA::PENDING_EVENT), $webHooksUrlsList) || + !in_array($this->helper->getNotificationUrl($clientId, DATA::CANCELLED_EVENT), $webHooksUrlsList) + ) { + if ( + !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::PAID_EVENT)) && + !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::PENDING_EVENT)) && + !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::CANCELLED_EVENT)) + + ) { $this->helper->setConfig('validated', $params['client_id'] . $params['client_secret']); $response = [ - 'success' => $webHook, + 'success' => true, ]; } else { $response = [ diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index c84fa29..2d9c951 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -52,8 +52,8 @@ public function execute() if (!empty($this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY)) && !empty($this->getRequest()->getHeaders()->get('X-CoinPayments-Signature'))) { $content = $this->getRequest()->getContent(); $signature = $this->getRequest()->getHeaders()->get('X-CoinPayments-Signature')->getFieldValue(); + $requestData = json_decode($content, true); if ($this->checkDataSignature($signature, $content)) { - $requestData = json_decode($content, true); $this->webHookModel->receiveNotification($requestData); } } diff --git a/Helper/Data.php b/Helper/Data.php index 8a14983..610b0cc 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -36,8 +36,9 @@ class Data extends AbstractHelper const CREATE_INVOICE_URL = 'coinpayments/invoice/create'; const WEBHOOK_NOTIFICATION_URL = 'coinpayments/webhooks/notification'; - const API_INVOICE_COMPLETED = 'Completed'; - const API_INVOICE_CANCELLED = 'Cancelled'; + const PENDING_EVENT = 'Pending'; + const PAID_EVENT = 'Paid'; + const CANCELLED_EVENT = 'Cancelled'; /** * @var Config @@ -117,6 +118,20 @@ public function getHostUrl($route = '') return $this->_getUrl($route, ['_direct' => null]); } + /** + * @param $clientId + * @param $event + * @return string + */ + public function getNotificationUrl($clientId, $event) + { + $query = http_build_query(array( + 'event' => $event, + 'clientId' => $clientId, + )); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + } + /** * @param $coinInvoiceId * @param $successUrl diff --git a/Model/WebHook.php b/Model/WebHook.php index a12640e..48111b6 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -16,11 +16,11 @@ class WebHook extends AbstractApi implements WebHookInterface /** * @param $clientId * @param $clientSecret - * @param $webHookCallbackUrl + * @param $event * @return mixed * @throws \Exception */ - public function createWebHook($clientId, $clientSecret, $webHookCallbackUrl) + public function createWebHook($clientId, $clientSecret, $event) { $action = sprintf(Data::API_WEBHOOK_ACTION, $clientId); @@ -33,13 +33,9 @@ public function createWebHook($clientId, $clientSecret, $webHookCallbackUrl) ]; $requestData = [ - "notificationsUrl" => $webHookCallbackUrl, + "notificationsUrl" => $this->helper->getNotificationUrl($clientId, $event), "notifications" => [ - "invoiceCreated", - "invoicePending", - "invoicePaid", - "invoiceCompleted", - "invoiceCancelled", + sprintf("invoice%s", $event), ], ]; @@ -91,9 +87,12 @@ public function receiveNotification($requestData) if (!empty($transaction)) { /** @var Order $order */ $order = $transaction->getOrder(); - if ($requestData['invoice']['status'] == Data::API_INVOICE_COMPLETED) { + + + $completed_statuses = array(Data::PAID_EVENT, Data::PENDING_EVENT); + if (in_array($requestData['invoice']['status'], $completed_statuses)) { $this->completeOrder($requestData['invoice'], $order, $transaction); - } elseif ($requestData['invoice']['status'] == Data::API_INVOICE_CANCELLED) { + } elseif ($requestData['invoice']['status'] == Data::CANCELLED_EVENT) { $this->cancelOrder($order); } } From 90d2ed5c969d4e319236e63a31f3756cdb24b860 Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 10 Feb 2021 20:19:05 +0200 Subject: [PATCH 066/107] Use order link as notesToRecipient --- Api/InvoiceInterface.php | 15 ++--- Controller/Adminhtml/Validation/Invoice.php | 14 +++- Controller/Invoice/Create.php | 30 +++++++-- Model/Invoice.php | 71 +++++++++++++++------ 4 files changed, 93 insertions(+), 37 deletions(-) diff --git a/Api/InvoiceInterface.php b/Api/InvoiceInterface.php index 0d81431..71b68a1 100644 --- a/Api/InvoiceInterface.php +++ b/Api/InvoiceInterface.php @@ -7,22 +7,17 @@ interface InvoiceInterface /** * @param $clientId - * @param $currencyId - * @param $invoiceId - * @param $amount + * @param $invoiceParams * @return mixed */ - public function createSimple($clientId, $currencyId, $invoiceId, $amount); + public function createSimple($clientId, $invoiceParams); /** * @param $clientId * @param $clientSecret - * @param $currencyId - * @param $invoiceId - * @param $amount - * @param $displayValue + * @param $invoiceParams * @return mixed */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $displayValue); + public function createMerchant($clientId, $clientSecret, $invoiceParams); -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Validation/Invoice.php b/Controller/Adminhtml/Validation/Invoice.php index aa2d7d2..27705b1 100644 --- a/Controller/Adminhtml/Validation/Invoice.php +++ b/Controller/Adminhtml/Validation/Invoice.php @@ -16,7 +16,17 @@ public function execute() $response = []; if (!empty($params['client_id']) && $this->helper->getConfig('validated') != $params['client_id']) { $clientId = $params['client_id']; - $invoice = $this->invoiceModel->createSimple($clientId); + + $invoiceParams = array( + 'currencyId' => 5057, + 'invoiceId' => 'Validate invoice', + 'amount' => 1, + 'displayValue' => '0.01', + 'notesLink' => '', + ); + + $invoice = $this->invoiceModel->createSimple($clientId, $invoiceParams); + if ($invoice) { $this->helper->setConfig('validated', $params['client_id']); $response = [ @@ -44,4 +54,4 @@ public function execute() $result->setData($response); return $result; } -} \ No newline at end of file +} diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 1b42d52..4d96183 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -41,6 +41,10 @@ class Create extends Action implements CsrfAwareActionInterface * @var Data */ protected $helper; + /** + * @var \Magento\Backend\Model\Url + */ + protected $backendUrl; /** * Create constructor. @@ -51,6 +55,7 @@ class Create extends Action implements CsrfAwareActionInterface * @param ScopeConfigInterface $scopeConfig * @param Url $urlBuilder * @param JsonFactory $jsonResultFactory + * @param \Magento\Backend\Model\Url $backendUrl */ public function __construct( Context $context, @@ -59,7 +64,8 @@ public function __construct( Session $checkoutSession, ScopeConfigInterface $scopeConfig, Url $urlBuilder, - JsonFactory $jsonResultFactory + JsonFactory $jsonResultFactory, + \Magento\Backend\Model\Url $backendUrl ) { @@ -69,6 +75,7 @@ public function __construct( $this->scopeConfig = $scopeConfig; $this->checkoutSession = $checkoutSession; $this->jsonResultFactory = $jsonResultFactory; + $this->backendUrl = $backendUrl; parent::__construct($context); } @@ -100,11 +107,22 @@ public function execute() $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); $invoiceId = sprintf('%s|%s|%s', md5($this->helper->getHostUrl()), $order->getId(), $order->getPayment()->getId()); - if ($merchantWebHooks) { - $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); - $invoiceData = array_shift($invoicesData['invoices']); - } else { - $invoiceData = $this->invoiceModel->createSimple($clientId, $coinCurrency['id'], $invoiceId, intval($amount), $order->getGrandTotal()); + $invoiceParams = array( + 'invoiceId' => $invoiceId, + 'currencyId' => $coinCurrency['id'], + 'displayValue' => $order->getGrandTotal(), + 'amount' => intval($amount), + 'billingData' => $order->getBillingAddress(), + 'notesLink' => $this->backendUrl->getUrl('sales/order/view', ['order_id' => $order->getId()]), + ); + try { + if ($merchantWebHooks) { + $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $invoiceParams); + $invoiceData = array_shift($invoicesData['invoices']); + } else { + $invoiceData = $this->invoiceModel->createSimple($clientId, $invoiceParams); + } + } catch (\Exception $e) { } if (!empty($invoiceData['id'])) { diff --git a/Model/Invoice.php b/Model/Invoice.php index b2a06b6..26fe35f 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -16,14 +16,11 @@ class Invoice extends AbstractApi implements InvoiceInterface /** * @param $clientId * @param $clientSecret - * @param $currencyId - * @param $invoiceId - * @param $amount - * @param $displayValue + * @param $invoiceParams * @return mixed * @throws \Exception */ - public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId, $amount, $displayValue) + public function createMerchant($clientId, $clientSecret, $invoiceParams) { $action = Data::API_MERCHANT_INVOICE_ACTION; @@ -36,14 +33,19 @@ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId ]; $requestData = [ - "invoiceId" => $invoiceId, + "invoiceId" => $invoiceParams['invoiceId'], "amount" => [ - "currencyId" => $currencyId, - "displayValue" => $displayValue, - "value" => $amount + "currencyId" => $invoiceParams['currencyId'], + "displayValue" => $invoiceParams['displayValue'], + "value" => $invoiceParams['amount'] ], + 'noteToRecipient' => $invoiceParams['notesLink'], ]; + if (isset($invoiceParams['billingData'])) { + $requestData['buyer'] = $this->appendBillingData($invoiceParams['billingData']); + } + $requestData = $this->appendInvoiceMetadata($requestData); $headers = $this->getRequestHeaders($requestParams, $requestData); return $this->sendPostRequest($action, $headers, $requestData); @@ -51,27 +53,29 @@ public function createMerchant($clientId, $clientSecret, $currencyId, $invoiceId /** * @param $clientId - * @param int $currencyId - * @param string $invoiceId - * @param int $amount - * @param string $displayValue + * @param $invoiceParams * @return mixed */ - public function createSimple($clientId, $currencyId = 5057, $invoiceId = 'Validate invoice', $amount = 1, $displayValue = '0.01') + public function createSimple($clientId, $invoiceParams) { $action = Data::API_SIMPLE_INVOICE_ACTION; $requestData = [ 'clientId' => $clientId, - 'invoiceId' => $invoiceId, + 'invoiceId' => $invoiceParams['invoiceId'], 'amount' => [ - 'currencyId' => $currencyId, - "displayValue" => $displayValue, - 'value' => $amount + 'currencyId' => $invoiceParams['currencyId'], + "displayValue" => $invoiceParams['displayValue'], + 'value' => $invoiceParams['amount'], ], + 'noteToRecipient' => $invoiceParams['notesLink'], ]; + if (isset($invoiceParams['billingData'])) { + $requestData['buyer'] = $this->appendBillingData($invoiceParams['billingData']); + } + $requestData = $this->appendInvoiceMetadata($requestData); return $this->sendPostRequest($action, [], $requestData); } @@ -95,6 +99,10 @@ public function createOrderTransaction($order, $coinInvoiceId) return $transaction->getTransactionId(); } + /** + * @param $requestData + * @return mixed + */ protected function appendInvoiceMetadata($requestData) { @@ -105,4 +113,29 @@ protected function appendInvoiceMetadata($requestData) return $requestData; } -} \ No newline at end of file + + /** + * @param $billingData + * @return array + */ + function appendBillingData($billingData) + { + return array( + "companyName" => $billingData->getCompany(), + "name" => array( + "firstName" => $billingData->getFirstname(), + "lastName" => $billingData->getLastname(), + ), + "emailAddress" => $billingData->getEmail(), + "phoneNumber" => $billingData->getTelephone(), + "address" => array( + "address1" => $billingData->getStreetLine(1), + "address2" => $billingData->getStreetLine(2), + "provinceOrState" => $billingData->getRegionCode(), + "city" => $billingData->getCity(), + "countryCode" => $billingData->getCountryId(), + "postalCode" => $billingData->getPostcode() + ) + ); + } +} From 534207e1213f3f69eef7a3de627451aaffc9e32f Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 11 Feb 2021 00:14:00 +0200 Subject: [PATCH 067/107] add invoice info to order --- Model/WebHook.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Model/WebHook.php b/Model/WebHook.php index 48111b6..513235f 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -87,8 +87,6 @@ public function receiveNotification($requestData) if (!empty($transaction)) { /** @var Order $order */ $order = $transaction->getOrder(); - - $completed_statuses = array(Data::PAID_EVENT, Data::PENDING_EVENT); if (in_array($requestData['invoice']['status'], $completed_statuses)) { $this->completeOrder($requestData['invoice'], $order, $transaction); @@ -137,6 +135,14 @@ public function completeOrder($rawDetails, $order, $transaction) $payment->addTransactionCommentsToOrder($transaction, __('The authorized amount is %1.', $formatedPrice)); $payment->setParentTransactionId(null); + $invoice = $order->prepareInvoice()->register(); + $invoice->setOrder($order); + $invoice->setOrder($order); + $invoice->pay(); + + $order->addRelatedObject($invoice); + $payment->setCreatedInvoice($invoice); + $payment->save(); $order->save(); $transaction->save(); From 059bde0808a456e83f41454cea7944473856bbd7 Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 16 Feb 2021 23:05:30 +0200 Subject: [PATCH 068/107] Fix invoice buyer info --- Model/Invoice.php | 54 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Model/Invoice.php b/Model/Invoice.php index 26fe35f..4f76a91 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -33,11 +33,11 @@ public function createMerchant($clientId, $clientSecret, $invoiceParams) ]; $requestData = [ - "invoiceId" => $invoiceParams['invoiceId'], - "amount" => [ - "currencyId" => $invoiceParams['currencyId'], - "displayValue" => $invoiceParams['displayValue'], - "value" => $invoiceParams['amount'] + 'invoiceId' => $invoiceParams['invoiceId'], + 'amount' => [ + 'currencyId' => $invoiceParams['currencyId'], + 'displayValue' => $invoiceParams['displayValue'], + 'value' => $invoiceParams['amount'] ], 'noteToRecipient' => $invoiceParams['notesLink'], ]; @@ -66,7 +66,7 @@ public function createSimple($clientId, $invoiceParams) 'invoiceId' => $invoiceParams['invoiceId'], 'amount' => [ 'currencyId' => $invoiceParams['currencyId'], - "displayValue" => $invoiceParams['displayValue'], + 'displayValue' => $invoiceParams['displayValue'], 'value' => $invoiceParams['amount'], ], 'noteToRecipient' => $invoiceParams['notesLink'], @@ -107,8 +107,8 @@ protected function appendInvoiceMetadata($requestData) { $requestData['metadata'] = [ - "integration" => sprintf("Magento_v%s", $this->helper->getBaseConfigParam(Data::PACKAGE_VERSION)), - "hostname" => $this->helper->getHostUrl(), + 'integration' => sprintf('Magento_v%s', $this->helper->getBaseConfigParam(Data::PACKAGE_VERSION)), + 'hostname' => $this->helper->getHostUrl(), ]; return $requestData; @@ -120,22 +120,30 @@ protected function appendInvoiceMetadata($requestData) */ function appendBillingData($billingData) { - return array( - "companyName" => $billingData->getCompany(), - "name" => array( - "firstName" => $billingData->getFirstname(), - "lastName" => $billingData->getLastname(), + $params = array( + 'companyName' => $billingData->getCompany(), + 'name' => array( + 'firstName' => $billingData->getFirstname(), + 'lastName' => $billingData->getLastname(), ), - "emailAddress" => $billingData->getEmail(), - "phoneNumber" => $billingData->getTelephone(), - "address" => array( - "address1" => $billingData->getStreetLine(1), - "address2" => $billingData->getStreetLine(2), - "provinceOrState" => $billingData->getRegionCode(), - "city" => $billingData->getCity(), - "countryCode" => $billingData->getCountryId(), - "postalCode" => $billingData->getPostcode() - ) + 'emailAddress' => $billingData->getEmail(), + 'phoneNumber' => $billingData->getTelephone(), + ); + + + if (!empty($billingData->getStreetLine(1)) && + !empty($billingData->getCity()) && + preg_match('/^([A-Z]{2})$/', $billingData->getCountryId()) + ) { + $params['address'] = array( + 'address1' => $billingData->getStreetLine(1), + 'address2' => $billingData->getStreetLine(2), + 'provinceOrState' => $billingData->getRegionCode(), + 'city' => $billingData->getCity(), + 'countryCode' => $billingData->getCountryId(), + 'postalCode' => $billingData->getPostcode() + ); + } } } From 18fd99f006ca3c5401838eb199f51d761c38d69a Mon Sep 17 00:00:00 2001 From: letscode Date: Tue, 16 Feb 2021 23:06:10 +0200 Subject: [PATCH 069/107] Use Paid status to confirm payment --- Controller/Adminhtml/Validation/WebHook.php | 2 -- Helper/Data.php | 1 - Model/WebHook.php | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Controller/Adminhtml/Validation/WebHook.php b/Controller/Adminhtml/Validation/WebHook.php index 6239b5c..65758ca 100644 --- a/Controller/Adminhtml/Validation/WebHook.php +++ b/Controller/Adminhtml/Validation/WebHook.php @@ -38,12 +38,10 @@ public function execute() if ( !in_array($this->helper->getNotificationUrl($clientId, DATA::PAID_EVENT), $webHooksUrlsList) || - !in_array($this->helper->getNotificationUrl($clientId, DATA::PENDING_EVENT), $webHooksUrlsList) || !in_array($this->helper->getNotificationUrl($clientId, DATA::CANCELLED_EVENT), $webHooksUrlsList) ) { if ( !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::PAID_EVENT)) && - !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::PENDING_EVENT)) && !empty($this->webHookModel->createWebHook($clientId, $clientSecret, DATA::CANCELLED_EVENT)) ) { diff --git a/Helper/Data.php b/Helper/Data.php index 610b0cc..9056466 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -36,7 +36,6 @@ class Data extends AbstractHelper const CREATE_INVOICE_URL = 'coinpayments/invoice/create'; const WEBHOOK_NOTIFICATION_URL = 'coinpayments/webhooks/notification'; - const PENDING_EVENT = 'Pending'; const PAID_EVENT = 'Paid'; const CANCELLED_EVENT = 'Cancelled'; diff --git a/Model/WebHook.php b/Model/WebHook.php index 513235f..5d3a0be 100644 --- a/Model/WebHook.php +++ b/Model/WebHook.php @@ -87,8 +87,7 @@ public function receiveNotification($requestData) if (!empty($transaction)) { /** @var Order $order */ $order = $transaction->getOrder(); - $completed_statuses = array(Data::PAID_EVENT, Data::PENDING_EVENT); - if (in_array($requestData['invoice']['status'], $completed_statuses)) { + if ($requestData['invoice']['status'] == Data::PAID_EVENT) { $this->completeOrder($requestData['invoice'], $order, $transaction); } elseif ($requestData['invoice']['status'] == Data::CANCELLED_EVENT) { $this->cancelOrder($order); From fef67fe32bfa7dc5e3dcb0d29402dc288e57c52f Mon Sep 17 00:00:00 2001 From: letscode Date: Wed, 17 Feb 2021 01:02:03 +0200 Subject: [PATCH 070/107] Add SEO description --- view/frontend/web/template/payment/coin_payment.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/frontend/web/template/payment/coin_payment.html b/view/frontend/web/template/payment/coin_payment.html index 295bbdc..91c7081 100644 --- a/view/frontend/web/template/payment/coin_payment.html +++ b/view/frontend/web/template/payment/coin_payment.html @@ -14,6 +14,10 @@ +
    From 30735c5aa1a6d8c2e13670d9d13a3f2748d92621 Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 22 Mar 2021 16:15:44 +0200 Subject: [PATCH 071/107] Fix php version compatibility --- Controller/Invoice/Create.php | 4 ++-- Controller/WebHooks/Notification.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 4d96183..fcaa316 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -166,12 +166,12 @@ protected function getCoinCurrency(string $name) return array_shift($items); } - public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException + public function createCsrfValidationException(RequestInterface $request) { return null; } - public function validateForCsrf(RequestInterface $request): ?bool + public function validateForCsrf(RequestInterface $request) { return true; } diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index 2d9c951..bfacb48 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -74,12 +74,12 @@ protected function checkDataSignature($signature, $content) return $signature == $encodedPure; } - public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException + public function createCsrfValidationException(RequestInterface $request) { return null; } - public function validateForCsrf(RequestInterface $request): ?bool + public function validateForCsrf(RequestInterface $request) { return true; } From e60fd09d56303c04f063e5fca7a6d91fb37090f5 Mon Sep 17 00:00:00 2001 From: letscode Date: Mon, 22 Mar 2021 16:17:08 +0200 Subject: [PATCH 072/107] Fix invoice buyer data --- Model/Invoice.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Model/Invoice.php b/Model/Invoice.php index 4f76a91..d043921 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -126,11 +126,12 @@ function appendBillingData($billingData) 'firstName' => $billingData->getFirstname(), 'lastName' => $billingData->getLastname(), ), - 'emailAddress' => $billingData->getEmail(), 'phoneNumber' => $billingData->getTelephone(), - ); + if (preg_match('/^.*@.*$/', $billingData->getEmail())) { + $params['emailAddress'] = $billingData->getEmail(); + } if (!empty($billingData->getStreetLine(1)) && !empty($billingData->getCity()) && @@ -145,5 +146,7 @@ function appendBillingData($billingData) 'postalCode' => $billingData->getPostcode() ); } + + return $params; } } From 76806cd4553d538618a678ab4285b7d78d760599 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 25 Mar 2021 16:20:18 +0200 Subject: [PATCH 073/107] Revert "Fix php version compatibility" This reverts commit 30735c5a --- Controller/Invoice/Create.php | 4 ++-- Controller/WebHooks/Notification.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index fcaa316..4d96183 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -166,12 +166,12 @@ protected function getCoinCurrency(string $name) return array_shift($items); } - public function createCsrfValidationException(RequestInterface $request) + public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException { return null; } - public function validateForCsrf(RequestInterface $request) + public function validateForCsrf(RequestInterface $request): ?bool { return true; } diff --git a/Controller/WebHooks/Notification.php b/Controller/WebHooks/Notification.php index bfacb48..2d9c951 100644 --- a/Controller/WebHooks/Notification.php +++ b/Controller/WebHooks/Notification.php @@ -74,12 +74,12 @@ protected function checkDataSignature($signature, $content) return $signature == $encodedPure; } - public function createCsrfValidationException(RequestInterface $request) + public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException { return null; } - public function validateForCsrf(RequestInterface $request) + public function validateForCsrf(RequestInterface $request): ?bool { return true; } From 96e6205b45c87ece85e9625c71ab5981fe3b5893 Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 25 Mar 2021 16:22:18 +0200 Subject: [PATCH 074/107] Fix composer php requirements --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 266a15a..e339362 100644 --- a/composer.json +++ b/composer.json @@ -2,8 +2,7 @@ "name": "coinpaymentsnet/magento2", "description": "Add new payment method for CoinPayments.net", "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1", - "lusitanian/oauth": "~0.8.10" + "php": "~7.3.0||~7.4.0" }, "type": "magento2-module", "version": "2.0.0", From aa454721588861c69d3c2f956900059326a0958a Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 25 Mar 2021 16:23:41 +0200 Subject: [PATCH 075/107] Add notesToRecipient description --- Controller/Invoice/Create.php | 24 ++++++++++++++++-------- Helper/Data.php | 10 ++++++++++ Model/Invoice.php | 4 ++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Controller/Invoice/Create.php b/Controller/Invoice/Create.php index 4d96183..94a28a7 100644 --- a/Controller/Invoice/Create.php +++ b/Controller/Invoice/Create.php @@ -107,15 +107,23 @@ public function execute() $merchantWebHooks = $this->helper->getConfig(Data::CLIENT_WEBHOOKS_KEY); $invoiceId = sprintf('%s|%s|%s', md5($this->helper->getHostUrl()), $order->getId(), $order->getPayment()->getId()); - $invoiceParams = array( - 'invoiceId' => $invoiceId, - 'currencyId' => $coinCurrency['id'], - 'displayValue' => $order->getGrandTotal(), - 'amount' => intval($amount), - 'billingData' => $order->getBillingAddress(), - 'notesLink' => $this->backendUrl->getUrl('sales/order/view', ['order_id' => $order->getId()]), - ); try { + $notesLink = sprintf( + "%s|Store name: %s|Order #%s", + $this->backendUrl->getUrl('sales/order/view', ['order_id' => $order->getId(), '_nosecret' => true]), + $this->helper->getGeneralConfig('store_information/name'), + $order->getId() + ); + + $invoiceParams = array( + 'invoiceId' => $invoiceId, + 'currencyId' => $coinCurrency['id'], + 'displayValue' => $order->getGrandTotal(), + 'amount' => intval($amount), + 'billingData' => $order->getBillingAddress(), + 'notesLink' => $notesLink, + ); + if ($merchantWebHooks) { $invoicesData = $this->invoiceModel->createMerchant($clientId, $clientSecret, $invoiceParams); $invoiceData = array_shift($invoicesData['invoices']); diff --git a/Helper/Data.php b/Helper/Data.php index 9056466..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -19,6 +19,7 @@ class Data extends AbstractHelper const INVOICE_CACHE_PREFIX = 'CoinpaymentsInvoice'; const XML_PATH_CONFIG_COINPAYMENTS = 'payment/coin_payments/'; + const XML_PATH_CONFIG_GENERAL = 'general/'; const CLIENT_ID_KEY = 'client_id'; const CLIENT_SECRET_KEY = 'client_secret'; @@ -68,6 +69,15 @@ public function getConfig($param) return $this->scopeConfig->getValue(self::XML_PATH_CONFIG_COINPAYMENTS . $param); } + /** + * @param $param + * @return mixed + */ + public function getGeneralConfig($param) + { + return $this->scopeConfig->getValue(self::XML_PATH_CONFIG_GENERAL . $param); + } + /** * @param $param * @param $value diff --git a/Model/Invoice.php b/Model/Invoice.php index d043921..bac1a09 100644 --- a/Model/Invoice.php +++ b/Model/Invoice.php @@ -39,7 +39,7 @@ public function createMerchant($clientId, $clientSecret, $invoiceParams) 'displayValue' => $invoiceParams['displayValue'], 'value' => $invoiceParams['amount'] ], - 'noteToRecipient' => $invoiceParams['notesLink'], + 'notesToRecipient' => $invoiceParams['notesLink'], ]; if (isset($invoiceParams['billingData'])) { @@ -69,7 +69,7 @@ public function createSimple($clientId, $invoiceParams) 'displayValue' => $invoiceParams['displayValue'], 'value' => $invoiceParams['amount'], ], - 'noteToRecipient' => $invoiceParams['notesLink'], + 'notesToRecipient' => $invoiceParams['notesLink'], ]; if (isset($invoiceParams['billingData'])) { From e9512731c684e4efe9099f1d6045108fb64bf11c Mon Sep 17 00:00:00 2001 From: letscode Date: Thu, 25 Mar 2021 16:34:25 +0200 Subject: [PATCH 076/107] Update webhook url formation --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From a3d05a1a33a1981c4bb11b0e58f79ea1074de88d Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:13:33 +0400 Subject: [PATCH 077/107] Revert "Update webhook url formation" This reverts commit e9512731c684e4efe9099f1d6045108fb64bf11c. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From a056af0b1a66d40103441ba259a0f65b9fdb8ff3 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:13:37 +0400 Subject: [PATCH 078/107] Revert "Revert "Update webhook url formation"" This reverts commit a3d05a1a33a1981c4bb11b0e58f79ea1074de88d. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 02033b3770f6948be44bfe2fd3f335ad33c6f7dd Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:13:44 +0400 Subject: [PATCH 079/107] Revert "Revert "Revert "Update webhook url formation""" This reverts commit a056af0b1a66d40103441ba259a0f65b9fdb8ff3. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 218ebac576a21152634a8989e9ab1f842d3dc4d0 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:19 +0400 Subject: [PATCH 080/107] Revert "Revert "Update webhook url formation"" This reverts commit a3d05a1a33a1981c4bb11b0e58f79ea1074de88d. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 6c5985289c892c3073e7a792a1bbf6b33857400a Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:26 +0400 Subject: [PATCH 081/107] Revert "Revert "Revert "Update webhook url formation""" This reverts commit 218ebac576a21152634a8989e9ab1f842d3dc4d0. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 0a4f2215636fbffb59dbebd7c75c615eaee14281 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:37 +0400 Subject: [PATCH 082/107] Revert "Revert "Revert "Revert "Update webhook url formation"""" This reverts commit 6c5985289c892c3073e7a792a1bbf6b33857400a. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 67b6a897dced393fd93281193cd50abcea95d3d1 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:43 +0400 Subject: [PATCH 083/107] Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""" This reverts commit 0a4f2215636fbffb59dbebd7c75c615eaee14281. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 585a144e524d81cf01b083510527d1ff8d0bdd85 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:47 +0400 Subject: [PATCH 084/107] Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""" This reverts commit 67b6a897dced393fd93281193cd50abcea95d3d1. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 37c35ca77b9bc02952fe2b644b563b1725d0db3a Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:54 +0400 Subject: [PATCH 085/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""" This reverts commit 585a144e524d81cf01b083510527d1ff8d0bdd85. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From d45957656e9dca535d40b753b51fe6e40044d521 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:14:58 +0400 Subject: [PATCH 086/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""" This reverts commit 37c35ca77b9bc02952fe2b644b563b1725d0db3a. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 6b85602cb6db7bd062edab83e9d44bf6ac17ebc4 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:01 +0400 Subject: [PATCH 087/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""" This reverts commit d45957656e9dca535d40b753b51fe6e40044d521. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 1f7e54e1e73208ab4c7e564f14580e474b210bfd Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:04 +0400 Subject: [PATCH 088/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""" This reverts commit 6b85602cb6db7bd062edab83e9d44bf6ac17ebc4. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From c2f813a4a54d9b8e598cf293ce6a82c01534034b Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:11 +0400 Subject: [PATCH 089/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""" This reverts commit 1f7e54e1e73208ab4c7e564f14580e474b210bfd. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 0eec89187cc5fb6e74e8e180c5a77f205c3f1f3e Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:15 +0400 Subject: [PATCH 090/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""" This reverts commit c2f813a4a54d9b8e598cf293ce6a82c01534034b. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 17af736c0aa4a8571d6c6d9f3ede535cc39eb328 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:20 +0400 Subject: [PATCH 091/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""" This reverts commit 0eec89187cc5fb6e74e8e180c5a77f205c3f1f3e. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 36b2c71458753e6343a18a74736ec5d54225beca Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:23 +0400 Subject: [PATCH 092/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""" This reverts commit c2f813a4a54d9b8e598cf293ce6a82c01534034b. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 64d83b65d9fd23c35de2982fc89c5a64bef3947e Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:24 +0400 Subject: [PATCH 093/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""" This reverts commit 0eec89187cc5fb6e74e8e180c5a77f205c3f1f3e. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 7826ce48857c7f92ebb107f399c763672227d90d Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:25 +0400 Subject: [PATCH 094/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""""" This reverts commit 17af736c0aa4a8571d6c6d9f3ede535cc39eb328. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 5f3780e53694adf512f535d9a2af80581cd0435f Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:26 +0400 Subject: [PATCH 095/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""" This reverts commit 36b2c71458753e6343a18a74736ec5d54225beca. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 01ebd0c7438ee4826b1cb6ffafcee996a0b9d602 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:41 +0400 Subject: [PATCH 096/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""""" This reverts commit 5f3780e53694adf512f535d9a2af80581cd0435f. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From ddf89bc685233b4f34c4ce2e24626a4478cc78bc Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:44 +0400 Subject: [PATCH 097/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""""" This reverts commit 7826ce48857c7f92ebb107f399c763672227d90d. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From 20079f6aca88a6bf748e49110d896a4a2627c118 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:50 +0400 Subject: [PATCH 098/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""""""" This reverts commit ddf89bc685233b4f34c4ce2e24626a4478cc78bc. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From 18a6e55b4338c583c1569b320a436f36be98d58b Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:53 +0400 Subject: [PATCH 099/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""""""" This reverts commit 20079f6aca88a6bf748e49110d896a4a2627c118. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From d1fd832ec2f5c834949520fa7d08edbf9d6f7c00 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:56 +0400 Subject: [PATCH 100/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation"""""""""""""""""" This reverts commit 18a6e55b4338c583c1569b320a436f36be98d58b. --- Helper/Data.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 9cb1d53..f38862f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '') + public function getHostUrl($route = '', $params = ['_direct' => null]) { - return $this->_getUrl($route, ['_direct' => null]); + return $this->_getUrl($route, $params); } /** @@ -138,7 +138,10 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ + '_nosid' => true, + '_query' => $query, + ]); } /** From d168e02b81f84f81c332a9bca1a64f9a65264226 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:16:02 +0400 Subject: [PATCH 101/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""""""""" This reverts commit d1fd832ec2f5c834949520fa7d08edbf9d6f7c00. --- Helper/Data.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index f38862f..9cb1d53 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -122,9 +122,9 @@ public function getBaseConfigParam($param) * @param string $route * @return string */ - public function getHostUrl($route = '', $params = ['_direct' => null]) + public function getHostUrl($route = '') { - return $this->_getUrl($route, $params); + return $this->_getUrl($route, ['_direct' => null]); } /** @@ -138,10 +138,7 @@ public function getNotificationUrl($clientId, $event) 'event' => $event, 'clientId' => $clientId, )); - return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL, [ - '_nosid' => true, - '_query' => $query, - ]); + return $this->getHostUrl(DATA::WEBHOOK_NOTIFICATION_URL) . '?' . $query; } /** From d5480c1c626ee91a38ac55128cb3e4ecaefc18e9 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Thu, 8 Apr 2021 17:15:53 +0400 Subject: [PATCH 102/107] Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Revert "Update webhook url formation""""""""""""""""" This reverts commit 20079f6aca88a6bf748e49110d896a4a2627c118. From 8b1675dfb134a41ee8a9faba6e616ae0aaa6c34c Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Fri, 9 Apr 2021 10:50:17 +0400 Subject: [PATCH 103/107] Revert "update logo" --- Model/CoinPaymentsConfigProvider.php | 2 +- view/frontend/web/images/logo.svg | 75 ---------------------------- 2 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 view/frontend/web/images/logo.svg diff --git a/Model/CoinPaymentsConfigProvider.php b/Model/CoinPaymentsConfigProvider.php index 19cda93..c6f4f20 100644 --- a/Model/CoinPaymentsConfigProvider.php +++ b/Model/CoinPaymentsConfigProvider.php @@ -91,7 +91,7 @@ public function getConfig() 'coinpayments' => [ 'available_currencies' => $currencies, 'accepted_currencies' => $acceptedCurrencies, - 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.svg'), + 'logo' => $this->_assetRepo->getUrl('Coinpayments_CoinPayments::images/logo.png'), 'direct_mode' => (int)$isDirect, 'url' => $coinpaymentsDomain, 'api_url' => $coinpaymentsApi diff --git a/view/frontend/web/images/logo.svg b/view/frontend/web/images/logo.svg deleted file mode 100644 index d8b21d9..0000000 --- a/view/frontend/web/images/logo.svg +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - Black_Make_Easy_CoinPayments_Updated_logo_2 - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 7338c0758930f4698106ac297ebc857fc9bdb97b Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Sat, 10 Apr 2021 15:40:56 +0400 Subject: [PATCH 104/107] pay --- Api/InvoiceInterface.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Api/InvoiceInterface.php b/Api/InvoiceInterface.php index 71b68a1..014b852 100644 --- a/Api/InvoiceInterface.php +++ b/Api/InvoiceInterface.php @@ -1,5 +1,9 @@ >>>>>> Stashed changes namespace Coinpayments\CoinPayments\Api; interface InvoiceInterface From 5c5e61e86da968b970449c40cdc772ead09a9f4f Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Sat, 10 Apr 2021 16:23:45 +0400 Subject: [PATCH 105/107] Create launch.json --- .vscode/launch.json | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..57a4ec1 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,94 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Attach to Remote Program", + "request": "attach", + "hostName": "", + "port": "" + }, + { + "name": "Launch Chrome", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + }, + { + "type": "java", + "name": "Launch External Terminal", + "request": "launch", + "console": "externalTerminal", + "mainClass": "" + }, + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, + { + "type": "java", + "name": "Attach to Remote Program", + "request": "attach", + "hostName": "", + "port": "" + }, + { + "name": "Launch Chrome", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + }, + { + "type": "java", + "name": "Attach to Remote Program", + "request": "attach", + "hostName": "", + "port": "" + }, + { + "type": "java", + "name": "Attach to Remote Program", + "request": "attach", + "hostName": "", + "port": "" + }, + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, + { + "type": "pwa-msedge", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file From caec4ad64f449edd3d1371e2f002bf6d1e860101 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Sat, 10 Apr 2021 16:38:57 +0400 Subject: [PATCH 106/107] Create tasks.json --- .vscode/tasks.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..ed46e28 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "verify", + "type": "shell", + "command": "mvn -B verify", + "group": "build" + }, + { + "label": "test", + "type": "shell", + "command": "mvn -B test", + "group": "test" + } + ] +} \ No newline at end of file From f12730b0be47aeb0e65cba3b9f3611793a1bda25 Mon Sep 17 00:00:00 2001 From: inabhani <81841709+inabhani@users.noreply.github.com> Date: Sat, 10 Apr 2021 17:22:03 +0400 Subject: [PATCH 107/107] Update launch.json --- .vscode/launch.json | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 57a4ec1..9ee856f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,80 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "Launch Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "args": [ + " + " + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "name": "Yeoman + ", + "program": "${workspaceFolder}/node_modules/yo/lib/cli.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, + + { + "name": "Attach", + "port": 9229, + "request": "attach", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, + { + "type": "java", + "name": "Launch with Arguments Prompt", + "request": "launch", + "mainClass": "", + "args": "${command:SpecifyProgramArgs}" + }, + { + "args": [ + "-u", + "tdd", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/test" + ], + "internalConsoleOptions": "openOnSessionStart", + "name": "Mocha Tests", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, + { + "name": "Launch Program", + "program": "${workspaceFolder}/app.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, + { + "name": "Launch Chrome", + "request": "launch", + "type": "pwa-chrome", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + }, + { "type": "java", "name": "Attach to Remote Program",