Skip to content

Commit

Permalink
Merge pull request #2 from BeycanPress/alpha
Browse files Browse the repository at this point in the history
completed configurations
  • Loading branch information
BeycanDeveloper authored Feb 1, 2024
2 parents 96e10c2 + ef73881 commit 3d669a5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 46 deletions.
32 changes: 14 additions & 18 deletions classes/lite/MeprCryptoPayLiteCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
// @phpcs:disable Generic.Files.LineLength
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use BeycanPress\Http\Response;
use BeycanPress\CryptoPayLite\PluginHero\Hook;
use BeycanPress\CryptoPayLite\Pages\TransactionPage;
use BeycanPress\CryptoPayLite\PluginHero\Http\Response;
use BeycanPress\CryptoPayLite\Types\Data\PaymentDataType;

// @phpcs:ignore
class MeprCryptoPayLiteCtrl extends MeprBaseCtrl
Expand All @@ -23,16 +24,14 @@ public function load_hooks(): void
if (is_admin()) {
new TransactionPage(
esc_html__('MemberPress transactions', 'memberpress-cryptopay'),
'memberpress_lite',
'memberpress',
9,
[],
true,
['updatedAt']
[]
);
}

Hook::addFilter('init_memberpress_lite', function (object $data) {
if (!(new MeprTransaction())->get_one($data->params->MemberPress->transactionId)) {
Hook::addFilter('init_memberpress', function (PaymentDataType $data) {
if (!(new MeprTransaction())->get_one($data->getOrder()->getId())) {
Response::error(esc_html__('The MemberPress transaction not found!', 'memberpress-cryptopay'), 'TXN_NOT_FOUND', [
'redirect' => 'reload'
]);
Expand All @@ -41,31 +40,28 @@ public function load_hooks(): void
return $data;
});

Hook::addFilter('before_payment_started_memberpress_lite', function (object $data) {
$data->order->id = $data->params->MemberPress->transactionId;
return $data;
});
Hook::addAction('payment_finished_memberpress', function (PaymentDataType $data): void {
$txn = new MeprTransaction($data->getOrder()->getId());
$txn->status = $data->getStatus() ? MeprTransaction::$complete_str : MeprTransaction::$failed_str;

Hook::addAction('payment_finished_memberpress_lite', function (object $data): void {
$txn = new MeprTransaction($data->params->MemberPress->transactionId);
$txn->status = $data->status ? MeprTransaction::$complete_str : MeprTransaction::$failed_str;

if (!$data->status) {
if (!$data->getStatus()) {
MeprUtils::send_failed_txn_notices($txn);
}

if ($sub = $txn->subscription()) {
$sub->status = MeprSubscription::$active_str;
$sub->expires_at = $txn->expires_at;
$sub->store();
}

$txn->store();

MeprUtils::send_transaction_receipt_notices($txn);
});

Hook::addFilter('payment_redirect_urls_memberpress_lite', function (object $data) {
Hook::addFilter('payment_redirect_urls_memberpress', function (PaymentDataType $data) {
$meprOptions = MeprOptions::fetch();
$txn = new MeprTransaction($data->params->MemberPress->transactionId);
$txn = new MeprTransaction($data->getOrder()->getId());
$prd = $txn->product();
$query_params = [
'membership' => sanitize_title($prd->post_title),
Expand Down
19 changes: 9 additions & 10 deletions classes/lite/MeprCryptoPayLiteGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
// @phpcs:disable SlevomatCodingStandard.TypeHints.ParameterTypeHint

use BeycanPress\CryptoPayLite\Payment;
use BeycanPress\CryptoPayLite\Settings;
use BeycanPress\CryptoPayLite\Services;
use BeycanPress\CryptoPayLite\PluginHero\Hook;
use BeycanPress\CryptoPayLite\Types\Order\OrderType;

// @phpcs:ignore
class MeprCryptoPayLiteGateway extends MeprBaseRealGateway
Expand Down Expand Up @@ -214,16 +216,13 @@ public function display_payment_form($amount, $user, $productId, $transactionId)
?>
<div class="mp_wrapper mp_payment_form_wrapper">
<?php
echo Services::startPaymentProcess([
'amount' => $amount,
echo (new Payment('memberpress'))
->setOrder(OrderType::fromArray([
'id' => (int) $transactionId,
'amount' => (float) $amount,
'currency' => $meprOptions->currency_code,
], 'memberpress_lite', true, [
'MemberPress' => [
'userId' => (int) $user->ID,
'productId' => (int) $productId,
'transactionId' => (int) $transactionId,
]
]);
]))
->html(loading:true);
?>
</div>
<?php
Expand Down
2 changes: 1 addition & 1 deletion classes/pro/MeprCryptoPayCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// @phpcs:disable Generic.Files.LineLength
// @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use BeycanPress\Http\Response;
use BeycanPress\CryptoPay\PluginHero\Hook;
use BeycanPress\CryptoPay\Pages\TransactionPage;
use BeycanPress\CryptoPay\PluginHero\Http\Response;
use BeycanPress\CryptoPay\Types\Data\PaymentDataType;

// @phpcs:ignore
Expand Down
10 changes: 0 additions & 10 deletions classes/pro/MeprCryptoPayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use BeycanPress\CryptoPay\Settings;
use BeycanPress\CryptoPay\PluginHero\Hook;
use BeycanPress\CryptoPay\Types\Order\OrderType;
use BeycanPress\CryptoPay\Types\Transaction\ParamsType;

// @phpcs:ignore
class MeprCryptoPayGateway extends MeprBaseRealGateway
Expand Down Expand Up @@ -435,15 +434,6 @@ private function show_cryptopay_payment_form($txn): void
]))
->html(loading:true);
?>
<style>
.cp-modal .waiting-icon svg {
width: 94px!important;
height: 94px!important;
}
.cp-explorer-btn {
height: auto!important;
}
</style>
</div>
<?php
}
Expand Down
10 changes: 5 additions & 5 deletions memberpress-cryptopay-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Plugin Name: MemberPress - CryptoPay Gateway
* Version: 1.0.2
* Version: 1.0.3
* Plugin URI: https://beycanpress.com/cryptopay/
* Description: Adds Cryptocurrency payment gateway (CryptoPay) for MemberPress.
* Author: BeycanPress LLC
Expand All @@ -29,11 +29,11 @@
use BeycanPress\CryptoPay\Helpers;
use BeycanPress\CryptoPay\PluginHero\Hook;
use BeycanPress\CryptoPayLite\Loader as LiteLoader;
use BeycanPress\CryptoPayLite\Services as LiteServices;
use BeycanPress\CryptoPayLite\Helpers as LiteHelpers;
use BeycanPress\CryptoPayLite\PluginHero\Hook as LiteHook;

define('MEMBERPRESS_CRYPTOPAY_FILE', __FILE__);
define('MEMBERPRESS_CRYPTOPAY_VERSION', '1.0.2');
define('MEMBERPRESS_CRYPTOPAY_VERSION', '1.0.3');
define('MEMBERPRESS_CRYPTOPAY_URL', plugin_dir_url(__FILE__));
define('MEMBERPRESS_CRYPTOPAY_DIR', plugin_dir_path(__FILE__));

Expand Down Expand Up @@ -66,7 +66,7 @@ function memberpress_cryptopay_addModels(): void
require_once MEMBERPRESS_CRYPTOPAY_DIR . 'classes/lite/Models/MemberPressCrpyoPayLiteModel.php';
LiteHook::addFilter('models', function ($models) {
return array_merge($models, [
'memberpress_lite' => new MemberPressCrpyoPayLiteModel()
'memberpress' => new MemberPressCrpyoPayLiteModel()
]);
});
}
Expand Down Expand Up @@ -97,7 +97,7 @@ function memberpress_cryptopay_addModels(): void
}

if (class_exists(LiteLoader::class)) {
LiteServices::registerAddon('memberpress_lite');
LiteHelpers::registerIntegration('memberpress');
}

add_filter('mepr-gateway-paths', 'addGatewayPathToMemberPress', 10, 1);
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Tags: Bitcoin, Ethereum, Binance Smart Chain, Blockchain, Networks, Cryptocurren
Requires at least: 5.0
Tested up to: 6.4.2
Requires PHP: 8.1
Stable Tag: 1.0.2
Version: 1.0.2
Stable Tag: 1.0.3
Version: 1.0.3
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -53,6 +53,9 @@ You can easily translate with Loco translate.

== Changelog ==

= 1.0.3 =
* Updated: Compatibility due to updates in CryptoPay Lite 2.1.1

= 1.0.2 =
* Updated: Compatibility due to updates in CryptoPay 2.1.0

Expand Down

0 comments on commit 3d669a5

Please sign in to comment.