Skip to content

Conversation

@hirale
Copy link
Contributor

@hirale hirale commented Jun 22, 2025

Description (*)

Refactor PayPal module to meet PayPal REST APIs with https://github.com/paypal/PayPal-PHP-Server-SDK

Related Pull Requests

✅ Current Status

The standard purchase flow has been fully tested and works as expected.
It supports:

  • Refund
  • Void
  • Authorize
  • Capture

For Authorize transactions, I have created a cronjob to process automatic re-authorize after 3 days honor period.
You can find more details here:
👉 PayPal Checkout Payment Intent Documentation


🔜 Next Steps (Help Needed)

I’ll need help with the following:

  1. Recurring Payments

    • Development and testing of recurring payment functionality.
  2. Compatibility with One Step Checkout Extensions

    • Review and ensure compatibility with popular one-step checkout modules.
  3. Code Testing

    • Improve test coverage.
    • Identify critical areas needing unit or integration tests.
    • Validate edge cases and PayPal SDK integration scenarios.
  4. Backwards Compatibility

    • Ensure smooth backward compatibility where possible.
    • The current implementation removes all old PayPal payment methods from the install scripts, keeping only the corresponding payment title config.
    • Review upgrade paths for existing merchants migrating from previous PayPal integration to this new module version.

📦 Versioning Notes

  • The module version has been bumped directly to 2.0.0.0.
  • All previous PayPal payment methods and install scripts have been removed.
  • Only config-based payment titles remain for legacy visibility where needed.

📚 Reference

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added Component: PayPal Relates to Mage_Paypal Component: Core Relates to Mage_Core Template : admin Relates to admin template Component: Sales Relates to Mage_Sales Template : rwd Relates to rwd template Template : base Relates to base template Component: Adminhtml Relates to Mage_Adminhtml Component: Review Relates to Mage_Review Component: Downloadable Relates to Mage_Downloadable Component: Bundle Relates to Mage_Bundle translations Relates to app/locale composer Relates to composer.json JavaScript Relates to js/* XML Layout phpstan PHPStorm phpunit labels Jun 22, 2025
@hirale hirale marked this pull request as draft June 22, 2025 15:15
@github-actions github-actions bot removed Component: Api2 Relates to Mage_Api2 Component: Log Relates to Mage_Log Component: ImportExport Relates to Mage_ImportExport Component: Directory Relates to Mage_Directory Component: CatalogSearch Relates to Mage_CatalogSearch shell Relates to shell scripts Component: Centinel Relates to Mage_Centinel Component: Dataflow Relates to Mage_Dataflow Component: Uploader Relates to Mage_Uploader Component: Rss Relates to Mage_Rss Component: Paygate Relates to Mage_Paygate Component: lib/* Relates to lib/* errors Relates to error pages rector labels Jul 11, 2025
@sonarqubecloud
Copy link

hirale and others added 4 commits October 2, 2025 21:41
Refactor the cart total adjustment logic to handle rounding differences
for both item prices and taxes. This replaces the previous tax-only
discrepancy adjustment.

The change includes:
- Renaming the method from adjustCartTotalsForTaxDiscrepancy to
  adjustCartTotalsForRounding
- Calculating rounding differences for item prices and taxes separately
- Adjusting discount amounts or adding rounding adjustment items as needed
- Updating related helper text for rounding adjustments
- Fixing indentation for payment method comments
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2025

@github-actions github-actions bot added the phpmd label Nov 24, 2025
@sonarqubecloud
Copy link

@sreichel sreichel marked this pull request as ready for review November 24, 2025 09:06
Copilot AI review requested due to automatic review settings November 24, 2025 09:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the PayPal module to integrate with PayPal's REST API using the official PHP Server SDK. It replaces the legacy NVP/SOAP API implementation with a modern REST API approach, removing outdated payment methods while introducing support for new features including automatic authorization reauthorization and improved transaction management.

Key Changes:

  • Migration from PayPal NVP API to REST API with official PHP SDK integration
  • Implementation of new payment processing models (Payment, Order, Transaction, Helper)
  • Addition of cronjob for authorization lifecycle management
  • Removal of deprecated payment methods (PayflowPro, PayflowLink, Express Checkout, etc.)
  • Simplified configuration model with REST API credentials

Reviewed changes

Copilot reviewed 106 out of 254 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Mage_Paypal_Model_Payment.php New payment processing handler for authorize, capture, refund, and void operations
Mage_Paypal_Model_Order.php New order creation handler with PayPal SDK builders integration
Mage_Paypal_Model_Helper.php New helper class for validation, error handling, and API utilities
Mage_Paypal_Model_Cron.php New cronjob for authorization lifecycle management (reauth, expiration alerts)
Mage_Paypal_Model_Config.php Simplified configuration model for REST API credentials and button settings
Mage_Paypal_Model_Exception.php New custom exception class for PayPal-specific errors
Mage_Paypal_Model_Debug.php Updated debug model initialization
Multiple deleted files Removal of legacy payment methods and API implementations

return;
}

$paypalModel = Mage::getModel('paypal/paypal');
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The model name 'paypal/paypal' appears incorrect. Based on the new file structure, this should likely be 'paypal/payment' to match the Mage_Paypal_Model_Payment class that contains the reauthorizePayment method.

Suggested change
$paypalModel = Mage::getModel('paypal/paypal');
$paypalModel = Mage::getModel('paypal/payment');

Copilot uses AI. Check for mistakes.
$addressObj = $payer->getAddress();
$name = $nameObj->getGivenName() . ' ' . $nameObj->getSurname();
$country = $addressObj->getCountryCode();
$email = $payer->getEmailAddress() ?? '[email protected]';
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

Using a hardcoded fallback email '[email protected]' is problematic as PayPal may reject invalid or placeholder emails. Consider throwing an exception or logging an error when email is missing instead of using a placeholder value.

Suggested change
$email = $payer->getEmailAddress() ?? '[email protected]';
$email = $payer->getEmailAddress();
// For payment methods that require email, ensure it is present
if (in_array($fundingSource, ['p24', 'trustly'], true) && empty($email)) {
throw new \InvalidArgumentException("Missing payer email address for funding source '{$fundingSource}'.");
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Adminhtml Relates to Mage_Adminhtml Component: Bundle Relates to Mage_Bundle Component: Core Relates to Mage_Core Component: Downloadable Relates to Mage_Downloadable Component: PayPal Relates to Mage_Paypal Component: Review Relates to Mage_Review Component: Sales Relates to Mage_Sales composer Relates to composer.json JavaScript Relates to js/* phpmd phpstan PHPStorm phpunit Template : admin Relates to admin template Template : base Relates to base template Template : rwd Relates to rwd template translations Relates to app/locale XML Layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants