-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
435f461
commit 9eef93a
Showing
31 changed files
with
2,131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BeycanPress\CryptoPay\Forminator; | ||
|
||
// phpcs:disable PSR1.Methods.CamelCapsMethodName | ||
// phpcs:disable Squiz.NamingConventions.ValidVariableName | ||
// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore | ||
// phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint | ||
// phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint | ||
|
||
class Field extends \Forminator_Field | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $name = 'CryptoPay'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $slug = 'cryptopay'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $type = 'cryptopay'; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public $position = 24; | ||
|
||
/** | ||
* @var array<mixed> | ||
*/ | ||
public $options = []; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $category = 'standard'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $icon = 'sui-icon cryptopay-icon'; | ||
|
||
/** | ||
* @var array<mixed> | ||
*/ | ||
public $field; | ||
|
||
/** | ||
* @var array<mixed> | ||
*/ | ||
public $form_settings; | ||
|
||
|
||
/** | ||
* Gateway constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
add_action('admin_enqueue_scripts', [$this, 'adminScripts']); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function adminScripts(): void | ||
{ | ||
wp_enqueue_style( | ||
'forminator-cryptopay', | ||
FORMINATOR_CRYPTOPAY_URL . 'assets/css/main.css', | ||
[], | ||
FORMINATOR_CRYPTOPAY_VERSION | ||
); | ||
|
||
wp_enqueue_script( | ||
'forminator-cryptopay', | ||
FORMINATOR_CRYPTOPAY_URL . 'assets/js/admin.js', | ||
[], | ||
FORMINATOR_CRYPTOPAY_VERSION, | ||
true | ||
); | ||
} | ||
|
||
/** | ||
* @return array<mixed> | ||
*/ | ||
public function defaults(): array | ||
{ | ||
$currency = 'USD'; | ||
try { | ||
// gateway | ||
} catch (\Exception $e) { | ||
forminator_maybe_log(__METHOD__, $e->getMessage()); | ||
} | ||
|
||
return [ | ||
'currency' => $currency, | ||
'amount_type' => 'fixed', | ||
'options' => [] | ||
]; | ||
} | ||
|
||
/** | ||
* Front-end markup | ||
* @param array<mixed> $field | ||
* @param \Forminator_Render_Form $views_obj Forminator_Render_Form object. | ||
* @return string | ||
*/ | ||
public function markup($field, $views_obj): string | ||
{ | ||
|
||
$this->field = $field; | ||
$this->form_settings = $views_obj->model->settings; | ||
|
||
$elementName = self::get_property('element_id', $field); | ||
$fieldId = $elementName . '-field'; | ||
$amount = self::get_property('amount', $field, '0'); | ||
$amountVariable = self::get_property('variable', $field, ''); | ||
$amountType = self::get_property('amount_type', $field, 'fixed'); | ||
$currency = self::get_property('currency', $field, $this->getDefaultCurrency()); | ||
|
||
$attr = [ | ||
'type' => 'hidden', | ||
'name' => $elementName, | ||
'id' => 'forminator-' . $fieldId, | ||
'class' => 'forminator-cryptopay-input', | ||
'data-is-payment' => 'true', | ||
'data-payment-type' => $this->type, | ||
'data-amount-type' => esc_html($amountType), | ||
'data-currency' => esc_html(strtolower($currency)), | ||
'data-amount' => ('fixed' === $amountType ? esc_html($amount) : $amountVariable), | ||
]; | ||
|
||
$html = self::create_input($attr); | ||
|
||
return apply_filters('forminator_field_cryptopay_markup', $html, $attr, $field); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDefaultCurrency(): string | ||
{ | ||
return 'USD'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BeycanPress\CryptoPay\Forminator; | ||
|
||
class Gateway extends \Forminator_Payment_Gateway | ||
{ | ||
/** | ||
* Gateway constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.cryptopay-icon { | ||
content: url(../images/icon.svg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
;(() => { | ||
})() |
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
// autoload.php @generated by Composer | ||
|
||
if (PHP_VERSION_ID < 50600) { | ||
if (!headers_sent()) { | ||
header('HTTP/1.1 500 Internal Server Error'); | ||
} | ||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; | ||
if (!ini_get('display_errors')) { | ||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { | ||
fwrite(STDERR, $err); | ||
} elseif (!headers_sent()) { | ||
echo $err; | ||
} | ||
} | ||
trigger_error( | ||
$err, | ||
E_USER_ERROR | ||
); | ||
} | ||
|
||
require_once __DIR__ . '/composer/autoload_real.php'; | ||
|
||
return ComposerAutoloaderInitb035a5ad621c56f0f4eca9f034b92c9e::getLoader(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CryptoPay Integrator Wrapper | ||
|
||
```bash | ||
composer require beycanpress/cryptopay-integrator | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "beycanpress/cryptopay-integrator", | ||
"version": "0.1.10", | ||
"description": "CryptoPay and CryptoPay Lite integration wrapper", | ||
"type": "library", | ||
"license": "MIT", | ||
"author": "BeycanPress", | ||
"support": { | ||
"issues": "https://github.com/BeycanPress/cryptopay-integrator/issues" | ||
}, | ||
"homepage": "https://github.com/BeycanPress/cryptopay-integrator", | ||
"require": { | ||
"php": ">=8.1" | ||
}, | ||
"scripts": { | ||
"phpcs": "phpcs --standard=phpcs.xml .", | ||
"phpcbf": "phpcbf --standard=phpcs.xml .", | ||
"install-phpcs": "composer config --global --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true && composer global require --dev squizlabs/php_codesniffer=* slevomat/coding-standard" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"BeycanPress\\CryptoPay\\Integrator\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="BeycanPressStandard"> | ||
<rule ref="PSR12"/> | ||
<description> | ||
BeycanPressStandard | ||
</description> | ||
<file>./**/*.php</file> | ||
<exclude-pattern>*/views/*</exclude-pattern> | ||
<arg name="extensions" value="php"/> | ||
<arg name="standard" value="PSR12"/> | ||
<rule ref="Generic.Files.InlineHTML"/> | ||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.Missing"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.MissingParamName"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/> | ||
<rule ref="Squiz.Commenting.FunctionComment.MissingReturn"/> | ||
<rule ref="Squiz.NamingConventions.ValidVariableName"/> | ||
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"> | ||
<severity>0</severity> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/> | ||
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectStrictTypesFormat" /> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation" /> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" /> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation" /> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/> | ||
<rule ref="SlevomatCodingStandard.Commenting.AnnotationName"/> | ||
</ruleset> |
Oops, something went wrong.