Skip to content

Commit

Permalink
updated integrator
Browse files Browse the repository at this point in the history
  • Loading branch information
BeycanDeveloper committed Mar 22, 2024
1 parent db2b3cd commit 5cfd28c
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 50 deletions.
8 changes: 6 additions & 2 deletions app/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ protected function __construct(string $sectionClass)
*/
public function cpPaymentFinished(object $data): object
{
if (!$this->getStatus()) {
return $data;
}

$user = new \WP_User($data->getUserId());
$metadata = $data->getParams()->get('metadata');
$product = Product::find(absint($metadata->post_id));
Expand All @@ -75,9 +79,9 @@ public function cpPaymentFinished(object $data): object

foreach ($accessUpdates as $productId => $update) {
if ($update) {
$this->log_info('User enrolling into Product[' . $productId . '] success.');
$this->log_info('User enrolling into Product[' . esc_html($productId) . '] success.');
} else {
$this->log_info('User enrolling into Product[' . $productId . '] failed.');
$this->log_info('User enrolling into Product[' . esc_html($productId) . '] failed.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Gateways/GatewayLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function start(Product $product): void
$cp = (new Payment('learndash'))->modal();

add_action('wp_footer', function () use ($cp): void {
echo $cp;
Helpers::ksesEcho($cp);
});
}

Expand Down
2 changes: 1 addition & 1 deletion app/Gateways/GatewayPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function start(Product $product): void
$cp = (new Payment('learndash'))->modal();

add_action('wp_footer', function () use ($cp): void {
echo $cp;
Helpers::ksesEcho($cp);
});
}

Expand Down
1 change: 0 additions & 1 deletion assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
}
},
error: (error) => {
console.log(error);
if (error?.response?.data?.msg) {
helpers.errorPopup(error.response.data.msg);
} else {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
}
},
"require": {
"beycanpress/cryptopay-integrator": "^0.1.8"
"beycanpress/cryptopay-integrator": "^0.1.10"
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions learndash-lms-cryptopay-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,13 @@ function learndash_cryptopay_addModels(): void
load_plugin_textdomain('ldlms-cryptopay', false, basename(__DIR__) . '/languages');

if (!defined('LEARNDASH_VERSION')) {
add_action('admin_notices', function (): void {
?>
<div class="notice notice-error">
<p><?php echo sprintf(esc_html__('LearnDash LMS - CryptoPay Gateway: This plugin requires LearnDash LMS to work. You can buy LearnDash LMS by %s.', 'ldlms-cryptopay'), '<a href="https://www.learndash.com/" target="_blank">' . esc_html__('clicking here', 'ldlms-cryptopay') . '</a>'); ?></p>
</div>
<?php
});
Helpers::requirePluginMessage('LearnDash LMS', 'https://www.learndash.com/', false);
return;
}

if (Helpers::bothExists()) {
new BeycanPress\CryptoPay\LearnDash\Initialize();
} else {
add_action('admin_notices', function (): void {
?>
<div class="notice notice-error">
<p><?php echo sprintf(esc_html__('LearnDash LMS - CryptoPay Gateway: This plugin is an extra feature plugin so it cannot do anything on its own. It needs CryptoPay to work. You can buy CryptoPay by %s.', 'ldlms-cryptopay'), '<a href="https://beycanpress.com/product/cryptopay-all-in-one-cryptocurrency-payments-for-wordpress/?utm_source=wp_org_addons&utm_medium=learndash_lms" target="_blank">' . esc_html__('clicking here', 'ldlms-cryptopay') . '</a>'); ?></p>
</div>
<?php
});
Helpers::requireCryptoPayMessage('LearnDash LMS');
}
});
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit6be0de7c2c544c6b51cbdeae0bbe23be::getLoader();
return ComposerAutoloaderInitd790c17a0fbe6d9c27793420cf646a1f::getLoader();
2 changes: 1 addition & 1 deletion vendor/beycanpress/cryptopay-integrator/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beycanpress/cryptopay-integrator",
"version": "0.1.8",
"version": "0.1.10",
"description": "CryptoPay and CryptoPay Lite integration wrapper",
"type": "library",
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions vendor/beycanpress/cryptopay-integrator/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<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" />
Expand Down
35 changes: 35 additions & 0 deletions vendor/beycanpress/cryptopay-integrator/src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ public static function response(string $method, ...$args): mixed
}
}

/**
* @param string $currentPlugin
* @param string $pluginLink
* @param bool $download
* @return void
*/
public static function requirePluginMessage(string $currentPlugin, string $pluginLink, bool $download = true): void
{
add_action('admin_notices', function () use ($currentPlugin, $pluginLink, $download): void {
require dirname(__DIR__) . '/views/message-1.php';
});
}

/**
* @param string $currentPlugin
* @return void
*/
public static function requireCryptoPayMessage(string $currentPlugin): void
{
add_action('admin_notices', function () use ($currentPlugin): void {
require dirname(__DIR__) . '/views/message-2.php';
});
}

/**
* @param array<mixed> $data
* @return string
Expand Down Expand Up @@ -181,6 +205,17 @@ public static function createSPP(array $data): string
return home_url("/?cp_spp={$token}");
}

/**
* @param string $url
* @return string|null
*/
public static function getSPPToken(string $url): ?string
{
/** @var array<mixed> $matches */
preg_match('/[?&]cp_spp=([^&]+)/', $url, $matches);
return isset($matches[1]) ? $matches[1] : null;
}

