Skip to content

Commit

Permalink
Merge pull request #40 from Snickser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Snickser authored Jul 21, 2024
2 parents 982c92a + 295da63 commit 94fbe02
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 76 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## CryptoCloud payment gateway plugin for Moodle.

v0.11
v0.12

https://cryptocloud.plus/

Expand Down
28 changes: 25 additions & 3 deletions classes/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ public static function add_configuration_to_gateway_form(\core_payment\form\acco

$mform->addElement('text', 'shopid', get_string('shopid', 'paygw_cryptocloud'));
$mform->setType('shopid', PARAM_TEXT);
$mform->addRule('shopid', get_string('required'), 'required', null, 'client');

$mform->addElement('text', 'apikey', get_string('apikey', 'paygw_cryptocloud'), ['size' => 48]);
$mform->addElement('text', 'apikey', get_string('apikey', 'paygw_cryptocloud'), ['size' => 50]);
$mform->setType('apikey', PARAM_TEXT);
$mform->addRule('apikey', get_string('required'), 'required', null, 'client');

$mform->addElement('text', 'secretkey', get_string('secretkey', 'paygw_cryptocloud'), ['size' => 48]);
$mform->addElement('text', 'secretkey', get_string('secretkey', 'paygw_cryptocloud'), ['size' => 50]);
$mform->setType('secretkey', PARAM_TEXT);
$mform->addRule('secretkey', get_string('required'), 'required', null, 'client');

$options = [
'USDT_TRC20' => 'USDT_TRC20',
Expand Down Expand Up @@ -124,19 +127,38 @@ public static function add_configuration_to_gateway_form(\core_payment\form\acco
);
$mform->setType('showduration', PARAM_INT);

$mform->addElement(
'advcheckbox',
'fixcost',
get_string('fixcost', 'paygw_cryptocloud'),
get_string('fixcost', 'paygw_cryptocloud')
);
$mform->setType('fixcost', PARAM_INT);
$mform->addHelpButton('fixcost', 'fixcost', 'paygw_cryptocloud');

$mform->addElement('text', 'suggest', get_string('suggest', 'paygw_cryptocloud'), ['size' => 10]);
$mform->setType('suggest', PARAM_TEXT);
$mform->disabledIf('suggest', 'fixcost', "neq", 0);

$mform->addElement('text', 'maxcost', get_string('maxcost', 'paygw_cryptocloud'), ['size' => 10]);
$mform->setType('maxcost', PARAM_TEXT);
$mform->disabledIf('maxcost', 'fixcost', "neq", 0);

global $CFG;
$mform->addElement('html', '<div class="label-callback" style="background: #F2EFE6; padding: 15px;">' .
$mform->addElement('html', '<div class="label-callback" style="background: pink; padding: 15px;">' .
get_string('callback_url', 'paygw_cryptocloud') . '<br>');
$mform->addElement('html', $CFG->wwwroot . '/payment/gateway/cryptocloud/callback.php<br>');
$mform->addElement('html', get_string('return_url', 'paygw_cryptocloud') . '<br>');
$mform->addElement('html', $CFG->wwwroot . '/payment/gateway/cryptocloud/return.php<br>');
$mform->addElement('html', get_string('callback_help', 'paygw_cryptocloud') . '</div><br>');

$header = '<div>Новые версии плагина вы можете найти на
<a href=https://github.com/Snickser/moodle-paygw_cryptocloud>GitHub.com</a><br>
Пожалуйста, отправьте мне немножко <a href="https://yoomoney.ru/fundraise/143H2JO3LLE.240720">доната</a>😊</div>
<iframe src="https://yoomoney.ru/quickpay/fundraise/button?billNumber=143H2JO3LLE.240720"
width="330" height="50" frameborder="0" allowtransparency="true" scrolling="no"></iframe>';
$mform->addElement('html', $header);

}

/**
Expand Down
81 changes: 42 additions & 39 deletions lang/en/paygw_cryptocloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,59 @@
* @copyright 2024 Alex Orlov <snickser@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'CryptoCloud payment';
$string['pluginname_desc'] = 'The cryptocloud plugin allows you to receive payments via CryptoCloud.';
$string['abouttopay'] = 'You are about to pay for';
$string['apikey'] = 'API Key';
$string['callback_help'] = 'Copy this lines and paste it into the cryptocloud project settings. Switch off "My project on CMS".';
$string['callback_url'] = 'Notification URL:';
$string['cryptocurrency'] = 'Allowed cryptocurrency';
$string['fixdesc'] = 'Fixed payment comment';
$string['fixdesc_help'] = 'This setting sets a fixed comment for all payments.';
$string['gatewaydescription'] = 'CryptoCloud — a reliable way to easily and conveniently accept payments from around the world in the most popular cryptocurrencies.';
$string['gatewayname'] = 'CryptoCloud';
$string['callback_url'] = 'Notification URL:';
$string['callback_help'] = 'Copy this lines and paste it into the cryptocloud project settings. Switch off "My project on CMS".';
$string['return_url'] = 'SuccessURL and FailURL:';
$string['payment_success'] = 'Payment Successful';
$string['payment_error'] = 'Payment Error';
$string['password_success'] = 'Paymemt password accepted';
$string['password_error'] = 'Invalid payment password';
$string['paymore'] = 'If you want to donate more, simply enter your amount instead of the indicated amount.';
$string['sendpaymentbutton'] = 'Send payment via cryptocloud!';
$string['skippaymentbutton'] = 'Skip payment :(';
$string['abouttopay'] = 'You are about to pay for';
$string['payment'] = 'Donation';
$string['internalerror'] = 'An internal error has occurred. Please contact us.';
$string['istestmode'] = 'Test mode';
$string['maxcost'] = 'Maximium cost';
$string['message_success_completed'] = 'Hello {$a->firstname},
You transaction of payment id {$a->orderid} with cost of {$a->fee} {$a->currency} is successfully completed.
If the item is not accessable please contact the administrator.';
$string['messageprovider:payment_receipt'] = 'Payment receipt';
$string['messagesubject'] = 'Payment notification';
$string['password'] = 'Password';
$string['passwordmode'] = 'Password';
$string['password_error'] = 'Invalid payment password';
$string['password_help'] = 'Using this password you can bypass the payback process. It can be useful when it is not possible to make a payment.';
$string['password_success'] = 'Paymemt password accepted';
$string['password_text'] = 'If you are unable to make a payment, then ask your curator for a password and enter it.';
$string['apikey'] = 'API Key';
$string['passwordmode'] = 'Password';
$string['payment'] = 'Donation';
$string['payment_error'] = 'Payment Error';
$string['payment_success'] = 'Payment Successful';
$string['paymore'] = 'If you want to donate more, simply enter your amount instead of the indicated amount.';
$string['pluginname'] = 'CryptoCloud payment';
$string['pluginname_desc'] = 'The cryptocloud plugin allows you to receive payments via CryptoCloud.';
$string['privacy:metadata'] = 'The cryptocloud plugin store some personal data.';
$string['privacy:metadata:paygw_cryptocloud:apikey'] = 'ApiKey';
$string['privacy:metadata:paygw_cryptocloud:courceid'] = 'Cource id';
$string['privacy:metadata:paygw_cryptocloud:cryptocloud_plus'] = 'Send json data';
$string['privacy:metadata:paygw_cryptocloud:email'] = 'Email';
$string['privacy:metadata:paygw_cryptocloud:groupnames'] = 'Group names';
$string['privacy:metadata:paygw_cryptocloud:invoiceid'] = 'Invoice id';
$string['privacy:metadata:paygw_cryptocloud:paygw_cryptocloud'] = 'Store some data';
$string['privacy:metadata:paygw_cryptocloud:shopid'] = 'Shopid';
$string['privacy:metadata:paygw_cryptocloud:success'] = 'Status';
$string['return_url'] = 'SuccessURL and FailURL:';
$string['secretkey'] = 'Secret key';
$string['sendpaymentbutton'] = 'Send payment via cryptocloud!';
$string['shopid'] = 'ShopID';
$string['istestmode'] = 'Test mode';
$string['suggest'] = 'Suggested cost';
$string['maxcost'] = 'Maximium cost';
$string['showduration'] = 'Show duration of training';
$string['skipmode'] = 'Can skip payment';
$string['skipmode_help'] = 'This setting allows a payment bypass button, which can be useful in public courses with optional payment.';
$string['skipmode_text'] = 'If you are not able to make a donation through the payment system, you can click on this button.';
$string['fixdesc'] = 'Fixed payment comment';
$string['fixdesc_help'] = 'This setting sets a fixed comment for all payments.';
$string['showduration'] = 'Show duration of training';
$string['skippaymentbutton'] = 'Skip payment :(';
$string['suggest'] = 'Suggested cost';
$string['usedetails'] = 'Make it collapsible';
$string['usedetails_help'] = 'Display a button or password in a collapsed block.';
$string['usedetails_text'] = 'Click here if you are unable to donate.';
$string['internalerror'] = 'An internal error has occurred. Please contact us.';

$string['privacy:metadata'] = 'The cryptocloud plugin store some personal data.';
$string['privacy:metadata:paygw_cryptocloud:paygw_cryptocloud'] = 'Store some data';
$string['privacy:metadata:paygw_cryptocloud:shopid'] = 'Shopid';
$string['privacy:metadata:paygw_cryptocloud:apikey'] = 'ApiKey';
$string['privacy:metadata:paygw_cryptocloud:email'] = 'Email';
$string['privacy:metadata:paygw_cryptocloud:cryptocloud_plus'] = 'Send json data';
$string['privacy:metadata:paygw_cryptocloud:invoiceid'] = 'Invoice id';
$string['privacy:metadata:paygw_cryptocloud:courceid'] = 'Cource id';
$string['privacy:metadata:paygw_cryptocloud:groupnames'] = 'Group names';
$string['privacy:metadata:paygw_cryptocloud:success'] = 'Status';

$string['messagesubject'] = 'Payment notification';
$string['message_success_completed'] = 'Hello {$a->firstname},
You transaction of payment id {$a->orderid} with cost of {$a->fee} {$a->currency} is successfully completed.
If the item is not accessable please contact the administrator.';
$string['messageprovider:payment_receipt'] = 'Payment receipt';
$string['fixcost'] = 'Fixed price mode';
$string['fixcost_help'] = 'Disables the ability for students to pay with an arbitrary amount.';
$string['maxcosterror'] = 'The maximum price must be higher than the recommended price';
51 changes: 28 additions & 23 deletions lang/ru/paygw_cryptocloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,45 @@

defined('MOODLE_INTERNAL') || die();

$string['sendpaymentbutton'] = 'Пожертвовать!';
$string['skippaymentbutton'] = 'Не имею :(';
$string['paymore'] = 'Если вы хотите пожертвовать больше, то просто впишите свою сумму вместо указанной.';
$string['payment'] = 'Пожертвование';
$string['abouttopay'] = 'Вы собираетесь пожертвовать на';
$string['pluginname'] = 'Платежи CryptoCloud';
$string['pluginname_desc'] = 'Плагин cryptocloud позволяет получать платежи через CryptoCloud.';
$string['gatewaydescription'] = 'CryptoCloud — надежный способ легко и удобно принимать оплату со всего мира в самых популярных криптовалютах.';
$string['apikey'] = 'API Key';
$string['callback_help'] = 'Скопируйте эти строки и вставьте в настройках проекта в CryptoCloud. Отключите настройку "Мой проект на CMS".';
$string['callback_url'] = 'URL для уведомлений:';
$string['cost'] = 'Стоимость записи';
$string['cryptocurrency'] = 'Разрешенные валюты';
$string['currency'] = 'Валюта';
$string['paymentserver'] = 'URL сервера оплаты';
$string['fixdesc'] = 'Фиксированный комментарий платежа';
$string['fixdesc_help'] = 'Эта настройка устанавливает фиксированный комментарий для всех платежей, и отключает отображение описания комментария на странице платежа.';
$string['gatewaydescription'] = 'CryptoCloud — надежный способ легко и удобно принимать оплату со всего мира в самых популярных криптовалютах.';
$string['istestmode'] = 'Тестовый режим';
$string['maxcost'] = 'Максимальная цена';
$string['password'] = 'Резервный пароль';
$string['passwordmode'] = 'Разрешить ввод резервного пароля';
$string['password_error'] = 'Введён неверный платёжный пароль';
$string['password_help'] = 'С помощью этого пароля можно обойти процесс отплаты. Может быть полезен когда нет возможности произвести оплату.';
$string['password_success'] = 'Платёжный пароль принят';
$string['password_text'] = 'Если у вас нет возможности сделать пожертвование, то попросите у вашего куратора пароль и введите его.';
$string['apikey'] = 'API Key';
$string['passwordmode'] = 'Разрешить ввод резервного пароля';
$string['payment'] = 'Пожертвование';
$string['payment_error'] = 'Ошибка оплаты';
$string['payment_success'] = 'Оплата успешно произведена';
$string['paymentserver'] = 'URL сервера оплаты';
$string['paymore'] = 'Если вы хотите пожертвовать больше, то просто впишите свою сумму вместо указанной.';
$string['pluginname'] = 'Платежи CryptoCloud';
$string['pluginname_desc'] = 'Плагин cryptocloud позволяет получать платежи через CryptoCloud.';
$string['return_url'] = 'SuccessURL и FailURL:';
$string['secretkey'] = 'Secret key';
$string['sendpaymentbutton'] = 'Пожертвовать!';
$string['shopid'] = 'Идентификатор проекта';
$string['istestmode'] = 'Тестовый режим';
$string['callback_url'] = 'URL для уведомлений:';
$string['callback_help'] = 'Скопируйте эти строки и вставьте в настройках проекта в CryptoCloud. Отключите настройку "Мой проект на CMS".';
$string['return_url'] = 'SuccessURL и FailURL:';
$string['payment_success'] = 'Оплата успешно произведена';
$string['payment_error'] = 'Ошибка оплаты';
$string['suggest'] = 'Рекомендуемая цена';
$string['password_success'] = 'Платёжный пароль принят';
$string['password_error'] = 'Введён неверный платёжный пароль';
$string['maxcost'] = 'Максимальная цена';
$string['showduration'] = 'Показывать длительность обучения на странице';
$string['skipmode'] = 'Показать кнопку обхода платежа';
$string['skipmode_help'] = 'Эта настройка разрешает кнопку обхода платежа, может быть полезна в публичных курсах с необязательной оплатой.';
$string['skipmode_text'] = 'Если вы не имеете возможности совершить пожертвование через платёжную систему то можете нажать на эту кнопку.';
$string['fixdesc'] = 'Фиксированный комментарий платежа';
$string['fixdesc_help'] = 'Эта настройка устанавливает фиксированный комментарий для всех платежей, и отключает отображение описания комментария на странице платежа.';
$string['showduration'] = 'Показывать длительность обучения на странице';
$string['skippaymentbutton'] = 'Не имею :(';
$string['suggest'] = 'Рекомендуемая цена';
$string['usedetails'] = 'Показывать свёрнутым';
$string['usedetails_help'] = 'Прячет кнопку или пароль под сворачиваемый блок, если они включены.';
$string['usedetails_text'] = 'Нажмите тут если у вас нет возможности совершить пожертвование';

$string['fixcost'] = 'Режим фиксированной цены';
$string['fixcost_help'] = 'Отключает для студентов возможность оплаты произвольной суммой.';
$string['maxcosterror'] = 'Максимальная цена должна быть выше рекомендуемой цены';
14 changes: 9 additions & 5 deletions method.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,20 @@
}

$templatedata->passwordmode = $config->passwordmode;
$templatedata->maxcost = $config->maxcost;

if ($config->suggest < $fee) {
$templatedata->suggest = $fee;
$templatedata->fixcost = $config->fixcost;
if (!$config->fixcost) {
if ($config->suggest < $fee) {
$templatedata->suggest = $fee;
} else {
$templatedata->suggest = $config->suggest;
}
} else {
$templatedata->suggest = $config->suggest;
$templatedata->localizedcost = \core_payment\helper::get_cost_as_string($fee, $currency);
}

$templatedata->maxcost = $config->maxcost;
$templatedata->skipmode = $config->skipmode;

if ($config->skipmode || $config->passwordmode) {
$templatedata->usedetails = $config->usedetails;
}
Expand Down
12 changes: 9 additions & 3 deletions templates/method.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"skipmode": "1",
"suggested": "100",
"maxcost": "1000",
"fixdesc": "1"
"fixdesc": "1",
"fixcost": "0",
"localizedcost": "1 $"
}

}}
Expand All @@ -50,9 +52,13 @@
<p>{{# str }} paymore, paygw_cryptocloud {{/ str}}</p>

<h3>{{# str }} cost {{/ str}}:
<input type="number" id="costself" name="costself" min="{{fee}}" {{#maxcost}}max="{{maxcost}}"{{/maxcost}}
{{^fixcost}}
<input type="number" id="costself" name="costself"
value="{{#suggest}}{{suggest}}{{/suggest}}{{^suggest}}{{fee}}{{/suggest}}"
step="0.01" style="width: 5em;">&nbsp;{{currency}}
min="{{fee}}" {{#maxcost}}max="{{maxcost}}"{{/maxcost}} step="0.01"
style="width: 5em;">{{^fixcost}}&nbsp;{{currency}}{{/fixcost}}
{{/fixcost}}
{{#fixcost}}{{localizedcost}}{{/fixcost}}
</h3>

{{#enrolperiod}}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024051600;
$plugin->version = 2024072100;
$plugin->requires = 2023100900;
$plugin->component = 'paygw_cryptocloud';
$plugin->release = '0.11';
$plugin->release = '0.12';
$plugin->maturity = MATURITY_STABLE;

0 comments on commit 94fbe02

Please sign in to comment.