Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code #7

Open
wants to merge 73 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
4cb94d7
Magento 2 api v2 integration without webhooks
grumpy-dog Jan 10, 2020
53619ee
Deletion of redundant functionality, preparation for testing.
grumpy-dog Jan 15, 2020
9ae071f
Fix test data & api_host
grumpy-dog Jan 15, 2020
1c067f7
dev release
grumpy-dog Jan 15, 2020
3f23da5
fix api host
grumpy-dog Jan 15, 2020
0feb091
fix js
grumpy-dog Jan 16, 2020
4f8b269
Updated invoice binding to order
grumpy-dog Jan 31, 2020
4aedeec
Fix typo
grumpy-dog Feb 1, 2020
8f98049
Fix typo
grumpy-dog Feb 1, 2020
d91bc3b
Fix docs
grumpy-dog Feb 2, 2020
5a58626
Fix var names
grumpy-dog Feb 2, 2020
9e145c9
Fix API host
grumpy-dog Feb 2, 2020
c5a954a
Fix abstract access
grumpy-dog Feb 4, 2020
8e23f87
Fix webhook validation conditions
grumpy-dog Feb 4, 2020
4ea9b25
Update readme
grumpy-dog Feb 4, 2020
ec60076
Update transaction status
grumpy-dog Feb 11, 2020
097ad4a
Fix invoices statuses
grumpy-dog Feb 13, 2020
e7c06a1
Add invoice metadata
grumpy-dog Feb 13, 2020
e3516ba
Format module code
grumpy-dog Feb 13, 2020
eda2721
Update README.md
meyburgh Apr 24, 2020
6efd31a
Fix merchant invoice response
letscode-u Jul 14, 2020
2bc2b71
fix api host
letscode-u Aug 8, 2020
d9989ad
update api domain
letscode-u Sep 25, 2020
883e0a2
Unify the naming of configuration fields
letscode-u Sep 28, 2020
4a66116
Changing api-url on checkout - url
NastyaGos Oct 23, 2020
7ff3dde
Add hostname check to webhooks notifications
letscode-u Nov 9, 2020
ca6d621
Fix merchant invoice response
letscode-u Nov 9, 2020
9646b3f
Update redirect host
letscode-u Nov 9, 2020
0a3dd0c
Changing logo
NastyaGos Dec 8, 2020
d968f27
Merge remote-tracking branch 'alpha-prod/cps_api_v2' into cps_api_v2
letscode-u Dec 8, 2020
cf13153
Ignore .idea
letscode-u Dec 8, 2020
52df4c0
Merge remote-tracking branch 'alpha-prod/Gosudarskaya_alpha_coinpayme…
letscode-u Dec 8, 2020
ef60a52
webhook notification url unique for each user & event
letscode-u Jan 28, 2021
90d2ed5
Use order link as notesToRecipient
letscode-u Feb 10, 2021
534207e
add invoice info to order
letscode-u Feb 10, 2021
059bde0
Fix invoice buyer info
letscode-u Feb 16, 2021
18fd99f
Use Paid status to confirm payment
letscode-u Feb 16, 2021
fef67fe
Add SEO description
letscode-u Feb 16, 2021
30735c5
Fix php version compatibility
letscode-u Mar 22, 2021
e60fd09
Fix invoice buyer data
letscode-u Mar 22, 2021
76806cd
Revert "Fix php version compatibility"
letscode-u Mar 25, 2021
96e6205
Fix composer php requirements
letscode-u Mar 25, 2021
aa45472
Add notesToRecipient description
letscode-u Mar 25, 2021
e951273
Update webhook url formation
letscode-u Mar 25, 2021
12aaeed
Merge pull request #18 from CoinPaymentsNet/Alpha
letscode-u Apr 19, 2021
f197fe5
Revert "Alpha"
letscode-u Apr 19, 2021
96ffe54
Merge pull request #19 from CoinPaymentsNet/revert-18-Alpha
letscode-u Apr 19, 2021
2441d15
Fix invoice taxes & discount
letscode-u May 4, 2021
fdfa516
Merge branch 'master' of github.com-coinpayments:CoinPaymentsNet/coin…
letscode-u May 4, 2021
b07997e
allow php 8.1.11 to be used with composer
timzagelow Nov 30, 2022
fc4cde1
also allow 8.0 and 8.1, version bump
timzagelow Nov 30, 2022
01204f3
cleanup
timzagelow Nov 30, 2022
2cf7250
Merge pull request #21 from CoinPaymentsNet/add-php-8-to-composer
timzagelow Nov 30, 2022
b9cdec4
Trying to fix exception
smilesrg May 22, 2023
0a2e264
Merge pull request #22 from serhii-smirnov-cps/master
serhii-smirnov-cps May 30, 2023
c3441ce
Fixed issue with config when API is not responding
Mar 21, 2024
b2f3017
Update system.xml to add 'Sort Order' function
git-seb Mar 21, 2024
f4bcb79
Update composer.json to allow PHP 8.2 and new version number
git-seb Mar 21, 2024
6bc00fb
Merge pull request #26 from git-seb/patch-2
Crypto2 Mar 21, 2024
f6f0b1b
Merge pull request #25 from git-seb/patch-1
Crypto2 Mar 21, 2024
958c724
Merge pull request #24 from CoinPaymentsNet/fix-issue-with-config-whe…
Crypto2 Mar 21, 2024
75a9240
Update coin_payment_form.html
git-seb Apr 30, 2024
d0b1b06
Merge pull request #27 from git-seb/patch-3
Crypto2 Apr 30, 2024
04c49e4
Revert "Fix for better compatibility with other payment methods"
git-seb May 6, 2024
b5c0ce9
Merge pull request #28 from git-seb/revert-27-patch-3
Crypto2 May 6, 2024
9c931f4
Update coin_payment.html
git-seb Jun 6, 2024
07a100d
Update status.phtml
git-seb Jun 6, 2024
dfdbc1a
Update coin-method.js to fix error function
git-seb Jun 7, 2024
9caddba
Create csp_whitelist.xml
git-seb Jun 7, 2024
dc91d15
Merge pull request #38 from git-seb/patch-14
Crypto2 Jun 7, 2024
8f7535c
Merge pull request #30 from git-seb/patch-5
Crypto2 Jun 7, 2024
2baf54f
Merge pull request #37 from git-seb/patch-13
Crypto2 Jun 7, 2024
c462656
Merge pull request #36 from git-seb/patch-12
Crypto2 Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Model/Api/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public function sendRequest($data, $cmd, $headers = [], $method = 'post', $assoc
{
$paymentConf = $this->getPaymentConfig();
$baseConf = $this->getBaseConfig();

$paymentConf['public_key'] = isset($paymentConf['public_key']) ? $paymentConf['public_key'] : '';
$paymentConf['api_version'] = isset($paymentConf['api_version']) ? $paymentConf['api_version'] : '1';

$additionalData = [
'version' => $baseConf['api_version'],
'cmd' => $cmd,
Expand All @@ -112,7 +112,7 @@ public function sendRequest($data, $cmd, $headers = [], $method = 'post', $assoc
public function generateHmac($data, $secretKey = null)
{
if (!$secretKey) {
$secretKey = $this->getPaymentConfig('secret_key');
$secretKey = $this->getPaymentConfig('secret_key') ?: '';
}
return hash_hmac('sha512', http_build_query($data), $secretKey);
}
Expand Down
33 changes: 19 additions & 14 deletions Model/CoinPaymentsConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,27 @@ public function getConfig()
$this->_curl->post($coinpaymentsApi, $data);
$response = json_decode($this->_curl->getBody());

$currencies = ['error' => $response->error];
$acceptedCurrencies = ['error' => $response->error];
if ($response->error == 'ok') {
$currencies = [];
$acceptedCurrencies = [];
foreach ($response->result as $key => $item) {
$elm = [
'value' => $key,
'body' => $item,
'name' => $item->name
];
$currencies[] = $elm;
if (isset($item->accepted) && $item->accepted == '1') {
$acceptedCurrencies[] = $elm;
if (!is_null($response) && property_exists($response, 'error') && property_exists($response, 'result')) {
$currencies = ['error' => $response->error];
$acceptedCurrencies = ['error' => $response->error];
if ($response->error == 'ok') {
$currencies = [];
$acceptedCurrencies = [];
foreach ($response->result as $key => $item) {
$elm = [
'value' => $key,
'body' => $item,
'name' => $item->name
];
$currencies[] = $elm;
if (isset($item->accepted) && $item->accepted == '1') {
$acceptedCurrencies[] = $elm;
}
}
}
} else {
$currencies = ['error' => 'Could not load currencies list.'];
$acceptedCurrencies = ['error' => 'Could not load currencies list.'];
}

return [
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "coinpaymentsnet/magento2",
"description": "Add new payment method for CoinPayments.net",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1"
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1|~8.0|~8.1|~8.2"
},
"type": "magento2-module",
"version": "1.6.0",
"version": "1.6.3",
"license": [
"OSL-3.0"
],
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
Expand Down
10 changes: 10 additions & 0 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="img-src">
<values>
<value id="coinpayments" type="host">https://www.coinpayments.net</value>
</values>
</policy>
</policies>
</csp_whitelist>
6 changes: 3 additions & 3 deletions view/frontend/templates/coinpayments/iframe.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ $failUrl = $block->getFailUrl();
'utf-8'
); ?>">
<input type="hidden" name="shippingf" value="<?php echo $block->getShippingAmount(); ?>">
<input type="hidden" name="taxf" value="<?php $quoteData->getShippingAddress()->getTaxAmount(); ?>">
<input type="hidden" name="amountf" value="<?php echo $quoteData->getSubtotal(); ?>">
<input type="hidden" name="taxf" value="<?php echo $quoteData->getShippingAddress()->getTaxAmount(); ?>">
<input type="hidden" name="amountf" value="<?php echo $quoteData->getSubtotalWithDiscount(); ?>">
<input type="hidden" name="success_url" value="<?php echo $successUrl; ?>">
<input type="hidden" name="cancel_url" value="<?php echo $failUrl; ?>">
<input type="hidden" name="ipn_url" value="<?php echo htmlspecialchars($block->getIpnUrl(), ENT_QUOTES, 'utf-8'); ?>">
Expand All @@ -50,4 +50,4 @@ $failUrl = $block->getFailUrl();
</form>
<script type="text/javascript">
document.coinpaymentsform.submit();
</script>
</script>
4 changes: 2 additions & 2 deletions view/frontend/templates/coinpayments/status.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ $currency = $block->getTransactionCurrency();
?>

<div class="checkout-success">
<p>Your order # is: <span><?php echo $block->getLastOrderIncrementId(); ?></span>.</p>
<p>We'll email you an order confirmation with details and tracking info.</p>
<p><?php echo __('Your order # is'); ?> <span><?php echo $block->getLastOrderIncrementId(); ?></span>.</p>
<p><?php echo __('Please scan the QR code below to make your payment using cryptocurrency. Once your payment has been confirmed your order will be processed.'); ?></p>
<?php if ($transactionData->error == 'ok') : ?>
<h3><a href="<?php echo $transactionData->result->status_url; ?>" target="_blank">Status link</a></h3>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ define(
window.location.replace(redirect);
}
},
error: function (err) {
error: function (error) {
console.log(error);
if (redirect) {
window.location.replace(redirect);
Expand Down
6 changes: 3 additions & 3 deletions view/frontend/web/template/payment/coin_payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!--/ko-->
<div class="payment-method-note">
<span data-bind="ifnot: getIsDirect()">
            <!-- ko template: 'Coinpayments_CoinPayments/payment/coin_payment_message' --><!-- /ko -->
<!-- ko template: 'Coinpayments_CoinPayments/payment/coin_payment_message' --><!-- /ko -->
</span>
<form
class="form"
Expand All @@ -32,7 +32,7 @@
method="post"
data-bind="if: getIsDirect()"
>
            <!-- ko template: 'Coinpayments_CoinPayments/payment/coin_payment_form' --><!-- /ko -->     
<!-- ko template: 'Coinpayments_CoinPayments/payment/coin_payment_form' --><!-- /ko -->
</form>
</div>
<div class="checkout-agreements-block">
Expand All @@ -55,4 +55,4 @@
</div>
</div>
</div>
</div>
</div>