/**
* @return void
*/
Expand Down
4 changes: 3 additions & 1 deletion vendor/beycanpress/cryptopay-integrator/src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public static function has(string $key): bool
public static function remove(string $key): void
{
self::start();
unset($_SESSION['cp_integrator'][$key]);
if (self::has($key)) {
unset($_SESSION['cp_integrator'][$key]);
}
}

/**
Expand Down
19 changes: 19 additions & 0 deletions vendor/beycanpress/cryptopay-integrator/views/message-1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="notice notice-error">
<p>
<?php echo wp_kses_post(
str_replace(
'{name}',
esc_html($currentPlugin),
sprintf(
esc_html__('{name} - CryptoPay Gateway: This plugin requires {name} to work. You can %s {name} by %s.', 'arm-cryptopay'),
$download ? esc_html__('download', 'cryptopay') : esc_html__('buy', 'cryptopay'),
sprintf(
'<a href="%s" target="_blank">' . esc_html__('clicking here', 'cryptopay') . '</a>',
$pluginLink
)
)
),
['a' => ['href' => [], 'target' => []]]
); ?>
</p>
</div>
16 changes: 16 additions & 0 deletions vendor/beycanpress/cryptopay-integrator/views/message-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

<div class="notice notice-error">
<p>
<?php echo wp_kses_post(
sprintf(
esc_html__('%s - CryptoPay Gateway: This plugin is an integration plugin so it cannot do anything on its own. It needs CryptoPay to work. You can buy CryptoPay by %s.', 'cryptopay'),
esc_html($currentPlugin),
sprintf(
'<a href="https://beycanpress.com/product/cryptopay-all-in-one-cryptocurrency-payments-for-wordpress/?utm_source=wp_org_addons&utm_medium=%s" target="_blank">' . esc_html__('clicking here', 'cryptopay') . '</a>',
esc_html($currentPlugin)
)
),
['a' => ['href' => [], 'target' => []]]
); ?>
</p>
</div>
23 changes: 23 additions & 0 deletions vendor/beycanpress/cryptopay-integrator/views/pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,26 @@
border-radius: 5px;
}

.go-to-back {
text-align: center;
margin: 20px 0;
}

.go-to-back a {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: #fff;
text-decoration: none;
border-radius: 5px;
}

@media screen and (max-width: 768px) {
body {
padding: 0 20px;
text-align: center;
}

.container {
flex-direction: column;
}
Expand All @@ -59,6 +78,7 @@
margin-right: 0;
margin-bottom: 20px;
max-width: 100%;
width: 100%;
}
}
</style>
Expand All @@ -84,6 +104,9 @@
<?php echo $cryptopay; ?>
</div>
</div>
<div class="go-to-back">
<a href="<?php echo esc_url($_SERVER["HTTP_REFERER"]) ?>"><?php echo esc_html__('Go back to add-on page') ?></a>
</div>
<?php do_action('wp_print_footer_scripts'); ?>
</body>
</html>
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit6be0de7c2c544c6b51cbdeae0bbe23be
class ComposerAutoloaderInitd790c17a0fbe6d9c27793420cf646a1f
{
private static $loader;

Expand All @@ -24,12 +24,12 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit6be0de7c2c544c6b51cbdeae0bbe23be', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd790c17a0fbe6d9c27793420cf646a1f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit6be0de7c2c544c6b51cbdeae0bbe23be', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd790c17a0fbe6d9c27793420cf646a1f', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd790c17a0fbe6d9c27793420cf646a1f::getInitializer($loader));

$loader->register(true);

Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be
class ComposerStaticInitd790c17a0fbe6d9c27793420cf646a1f
{
public static $prefixLengthsPsr4 = array (
'B' =>
Expand Down Expand Up @@ -32,9 +32,9 @@ class ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit6be0de7c2c544c6b51cbdeae0bbe23be::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd790c17a0fbe6d9c27793420cf646a1f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd790c17a0fbe6d9c27793420cf646a1f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd790c17a0fbe6d9c27793420cf646a1f::$classMap;

}, null, ClassLoader::class);
}
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"packages": [
{
"name": "beycanpress/cryptopay-integrator",
"version": "0.1.8",
"version_normalized": "0.1.8.0",
"version": "0.1.10",
"version_normalized": "0.1.10.0",
"source": {
"type": "git",
"url": "https://github.com/BeycanPress/cryptopay-integrator.git",
"reference": "c28bbee3ca84fd1e4ca02f4867f6dadbee0c117d"
"reference": "6ac799ad5b3c9b952ee77d4d974162f525ff0f2a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/BeycanPress/cryptopay-integrator/zipball/c28bbee3ca84fd1e4ca02f4867f6dadbee0c117d",
"reference": "c28bbee3ca84fd1e4ca02f4867f6dadbee0c117d",
"url": "https://api.github.com/repos/BeycanPress/cryptopay-integrator/zipball/6ac799ad5b3c9b952ee77d4d974162f525ff0f2a",
"reference": "6ac799ad5b3c9b952ee77d4d974162f525ff0f2a",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"time": "2024-03-11T06:09:27+00:00",
"time": "2024-03-22T11:55:55+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand All @@ -34,7 +34,7 @@
"homepage": "https://github.com/BeycanPress/cryptopay-integrator",
"support": {
"issues": "https://github.com/BeycanPress/cryptopay-integrator/issues",
"source": "https://github.com/BeycanPress/cryptopay-integrator/tree/0.1.8"
"source": "https://github.com/BeycanPress/cryptopay-integrator/tree/0.1.10"
},
"install-path": "../beycanpress/cryptopay-integrator"
}
Expand Down
Loading

0 comments on commit 5cfd28c

Please sign in to comment.