-
-
Notifications
You must be signed in to change notification settings - Fork 452
Refactor PayPal Module #4838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor PayPal Module #4838
Conversation
|
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
|
|
There was a problem hiding this 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'); |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
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.
| $paypalModel = Mage::getModel('paypal/paypal'); | |
| $paypalModel = Mage::getModel('paypal/payment'); |
| $addressObj = $payer->getAddress(); | ||
| $name = $nameObj->getGivenName() . ' ' . $nameObj->getSurname(); | ||
| $country = $addressObj->getCountryCode(); | ||
| $email = $payer->getEmailAddress() ?? '[email protected]'; |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
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.
| $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}'."); | |
| } |



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:
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:
Recurring Payments
Compatibility with One Step Checkout Extensions
Code Testing
Backwards Compatibility
📦 Versioning Notes
2.0.0.0.📚 Reference
Contribution checklist (*)