Skip to content

Conversation

@arifulhoque7
Copy link
Contributor

@arifulhoque7 arifulhoque7 commented Jul 15, 2025

Summary

Removed all 54 instances of \WP_User_Frontend::log() calls from the PayPal gateway file while ensuring:

Key Areas Where Log Statements Were Removed:

  • Webhook processing - Event handling and verification logs
  • Payment capture - Transaction processing logs
  • Subscription management - Creation, cancellation, and activation logs
  • Error handling - Exception and error logs
  • API interactions - PayPal API communication logs
  • Database operations - User and transaction record logs
  • Trial payments - Trial period handling logs

The file now operates exactly the same way functionally, but without any logging output to \WP_User_Frontend::log(). All error handling, try-catch blocks, and business logic remain intact.

Summary by CodeRabbit

  • Chores
    • Removed internal logging from PayPal payment processing to streamline operations. No changes to user-facing functionality.

@arifulhoque7 arifulhoque7 requested a review from sapayth July 15, 2025 11:48
@arifulhoque7 arifulhoque7 self-assigned this Jul 15, 2025
@arifulhoque7 arifulhoque7 added the needs: dev review This PR needs review by a developer label Jul 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

Walkthrough

All diagnostic logging statements invoking \WP_User_Frontend::log() have been removed from the Paypal class in Lib/Gateway/Paypal.php. The core logic, control flow, and error handling remain unchanged, with no modifications to public interfaces or exported entities.

Changes

Files Change Summary
Lib/Gateway/Paypal.php Removed all calls to \WP_User_Frontend::log().

Suggested labels

QA Approved

Suggested reviewers

  • sapayth

Poem

Logs have hopped away, so neat,
Paypal's code skips on silent feet.
No more chatter in the night,
Just pure logic, running right.
A rabbit bows with ears held high—
Code so quiet, it might just fly! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
Lib/Gateway/Paypal.php (2)

441-475: Webhook re-throw breaks mandatory 200-OK acknowledgement

handle_webhook_request() promises to always acknowledge PayPal (http_response_code( 200 ) …) even on failure.
The re-throw inside the catch (l. 468) short-circuits that guarantee—execution jumps out of the method and the 200 never reaches PayPal, causing repeated retries.

-            } catch ( \Exception $e ) {
-               throw new \Exception( 'Webhook processing failed: ' . $e->getMessage() );
+            } catch ( \Exception $e ) {
+                // Do not re-throw – we still need to ACK PayPal.
+                $acknowledged = false;
+                // Optional: error_log( 'PayPal webhook failed: ' . $e->getMessage() );
             }

731-805: Local subscription state is not updated when remote cancellation fails

Inside cancel_subscription() the inner try { … } catch (l. 761-793) re-throws an exception.
As a consequence, the “Update local subscription status regardless of PayPal API result” block (l. 797-819) is skipped whenever the remote call errors—contradicting the comment and leaving user meta/table rows stale.

-                } catch ( \Exception $e ) {
-                    throw new \Exception( 'PayPal cancellation failed: ' . $e->getMessage() );
+                } catch ( \Exception $e ) {
+                    // Remote call failed – record locally and surface the error later.
+                    $remote_error = $e;
                 }
 ...
-            return true;
-        } catch ( \Exception $e ) {
-            throw $e;
+            return true;
+        } catch ( \Exception $e ) {
+            // Preserve previous behaviour of surfacing errors if desired
+            throw $e;
         }

Alternatively, move the update logic into a finally { … } block.
Failing to fix this will leave users with an active PayPal subscription marked as “active” in WPUF after PayPal already cancelled billing.

🧹 Nitpick comments (2)
Lib/Gateway/Paypal.php (2)

458-463: Stale comment references removed logging

The line // Log the event type (l. 461) is now misleading—there is no log anymore. Remove or re-phrase.

-                // Log the event type
+                // Event type verified – proceed

1473-1477: Clean up leftover “debug logging” comments

There are still comments signalling debug logging at:

  • prepare_to_send() – l. 1475
  • process_subscription_payment() – l. 951

They add noise now that all WP_User_Frontend::log() calls are gone.

-            // Add debug logging
-                            // Create order
+            // Create PayPal order

(and remove the similar comment around l. 951)

Also applies to: 950-952

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c389f9f and a7a70c6.

📒 Files selected for processing (1)
  • Lib/Gateway/Paypal.php (3 hunks)

@sapayth sapayth merged commit a971c44 into weDevsOfficial:develop Jul 30, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: dev review This PR needs review by a developer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants