Changeset 3626543
- Timestamp:
- 07/29/2026 12:15:19 AM (3 months ago)
- Location:
- restore-paypal-standard-for-woocommerce
- Files:
-
- 34 added
- 6 edited
-
tags/3.1.1 (added)
-
tags/3.1.1/assets (added)
-
tags/3.1.1/assets/css (added)
-
tags/3.1.1/assets/css/paypal-standard-admin.css (added)
-
tags/3.1.1/assets/images (added)
-
tags/3.1.1/assets/images/paypal-cards.jpg (added)
-
tags/3.1.1/assets/images/paypal-logo.png (added)
-
tags/3.1.1/assets/images/paypal-logo.svg (added)
-
tags/3.1.1/assets/js (added)
-
tags/3.1.1/assets/js/blocks (added)
-
tags/3.1.1/assets/js/blocks/paypal-standard-blocks.asset.php (added)
-
tags/3.1.1/assets/js/blocks/paypal-standard-blocks.js (added)
-
tags/3.1.1/assets/js/deactivation-survey.js (added)
-
tags/3.1.1/assets/js/paypal-standard-admin.js (added)
-
tags/3.1.1/includes (added)
-
tags/3.1.1/includes/admin (added)
-
tags/3.1.1/includes/admin/migration.php (added)
-
tags/3.1.1/includes/admin/settings.php (added)
-
tags/3.1.1/includes/blocks-support.php (added)
-
tags/3.1.1/includes/class-wc-gateway-paypal-standard-blocks-support.php (added)
-
tags/3.1.1/includes/diagnostics.php (added)
-
tags/3.1.1/includes/functions.php (added)
-
tags/3.1.1/includes/paypal-standard (added)
-
tags/3.1.1/includes/paypal-standard-settings.php (added)
-
tags/3.1.1/includes/paypal-standard.php (added)
-
tags/3.1.1/includes/paypal-standard/paypal-standard-api-handler.php (added)
-
tags/3.1.1/includes/paypal-standard/paypal-standard-ipn-handler.php (added)
-
tags/3.1.1/includes/paypal-standard/paypal-standard-pdt-handler.php (added)
-
tags/3.1.1/includes/paypal-standard/paypal-standard-request.php (added)
-
tags/3.1.1/includes/paypal-standard/paypal-standard-response.php (added)
-
tags/3.1.1/languages (added)
-
tags/3.1.1/languages/restore-paypal-standard-for-woocommerce.pot (added)
-
tags/3.1.1/readme.txt (added)
-
tags/3.1.1/restore-paypal-standard-for-woocommerce.php (added)
-
trunk/includes/admin/migration.php (modified) (4 diffs)
-
trunk/includes/functions.php (modified) (1 diff)
-
trunk/includes/paypal-standard/paypal-standard-ipn-handler.php (modified) (2 diffs)
-
trunk/includes/paypal-standard/paypal-standard-pdt-handler.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/restore-paypal-standard-for-woocommerce.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
restore-paypal-standard-for-woocommerce/trunk/includes/admin/migration.php
r3292178 r3626543 328 328 wp_die( '', '', array( 'response' => 403 ) ); 329 329 } 330 330 331 331 // Get the notice count from the AJAX request 332 332 $notice_count = isset( $_REQUEST['notice_count'] ) ? intval( $_REQUEST['notice_count'] ) : 0; … … 355 355 wp_die( esc_html__( 'Security check failed', 'restore-paypal-standard-for-woocommerce' ) ); 356 356 } 357 357 358 358 // Mark notice as permanently dismissed 359 359 update_option( 'rpsfw_migration_notice_dismissed_permanently', 'yes' ); … … 397 397 wp_die( esc_html__( 'Security check failed', 'restore-paypal-standard-for-woocommerce' ) ); 398 398 } 399 399 400 400 // Run the migration 401 401 rpsfw_migrate_native_paypal_settings(); … … 417 417 wp_die( esc_html__( 'Security check failed', 'restore-paypal-standard-for-woocommerce' ) ); 418 418 } 419 419 420 420 // Reset dismissal options to force showing the notice 421 421 delete_option( 'rpsfw_migration_notice_dismissed_until' ); -
restore-paypal-standard-for-woocommerce/trunk/includes/functions.php
r3421414 r3626543 152 152 153 153 return $links; 154 } 155 156 /** 157 * Set the "_should_load" flag on WooCommerce's native PayPal Standard gateway. 158 * 159 * The value is written straight to the gateway's option rather than by calling 160 * WC_Gateway_Paypal::update_option(), which would mean instantiating the gateway. 161 * That constructor calls __() on the 'woocommerce' text domain, and on plugins_loaded 162 * that is before 'init' - which makes WordPress 6.7+ emit a "Translation loading for 163 * the woocommerce domain was triggered too early" notice. Writing the option has the 164 * same effect: WC_Settings_API::update_option() simply stores the value in 165 * get_option_key(), which for this gateway is 'woocommerce_paypal_settings'. 166 * 167 * @param string $value Either 'yes' or 'no'. 168 * @return void 169 */ 170 function rpsfw_set_native_paypal_should_load( $value ) { 171 // Nothing to toggle if WooCommerce or its PayPal Standard gateway is not present. 172 if ( ! class_exists( 'WC_Gateway_Paypal' ) ) { 173 return; 174 } 175 176 $settings = get_option( 'woocommerce_paypal_settings', array() ); 177 178 if ( ! is_array( $settings ) ) { 179 $settings = array(); 180 } 181 182 $settings['_should_load'] = $value; 183 184 update_option( 'woocommerce_paypal_settings', $settings, 'yes' ); 154 185 } 155 186 -
restore-paypal-standard-for-woocommerce/trunk/includes/paypal-standard/paypal-standard-ipn-handler.php
r3292178 r3626543 176 176 177 177 /** 178 * Check receiver email from PayPal. If the receiver email in the IPN is different than what is stored in our settings, process order but add a note.178 * Check receiver email from PayPal. If the receiver email in the IPN is different than what is stored in our settings, the payment was not made to this store's PayPal account, so put the order on-hold and stop - exactly as the currency and amount checks above do. 179 179 * 180 180 * @param WC_Order $order Order object. … … 184 184 if ( strcasecmp( trim( $receiver_email ), trim( $this->receiver_email ) ) !== 0 ) { 185 185 rpsfw_Gateway_PayPal_Standard::log( 'IPN Response: Receiver email mismatch - ' . $receiver_email . ' vs ' . $this->receiver_email ); 186 186 187 187 /* translators: %s: receiver email */ 188 188 $order->update_status('on-hold', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'restore-paypal-standard-for-woocommerce'), $receiver_email)); 189 190 return false; 191 } 192 return true; 189 190 exit; 191 } 193 192 } 194 193 -
restore-paypal-standard-for-woocommerce/trunk/includes/paypal-standard/paypal-standard-pdt-handler.php
r3292178 r3626543 155 155 */ 156 156 protected function validate_transaction_details( $order, $details ) { 157 // Validate receiver email (if provided) 158 if ( isset( $details['receiver_email'] ) && !empty( $this->receiver_email ) ) { 157 // PDT runs again every time the buyer loads the order-received URL with a ?tx= token, 158 // including for orders the IPN handler has already paid and verified. These checks exist 159 // to stop an order being completed, never to reverse a completion that already happened, 160 // so skip them once the order is paid. 161 $needs_verification = ! $order->has_status( wc_get_is_paid_statuses() ); 162 163 // Validate receiver email. When a receiving account is configured the response has to 164 // name it - a missing receiver_email means the payment cannot be confirmed as having 165 // reached this store, which is not the same as it having passed. 166 if ( $needs_verification && !empty( $this->receiver_email ) ) { 167 if ( ! isset( $details['receiver_email'] ) ) { 168 rpsfw_Gateway_PayPal_Standard::log('PDT Response: no receiver_email returned, cannot confirm the payment reached this store. Order #' . $order->get_id()); 169 170 $order->update_status('on-hold', __('Validation error: the PayPal PDT response did not identify the receiving account, so the payment could not be verified.', 'restore-paypal-standard-for-woocommerce')); 171 172 return false; 173 } 174 159 175 if ( strtolower( $details['receiver_email'] ) !== strtolower( $this->receiver_email ) ) { 160 176 rpsfw_Gateway_PayPal_Standard::log('PDT Response: Receiver email mismatch - ' . $details['receiver_email'] . ' vs ' . $this->receiver_email); 161 177 162 178 /* translators: %1$s: receiver email, %2$s: order ID */ 163 $order->update_status('on-hold', sprintf(__('Validation error: PayPal PDT response from a different email address (%1$s). Order #%2$s', 'restore-paypal-standard-for-woocommerce'), 179 $order->update_status('on-hold', sprintf(__('Validation error: PayPal PDT response from a different email address (%1$s). Order #%2$s', 'restore-paypal-standard-for-woocommerce'), 164 180 $details['receiver_email'], 165 181 $order->get_id() 166 182 )); 167 183 168 184 return false; 169 185 } … … 185 201 // If the order is already completed, just add a note 186 202 if ( $order->has_status( wc_get_is_paid_statuses() ) ) { 187 $order->add_order_note( 188 sprintf( 203 $order->add_order_note( 204 sprintf( 189 205 __( 'PayPal PDT: Payment verified (ID: %s)', 'restore-paypal-standard-for-woocommerce' ), 190 $transaction_id 191 ) 206 $transaction_id 207 ) 192 208 ); 193 209 } else { 210 // The amount and currency are carried in client side form fields on the way 211 // to PayPal, so a buyer can pay less than the order total. Check what was 212 // actually paid before completing the order, the same way the IPN handler 213 // does. The IPN handler aborts early on an already paid order, so this is 214 // the only amount check on a synchronous PDT completion. On a mismatch the 215 // order is left on-hold for manual review instead of being marked paid. 216 if ( ! isset( $details['mc_gross'], $details['mc_currency'] ) 217 || $order->get_currency() !== $details['mc_currency'] 218 || number_format( $order->get_total(), 2, '.', '' ) !== number_format( (float) $details['mc_gross'], 2, '.', '' ) ) { 219 220 rpsfw_Gateway_PayPal_Standard::log( 'PDT Response: payment could not be verified for order #' . $order->get_id() 221 . ' (order total ' . $order->get_total() . ' ' . $order->get_currency() 222 . ' | returned gross ' . ( isset( $details['mc_gross'] ) ? $details['mc_gross'] : '(missing)' ) 223 . ' ' . ( isset( $details['mc_currency'] ) ? $details['mc_currency'] : '(missing)' ) . ')' ); 224 225 /* translators: %s: Amount. */ 226 $order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal PDT amounts do not match (gross %s).', 'restore-paypal-standard-for-woocommerce' ), isset( $details['mc_gross'] ) ? $details['mc_gross'] : '' ) ); 227 228 return false; 229 } 230 194 231 // If order is still pending, complete it 195 232 $order->payment_complete( $transaction_id ); 196 $order->add_order_note( 197 sprintf( 233 $order->add_order_note( 234 sprintf( 198 235 __( 'PayPal PDT: Payment completed (ID: %s)', 'restore-paypal-standard-for-woocommerce' ), 199 $transaction_id 200 ) 236 $transaction_id 237 ) 201 238 ); 202 239 } -
restore-paypal-standard-for-woocommerce/trunk/readme.txt
r3540267 r3626543 5 5 Tested up to: 7.0 6 6 Requires PHP: 5.6 7 Stable tag: 3.1. 07 Stable tag: 3.1.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 42 42 43 43 == Changelog == 44 45 = 3.1.1 = 46 * 7/28/26 47 * Fix - Security fixes related to PayPal IPN and PDT. 48 * Fix - Resolved the 'Translation loading for the WooCommerce domain was triggered too early' notice in WordPress 6.7+, caused by loading WooCommerce's PayPal gateway on plugins_loaded. 44 49 45 50 = 3.1.0 = -
restore-paypal-standard-for-woocommerce/trunk/restore-paypal-standard-for-woocommerce.php
r3421414 r3626543 3 3 * Plugin Name: Restore Paypal Standard For WooCommerce 4 4 * Description: Restore PayPal Standard payment gateway for WooCommerce 5 * Version: 3.1. 05 * Version: 3.1.1 6 6 * Author: Scott Paterson 7 7 * Author URI: https://wpplugin.org … … 23 23 24 24 // Define plugin constants 25 define( 'RPSFW_VERSION', '3.1. 0' );25 define( 'RPSFW_VERSION', '3.1.1' ); 26 26 define( 'RPSFW_PLUGIN_FILE', __FILE__ ); 27 27 define( 'RPSFW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); … … 65 65 add_action( 'plugins_loaded',function(){ 66 66 // It enable PayPal Standard for WooCommerce. 67 $paypal = class_exists( 'WC_Gateway_Paypal' ) ? new WC_Gateway_Paypal() : null; 68 if( $paypal ) { 69 $paypal->update_option( '_should_load', 'yes' ); 70 } 67 rpsfw_set_native_paypal_should_load( 'yes' ); 71 68 add_filter( 'woocommerce_should_load_paypal_standard','__return_true',9999999999999 ); 72 69 } ); … … 74 71 // Ensure native PayPal is disabled after migration 75 72 add_action( 'plugins_loaded', function() { 76 if (class_exists( 'WC_Gateway_Paypal' )) { 77 $paypal = new WC_Gateway_Paypal(); 78 $paypal->update_option( '_should_load', 'no' ); 79 } 73 rpsfw_set_native_paypal_should_load( 'no' ); 80 74 }, 5 ); 81 75 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)