diff --git a/classes/lite/MeprCryptoPayLiteCtrl.php b/classes/lite/MeprCryptoPayLiteCtrl.php index 23bb851..8c7454a 100644 --- a/classes/lite/MeprCryptoPayLiteCtrl.php +++ b/classes/lite/MeprCryptoPayLiteCtrl.php @@ -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 @@ -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' ]); @@ -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), diff --git a/classes/lite/MeprCryptoPayLiteGateway.php b/classes/lite/MeprCryptoPayLiteGateway.php index 55290da..11f8ebc 100644 --- a/classes/lite/MeprCryptoPayLiteGateway.php +++ b/classes/lite/MeprCryptoPayLiteGateway.php @@ -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 @@ -214,16 +216,13 @@ public function display_payment_form($amount, $user, $productId, $transactionId) ?>
$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); ?>
html(loading:true); ?> - new MemberPressCrpyoPayLiteModel() + 'memberpress' => new MemberPressCrpyoPayLiteModel() ]); }); } @@ -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); diff --git a/readme.txt b/readme.txt index f680e5b..1ae23f6 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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