Skip to content

Commit

Permalink
Merge pull request #34 from BeycanPress/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
0xBeycan authored Jan 20, 2025
2 parents e34391f + b099257 commit 5c809ef
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 17 deletions.
9 changes: 9 additions & 0 deletions app/Models/AbstractTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ public function updateStatusToFailedByHash(string $hash): bool
return $this->updateStatusByHash($hash, Status::FAILED);
}

/**
* @param string $hash
* @return bool
*/
public function updateStatusToProcessingByHash(string $hash): bool
{
return $this->updateStatusByHash($hash, Status::PROCESSING);
}

/**
* @param string $text
* @param array<mixed> $params
Expand Down
5 changes: 4 additions & 1 deletion app/Pages/TransactionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ public function page(): void
)->format('d M Y H:i');
},
'delete' => function ($tx) {
if (strtolower($tx->status) == Status::PENDING->getValue()) {
if (
strtolower($tx->status) == Status::PENDING->getValue() ||
strtolower($tx->status) == Status::PROCESSING->getValue()
) {
return '';
};
return Helpers::view('components/delete', [
Expand Down
5 changes: 3 additions & 2 deletions app/RestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function createTransaction(): void
'userId' => $this->currentUserId,
'updatedAt' => current_time('mysql'),
'createdAt' => current_time('mysql'),
'status' => Status::PENDING->getValue(),
'status' => Status::PROCESSING->getValue(),
'hash' => $this->paymentData->getHash(),
'testnet' => Helpers::getTestnetStatus(),
'orderId' => $this->paymentData->getOrder()->getId(),
Expand Down Expand Up @@ -321,7 +321,8 @@ public function setReminderEmail(): void
$this->paymentData->getModel()->update([
'reminderEmail' => $email,
'userId' => $this->currentUserId,
'updatedAt' => current_time('mysql')
'updatedAt' => current_time('mysql'),
'status' => Status::PENDING->getValue()
], [
'hash' => $this->paymentData->getHash()
]);
Expand Down
15 changes: 6 additions & 9 deletions app/Services/Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,12 @@ public static function verifyPendingTransactions(
int $userId = 0,
string $code = 'all'
): void {
if (0 == $userId) {
$params = [
'status' => Status::PENDING->getValue()
];
} else {
$params = [
'status' => Status::PENDING->getValue(),
'userId' => $userId
];
$params = [
'status' => Status::PENDING->getValue()
];

if (0 != $userId) {
$params['userId'] = $userId;
}

if ('all' != $code) {
Expand Down
1 change: 1 addition & 0 deletions app/Types/Enums/TransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum TransactionStatus: string
case PENDING = 'pending';
case VERIFIED = 'verified';
case FAILED = 'failed';
case PROCESSING = 'processing';

/**
* @return string
Expand Down
2 changes: 1 addition & 1 deletion app/WooCommerce/Services/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function init(int $orderId): void
{
$order = wc_get_order($orderId);

if ($order->get_status() != Status::PENDING->getValue()) {
if ('pending' != $order->get_status()) {
wp_redirect($order->get_checkout_order_received_url());
exit();
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/WooCommerce/Services/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function frontend(int $orderId): void
if (CryptoPay::ID == $order->get_payment_method()) {
$transaction = (new OrderTransaction())->getTransactionByOrderId($orderId);

if ($order->get_status() == Status::PENDING->getValue() && !$transaction) {
if ('pending' == $order->get_status() && !$transaction) {
Helpers::viewEcho('woocommerce/pending', ['payUrl' => $order->get_checkout_payment_url(true)]);
} elseif (!is_null($transaction)) {
echo Helpers::getPaymentHtmlDetails($transaction);
Expand Down
2 changes: 1 addition & 1 deletion cryptopay-wc-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Plugin Name: CryptoPay Lite
* Version: 2.3.8
* Version: 2.3.9
* Plugin URI: https://beycanpress.com/cryptopay/
* Description: All In One Cryptocurrency Payments for WordPress
* Author: BeycanPress LLC
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Tags: WooCommerce, Cryptocurrency, Payment, Gateway, Bitcoin
Requires at least: 5.0
Tested up to: 6.7.1
Requires PHP: 8.1
Stable Tag: 2.3.8
Version: 2.3.8
Stable Tag: 2.3.9
Version: 2.3.9
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down

0 comments on commit 5c809ef

Please sign in to comment.