Commit 9389addb30 for woocommerce

commit 9389addb301b9093f586f6c14d5746007ff2e64b
Author: Wesley Rosa <wesleyjrosa@gmail.com>
Date:   Wed Jan 7 08:42:22 2026 -0300

    PayPal Standard Refactor 8: Moving PayPal order metas to new constants (#62635)

    * Moving PayPal order metas to new constants

    * Replacing meta keys in unit tests

    * Add changefile(s) from automation for the following project(s): woocommerce

    * Replacing missing order ID meta update

    * Update plugins/woocommerce/src/Gateways/PayPal/Constants.php

    Co-authored-by: daledupreez <dale@automattic.com>

    * Adding ORDER prefix to the meta constants

    ---------

    Co-authored-by: github-actions <github-actions@github.com>
    Co-authored-by: daledupreez <dale@automattic.com>

diff --git a/plugins/woocommerce/changelog/62635-refactor-moving-paypal-order-metas-to-constants b/plugins/woocommerce/changelog/62635-refactor-moving-paypal-order-metas-to-constants
new file mode 100644
index 0000000000..3c7b278576
--- /dev/null
+++ b/plugins/woocommerce/changelog/62635-refactor-moving-paypal-order-metas-to-constants
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Introduces new constants to store PayPal Standard order meta keys.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
index f58a5163e0..dfeb4f45e2 100644
--- a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
+++ b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
@@ -248,7 +248,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 			return;
 		}

-		$paypal_order_id = $order->get_meta( '_paypal_order_id' );
+		$paypal_order_id = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID );
 		if ( empty( $paypal_order_id ) ) {
 			return;
 		}
@@ -263,7 +263,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 		 * Once an attempt is made (meta exists), we skip to prevent repeated API calls on page reloads.
 		 * The webhook handler will always update the addresses.
 		 */
-		$addresses_update_attempted = $order->meta_exists( '_paypal_addresses_updated' );
+		$addresses_update_attempted = $order->meta_exists( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED );
 		if ( $addresses_update_attempted ) {
 			return;
 		}
@@ -276,7 +276,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 			PayPalHelper::update_addresses_in_order( $order, $paypal_order_details );
 		} catch ( Exception $e ) {
 			self::log( 'Error updating addresses for order #' . $order_id . ': ' . $e->getMessage(), 'error' );
-			$order->update_meta_data( '_paypal_addresses_updated', 'no' );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, 'no' );
 			$order->save();
 		}
 	}
@@ -713,7 +713,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 		}

 		// If the order is authorized via legacy API, the '_paypal_status' meta will be 'pending'.
-		$is_authorized_via_legacy_api = 'pending' === $order->get_meta( '_paypal_status', true );
+		$is_authorized_via_legacy_api = 'pending' === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true );

 		if ( $this->should_use_orders_v2() && ! $is_authorized_via_legacy_api ) {
 			$paypal_request = new PayPalRequest( $this );
@@ -721,7 +721,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 			return;
 		}

-		if ( 'pending' === $order->get_meta( '_paypal_status', true ) && $order->get_transaction_id() ) {
+		if ( 'pending' === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) && $order->get_transaction_id() ) {
 			$this->init_api();
 			$result = WC_Gateway_Paypal_API_Handler::do_capture( $order );

@@ -740,7 +740,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
 					case 'Completed':
 						/* translators: 1: Amount, 2: Authorization ID, 3: Transaction ID */
 						$order->add_order_note( sprintf( __( 'Payment of %1$s was captured - Auth ID: %2$s, Transaction ID: %3$s', 'woocommerce' ), $result->AMT, $result->AUTHORIZATIONID, $result->TRANSACTIONID ) );
-						$order->update_meta_data( '_paypal_status', $result->PAYMENTSTATUS );
+						$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $result->PAYMENTSTATUS );
 						$order->set_transaction_id( $result->TRANSACTIONID );
 						$order->save();
 						break;
diff --git a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php
index 46e781cd04..d92c7ec3fc 100644
--- a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php
+++ b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php
@@ -7,6 +7,7 @@
  */

 use Automattic\WooCommerce\Enums\OrderStatus;
+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;

 if ( ! defined( 'ABSPATH' ) ) {
 	exit;
@@ -353,7 +354,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
 			$order->set_transaction_id( wc_clean( $posted['txn_id'] ) );
 		}
 		if ( ! empty( $posted['payment_status'] ) ) {
-			$order->update_meta_data( '_paypal_status', wc_clean( $posted['payment_status'] ) );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, wc_clean( $posted['payment_status'] ) );
 		}
 		$order->save();
 	}
diff --git a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php
index 2a05af3386..2d34ef79a0 100644
--- a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php
+++ b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php
@@ -12,6 +12,8 @@ if ( ! defined( 'ABSPATH' ) ) {
 	exit;
 }

+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;
+
 require_once dirname( __FILE__ ) . '/class-wc-gateway-paypal-response.php';

 /**
@@ -156,7 +158,7 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
 			// We have a valid response from PayPal.
 			WC_Gateway_Paypal::log( 'PDT Transaction Status: ' . wc_print_r( $status, true ) );

-			$order->add_meta_data( '_paypal_status', $status );
+			$order->add_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $status );
 			$order->set_transaction_id( $transaction );

 			if ( OrderStatus::COMPLETED === $status ) {
diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-buttons-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-buttons-controller.php
index 85030d9939..4eaa4e86e8 100644
--- a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-buttons-controller.php
+++ b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-buttons-controller.php
@@ -12,6 +12,7 @@ declare(strict_types=1);
 defined( 'ABSPATH' ) || exit;

 use Automattic\WooCommerce\Enums\OrderStatus;
+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;

 if ( ! class_exists( 'WC_Gateway_Paypal_Constants' ) ) {
 	require_once WC_ABSPATH . 'includes/gateways/paypal/includes/class-wc-gateway-paypal-constants.php';
@@ -153,7 +154,7 @@ class WC_REST_Paypal_Buttons_Controller extends WC_REST_Controller {
 			return new WP_REST_Response( array( 'error' => 'Failed to create PayPal order' ), 400 );
 		}

-		$order->update_meta_data( '_paypal_order_id', $paypal_order['id'] );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, $paypal_order['id'] );
 		$order->update_status( OrderStatus::PENDING );
 		$order->save();

diff --git a/plugins/woocommerce/src/Gateways/PayPal/Constants.php b/plugins/woocommerce/src/Gateways/PayPal/Constants.php
index 44f9c878c8..2e86c9d1f5 100644
--- a/plugins/woocommerce/src/Gateways/PayPal/Constants.php
+++ b/plugins/woocommerce/src/Gateways/PayPal/Constants.php
@@ -143,4 +143,67 @@ class Constants {
 	 * @var string
 	 */
 	const PAYPAL_ISSUE_PAYEE_ACCOUNT_RESTRICTED = 'PAYEE_ACCOUNT_RESTRICTED';
+
+	/**
+	 * Meta key for storing PayPal payment status in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_STATUS = '_paypal_status';
+
+	/**
+	 * Meta key for storing PayPal capture ID in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_CAPTURE_ID = '_paypal_capture_id';
+
+	/**
+	 * Meta key for storing PayPal authorization ID in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_AUTHORIZATION_ID = '_paypal_authorization_id';
+
+	/**
+	 * Meta key for storing PayPal authorization checked flag in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_AUTHORIZATION_CHECKED = '_paypal_authorization_checked';
+
+	/**
+	 * Meta key for storing PayPal order ID in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_ORDER_ID = '_paypal_order_id';
+
+	/**
+	 * Meta key for storing PayPal addresses updated flag in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_ADDRESSES_UPDATED = '_paypal_addresses_updated';
+
+	/**
+	 * Meta key for storing PayPal payment source in order meta.
+	 *
+	 * @var string
+	 *
+	 * @since 10.5.0
+	 */
+	public const PAYPAL_ORDER_META_PAYMENT_SOURCE = '_paypal_payment_source';
 }
diff --git a/plugins/woocommerce/src/Gateways/PayPal/Helper.php b/plugins/woocommerce/src/Gateways/PayPal/Helper.php
index ab55429203..8c8db16ef3 100644
--- a/plugins/woocommerce/src/Gateways/PayPal/Helper.php
+++ b/plugins/woocommerce/src/Gateways/PayPal/Helper.php
@@ -5,6 +5,7 @@ declare( strict_types=1 );
 namespace Automattic\WooCommerce\Gateways\PayPal;

 use WC_Order;
+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;

 defined( 'ABSPATH' ) || exit;

@@ -164,7 +165,7 @@ class Helper {
 		}

 		// Bail early if '_paypal_addresses_updated' is 'yes', meaning the addresses update already have been successful.
-		if ( 'yes' === $order->get_meta( '_paypal_addresses_updated', true ) ) {
+		if ( 'yes' === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, true ) ) {
 			return;
 		}

@@ -207,7 +208,7 @@ class Helper {
 			$order->set_billing_address_2( $billing_address['address_line_2'] ?? '' );
 		}

-		$order->update_meta_data( '_paypal_addresses_updated', 'yes' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, 'yes' );
 		$order->save();
 	}
 }
diff --git a/plugins/woocommerce/src/Gateways/PayPal/Request.php b/plugins/woocommerce/src/Gateways/PayPal/Request.php
index 8302cf3a62..d7d9ec2531 100644
--- a/plugins/woocommerce/src/Gateways/PayPal/Request.php
+++ b/plugins/woocommerce/src/Gateways/PayPal/Request.php
@@ -146,14 +146,14 @@ class Request {
 			}

 			// Save the PayPal order ID to the order.
-			$order->update_meta_data( '_paypal_order_id', $response_data['id'] );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, $response_data['id'] );

 			// Save the PayPal order status to the order.
-			$order->update_meta_data( '_paypal_status', $response_data['status'] );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $response_data['status'] );

 			// Remember the payment source: payment_source is not patchable.
 			// If the payment source is changed, we need to create a new PayPal order.
-			$order->update_meta_data( '_paypal_payment_source', $payment_source );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_PAYMENT_SOURCE, $payment_source );
 			$order->save();

 			return array(
@@ -223,7 +223,7 @@ class Request {
 		}

 		$paypal_debug_id = null;
-		$paypal_order_id = $order->get_meta( '_paypal_order_id' );
+		$paypal_order_id = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID );
 		if ( ! $paypal_order_id ) {
 			\WC_Gateway_Paypal::log( 'PayPal order ID not found. Cannot ' . $action . ' payment.' );
 			return;
@@ -235,7 +235,7 @@ class Request {
 		}

 		// Skip if the payment is already captured.
-		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( '_paypal_status', true ) ) {
+		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) ) {
 			\WC_Gateway_Paypal::log( 'PayPal payment is already captured. Skipping capture. Order ID: ' . $order->get_id() );
 			return;
 		}
@@ -308,21 +308,21 @@ class Request {
 			return;
 		}

-		$paypal_order_id = $order->get_meta( '_paypal_order_id', true );
+		$paypal_order_id = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, true );
 		// Skip if the PayPal Order ID is not found. This means the order was not created via the Orders v2 API.
 		if ( ! $paypal_order_id ) {
 			\WC_Gateway_Paypal::log( 'PayPal Order ID not found to capture authorized payment. Order ID: ' . $order->get_id() );
 			return;
 		}

-		$capture_id = $order->get_meta( '_paypal_capture_id', true );
+		$capture_id = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true );
 		// Skip if the payment is already captured.
 		if ( $capture_id ) {
 			\WC_Gateway_Paypal::log( 'PayPal payment is already captured. PayPal capture ID: ' . $capture_id . '. Order ID: ' . $order->get_id() );
 			return;
 		}

-		$paypal_status = $order->get_meta( '_paypal_status', true );
+		$paypal_status = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true );

 		// Skip if the payment is already captured.
 		if ( PayPalConstants::STATUS_CAPTURED === $paypal_status || PayPalConstants::STATUS_COMPLETED === $paypal_status ) {
@@ -375,7 +375,7 @@ class Request {
 			}

 			// Set custom status for successful capture response, or if the authorization was already captured.
-			$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_CAPTURED );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_CAPTURED );
 			$order->save();
 		} catch ( Exception $e ) {
 			\WC_Gateway_Paypal::log( $e->getMessage() );
@@ -400,7 +400,7 @@ class Request {
 					'<a href="' . esc_url( $paypal_dashboard_url ) . '" target="_blank">',
 					'</a>'
 				);
-				$order->update_meta_data( '_paypal_authorization_checked', 'yes' );
+				$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, 'yes' );
 			}

 			if ( $paypal_debug_id ) {
@@ -423,9 +423,9 @@ class Request {
 	 * @return string|null
 	 */
 	private function get_authorization_id_for_capture( WC_Order $order ): ?string {
-		$paypal_order_id  = $order->get_meta( '_paypal_order_id', true );
-		$authorization_id = $order->get_meta( '_paypal_authorization_id', true );
-		$capture_id       = $order->get_meta( '_paypal_capture_id', true );
+		$paypal_order_id  = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, true );
+		$authorization_id = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, true );
+		$capture_id       = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true );

 		// If the PayPal order ID is not found or the capture ID is already set, return null.
 		if ( ! $paypal_order_id || ! empty( $capture_id ) ) {
@@ -437,7 +437,7 @@ class Request {
 		// 1. Capture auth API call returned 404 (authorization object does not exist with the authorization ID).
 		// 2. Order details API call returned empty authorization array (authorization object does not exist for this PayPal order).
 		// Return null to avoid repeated API calls for orders that have no authorization data.
-		if ( 'yes' === $order->get_meta( '_paypal_authorization_checked', true ) ) {
+		if ( 'yes' === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, true ) ) {
 			return null;
 		}

@@ -458,8 +458,8 @@ class Request {
 				// If the payment is already captured, store the capture ID and status, and return null as there is no authorization ID that needs to be captured.
 				if ( $capture_data && isset( $capture_data['id'] ) ) {
 					$capture_id = $capture_data['id'];
-					$order->update_meta_data( '_paypal_capture_id', $capture_id );
-					$order->update_meta_data( '_paypal_status', $capture_data['status'] ?? PayPalConstants::STATUS_CAPTURED );
+					$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, $capture_id );
+					$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $capture_data['status'] ?? PayPalConstants::STATUS_CAPTURED );
 					$order->save();
 					\WC_Gateway_Paypal::log( 'Storing capture ID from Paypal. Order ID: ' . $order->get_id() . '; capture ID: ' . $capture_id );
 					return null;
@@ -468,13 +468,13 @@ class Request {
 				if ( $authorization_data && isset( $authorization_data['id'], $authorization_data['status'] ) ) {
 					// If the payment is already captured, return null as there is no authorization ID that needs to be captured.
 					if ( PayPalConstants::STATUS_CAPTURED === $authorization_data['status'] ) {
-						$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_CAPTURED );
+						$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_CAPTURED );
 						$order->save();
 						return null;
 					}
 					$authorization_id = $authorization_data['id'];
-					$order->update_meta_data( '_paypal_authorization_id', $authorization_id );
-					$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_AUTHORIZED );
+					$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, $authorization_id );
+					$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_AUTHORIZED );
 					\WC_Gateway_Paypal::log( 'Storing authorization ID from Paypal. Order ID: ' . $order->get_id() . '; authorization ID: ' . $authorization_id );
 					$order->save();
 				} else {
@@ -482,7 +482,7 @@ class Request {
 					// Store '_paypal_authorization_checked' flag to prevent repeated API calls.
 					// This flag indicates that we've made an API call to get PayPal order details and confirmed no authorization object exists.
 					\WC_Gateway_Paypal::log( 'Authorization ID not found in PayPal order details. Order ID: ' . $order->get_id() );
-					$order->update_meta_data( '_paypal_authorization_checked', 'yes' );
+					$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, 'yes' );
 					$order->save();
 					return null;
 				}
diff --git a/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php b/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
index fcd2cbb4fd..ad30eeeceb 100644
--- a/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
+++ b/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
@@ -75,7 +75,7 @@ class WebhookHandler {
 		}

 		// Skip if the payment is already processed.
-		$paypal_status = $order->get_meta( '_paypal_status', true );
+		$paypal_status = $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true );
 		if ( in_array( $paypal_status, array( PayPalConstants::STATUS_COMPLETED, PayPalConstants::STATUS_APPROVED ), true ) ) {
 			return;
 		}
@@ -84,7 +84,7 @@ class WebhookHandler {
 		$paypal_order_id = $event['resource']['id'] ?? null;
 		if ( PayPalConstants::STATUS_APPROVED === $status ) {
 			\WC_Gateway_Paypal::log( 'PayPal payment approved. Order ID: ' . $order->get_id() );
-			$order->update_meta_data( '_paypal_status', $status );
+			$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $status );
 			$order->add_order_note(
 				sprintf(
 					/* translators: %1$s: PayPal order ID */
@@ -133,15 +133,15 @@ class WebhookHandler {
 		}

 		// Skip if the payment is already processed.
-		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( '_paypal_status', true ) ) {
+		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) ) {
 			return;
 		}

 		$transaction_id = $event['resource']['id'] ?? null;
 		$status         = $event['resource']['status'] ?? null;
 		$order->set_transaction_id( $transaction_id );
-		$order->update_meta_data( '_paypal_capture_id', $transaction_id );
-		$order->update_meta_data( '_paypal_status', $status );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, $transaction_id );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $status );
 		$order->payment_complete();
 		$order->add_order_note(
 			sprintf(
@@ -170,7 +170,7 @@ class WebhookHandler {
 		}

 		// Skip if the payment is already processed.
-		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( '_paypal_status', true ) ) {
+		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) ) {
 			return;
 		}

@@ -178,8 +178,8 @@ class WebhookHandler {
 		$status         = $event['resource']['status'] ?? null;
 		$reason         = $event['resource']['status_details']['reason'] ?? 'Unknown';
 		$order->set_transaction_id( $transaction_id );
-		$order->update_meta_data( '_paypal_capture_id', $transaction_id );
-		$order->update_meta_data( '_paypal_status', $status );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, $transaction_id );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $status );
 		/* translators: %s: reason */
 		$order->update_status( OrderStatus::ON_HOLD, sprintf( __( 'Payment pending (reason: %s).', 'woocommerce' ), $reason ) );
 		$order->save();
@@ -202,14 +202,14 @@ class WebhookHandler {
 		}

 		// Skip if the payment is already processed.
-		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( '_paypal_status', true ) ) {
+		if ( PayPalConstants::STATUS_COMPLETED === $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) ) {
 			return;
 		}

 		$transaction_id = $event['resource']['id'] ?? null;
 		$order->set_transaction_id( $transaction_id );
-		$order->update_meta_data( '_paypal_authorization_id', $transaction_id );
-		$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_AUTHORIZED );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, $transaction_id );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_AUTHORIZED );
 		$order->add_order_note(
 			sprintf(
 				/* translators: %1$s: Transaction ID */
diff --git a/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-test.php b/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-test.php
index 6b04c50f38..30b8b7ad7a 100644
--- a/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-test.php
+++ b/plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-test.php
@@ -6,6 +6,9 @@
  */

 declare(strict_types=1);
+
+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;
+
 /**
  * Class WC_Gateway_Paypal_Test.
  */
@@ -30,7 +33,7 @@ class WC_Gateway_Paypal_Test extends \WC_Unit_Test_Case {
 		$order = WC_Helper_Order::create_order();
 		$order->save();

-		$order->update_meta_data( '_paypal_status', 'pending' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, 'pending' );
 		$order->set_transaction_id( $this->transaction_id_26960 );
 		$order->set_payment_method( WC_Gateway_Paypal::ID );
 		$order->save();
@@ -57,7 +60,7 @@ class WC_Gateway_Paypal_Test extends \WC_Unit_Test_Case {
 		$order = WC_Helper_Order::create_order();
 		$order->save();

-		$order->update_meta_data( '_paypal_status', 'pending' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, 'pending' );
 		$order->set_transaction_id( $this->transaction_id_26960 );
 		$order->set_payment_method( WC_Gateway_Paypal::ID );
 		$order->save();
@@ -101,7 +104,7 @@ class WC_Gateway_Paypal_Test extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_payment() {
 		$order = WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_status', 'pending' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, 'pending' );
 		$order->set_transaction_id( $this->transaction_id_26960 );
 		$order->set_payment_method( WC_Gateway_Paypal::ID );
 		$order->save();
@@ -114,7 +117,7 @@ class WC_Gateway_Paypal_Test extends \WC_Unit_Test_Case {
 		remove_filter( 'pre_http_request', array( $this, '__return_paypal_success' ) );

 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'Completed', $order->get_meta( '_paypal_status' ) );
+		$this->assertEquals( 'Completed', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS ) );
 	}

 	/**
@@ -167,7 +170,7 @@ class WC_Gateway_Paypal_Test extends \WC_Unit_Test_Case {

 		$this->assertEquals( $order->get_meta( 'Payment type' ), WC_Gateway_Paypal::ID );
 		$this->assertEquals( $order->get_transaction_id(), $this->transaction_id_26960 );
-		$this->assertEquals( $order->get_meta( '_paypal_status' ), 'Completed' );
+		$this->assertEquals( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS ), 'Completed' );
 	}

 	/**
diff --git a/plugins/woocommerce/tests/php/src/Gateways/PayPal/HelperTest.php b/plugins/woocommerce/tests/php/src/Gateways/PayPal/HelperTest.php
index 00e2575c31..b0ac2c943a 100644
--- a/plugins/woocommerce/tests/php/src/Gateways/PayPal/HelperTest.php
+++ b/plugins/woocommerce/tests/php/src/Gateways/PayPal/HelperTest.php
@@ -9,6 +9,7 @@ declare(strict_types=1);

 namespace Automattic\WooCommerce\Tests\Gateways\PayPal;

+use Automattic\WooCommerce\Gateways\PayPal\Constants as PayPalConstants;
 use Automattic\WooCommerce\Gateways\PayPal\Helper;

 /**
@@ -488,7 +489,7 @@ class HelperTest extends \WC_Unit_Test_Case {
 		$this->assertEquals( 'Suite 100', $order->get_billing_address_2() );

 		// Verify meta flag was set.
-		$this->assertEquals( 'yes', $order->get_meta( '_paypal_addresses_updated', true ) );
+		$this->assertEquals( 'yes', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, true ) );

 		// Clean up.
 		$order->delete( true );
@@ -530,7 +531,7 @@ class HelperTest extends \WC_Unit_Test_Case {
 		// Order should not be modified.
 		$this->assertEquals( $original_shipping_first_name, $order->get_shipping_first_name() );
 		$this->assertEquals( $original_billing_first_name, $order->get_billing_first_name() );
-		$this->assertEmpty( $order->get_meta( '_paypal_addresses_updated', true ) );
+		$this->assertEmpty( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, true ) );

 		// Clean up.
 		$order->delete( true );
@@ -541,7 +542,7 @@ class HelperTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_update_addresses_in_order_skips_already_updated() {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_addresses_updated', 'yes' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ADDRESSES_UPDATED, 'yes' );
 		$order->save();

 		$original_shipping_first_name = $order->get_shipping_first_name();
diff --git a/plugins/woocommerce/tests/php/src/Gateways/PayPal/RequestTest.php b/plugins/woocommerce/tests/php/src/Gateways/PayPal/RequestTest.php
index 8eea09d864..5682e0ab25 100644
--- a/plugins/woocommerce/tests/php/src/Gateways/PayPal/RequestTest.php
+++ b/plugins/woocommerce/tests/php/src/Gateways/PayPal/RequestTest.php
@@ -449,8 +449,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_skipped_when_already_captured_via_capture_id(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_capture_id', 'CAPTURE_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, 'CAPTURE_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -477,7 +477,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		// Verify capture_auth API was not called.
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when payment already captured' );
 		// Verify status was not changed.
-		$this->assertEquals( 'CAPTURE_123', $order->get_meta( '_paypal_capture_id', true ) );
+		$this->assertEquals( 'CAPTURE_123', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
 	}

 	/**
@@ -503,8 +503,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_skipped_when_status_already_captured( string $status ): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_status', $status );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, $status );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -531,7 +531,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		// Verify capture_auth API was not called.
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when status is ' . $status );
 		// Verify status remained the same.
-		$this->assertEquals( $status, $order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( $status, $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 	}

 	/**
@@ -541,8 +541,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_succeeds_with_http_200(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -572,7 +572,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$order = wc_get_order( $order->get_id() );
 		$this->assertEquals(
 			PayPalConstants::STATUS_CAPTURED,
-			$order->get_meta( '_paypal_status', true )
+			$order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true )
 		);
 	}

@@ -583,9 +583,9 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_fails(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
-		$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_AUTHORIZED );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_AUTHORIZED );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -625,9 +625,9 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$this->assertStringContainsString( 'PayPal capture authorized payment failed', $notes[0]->content );
 		$this->assertStringContainsString( $debug_id, $notes[0]->content );
 		// Verify capture ID was not set.
-		$this->assertEmpty( $order->get_meta( '_paypal_capture_id', true ) );
+		$this->assertEmpty( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
 		// Verify status was not updated.
-		$this->assertEquals( PayPalConstants::STATUS_AUTHORIZED, $order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( PayPalConstants::STATUS_AUTHORIZED, $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 	}

 	/**
@@ -637,9 +637,9 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_404_error_and_sets_authorization_checked_flag(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
-		$order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_AUTHORIZED );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_AUTHORIZED );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -676,11 +676,11 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$this->assertStringContainsString( 'PayPal capture authorized payment failed', $notes[0]->content );
 		$this->assertStringContainsString( 'Authorization ID: ' . $authorization_id . ' not found', $notes[0]->content );
 		// Verify authorization_checked flag was set.
-		$this->assertEquals( 'yes', $order->get_meta( '_paypal_authorization_checked', true ), 'Expected _paypal_authorization_checked flag to be set to yes' );
+		$this->assertEquals( 'yes', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, true ), 'Expected _paypal_authorization_checked flag to be set to yes' );
 		// Verify capture ID was not set.
-		$this->assertEmpty( $order->get_meta( '_paypal_capture_id', true ) );
+		$this->assertEmpty( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
 		// Verify status was not updated.
-		$this->assertEquals( PayPalConstants::STATUS_AUTHORIZED, $order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( PayPalConstants::STATUS_AUTHORIZED, $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 	}

 	/**
@@ -690,8 +690,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_wp_error_response(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -737,8 +737,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_request_includes_correct_parameters(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
 		$order->save();

 		$captured_request       = null;
@@ -784,7 +784,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_retrieves_authorization_id_from_api(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		// Don't set _paypal_authorization_id.
 		$order->save();

@@ -845,7 +845,7 @@ class RequestTest extends \WC_Unit_Test_Case {

 		// Verify authorization ID was stored.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'AUTH_3', $order->get_meta( '_paypal_authorization_id', true ) );
+		$this->assertEquals( 'AUTH_3', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, true ) );
 	}

 	/**
@@ -855,7 +855,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_skipped_when_api_returns_capture_data(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -921,8 +921,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when capture already exists' );
 		// Verify capture ID was stored and no capture request was made.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'CAPTURE_2', $order->get_meta( '_paypal_capture_id', true ) );
-		$this->assertEquals( PayPalConstants::STATUS_COMPLETED, $order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( 'CAPTURE_2', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
+		$this->assertEquals( PayPalConstants::STATUS_COMPLETED, $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 	}

 	/**
@@ -932,7 +932,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_skipped_when_authorization_status_is_captured(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -986,7 +986,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when authorization already captured' );
 		// Verify status was updated but no capture request was made.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( PayPalConstants::STATUS_CAPTURED, $order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( PayPalConstants::STATUS_CAPTURED, $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 	}

 	/**
@@ -996,8 +996,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_authorization_checked_flag_prevents_repeated_calls(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_checked', 'yes' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, 'yes' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -1024,7 +1024,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		// Verify capture_auth API was not called.
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when authorization_checked flag is set' );
 		// Verify capture ID was not set.
-		$this->assertEmpty( $order->get_meta( '_paypal_capture_id', true ) );
+		$this->assertEmpty( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
 	}

 	/**
@@ -1034,7 +1034,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_api_exception_during_retrieval(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -1070,7 +1070,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$this->assertEquals( 0, $capture_api_call_count, 'Expected no capture_auth API call when order details retrieval fails' );
 		// Verify capture ID was not set.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEmpty( $order->get_meta( '_paypal_capture_id', true ) );
+		$this->assertEmpty( $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_CAPTURE_ID, true ) );
 	}

 	/**
@@ -1080,7 +1080,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_selects_most_recent_authorization(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		add_filter(
@@ -1140,7 +1140,7 @@ class RequestTest extends \WC_Unit_Test_Case {

 		// Verify the most recent authorization ID was stored.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'AUTH_NEWEST', $order->get_meta( '_paypal_authorization_id', true ) );
+		$this->assertEquals( 'AUTH_NEWEST', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, true ) );
 	}

 	/**
@@ -1150,8 +1150,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_respects_test_mode_setting(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
 		$order->save();

 		// Test with test mode enabled.
@@ -1194,7 +1194,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_empty_authorization_array(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		add_filter(
@@ -1238,7 +1238,7 @@ class RequestTest extends \WC_Unit_Test_Case {

 		// Verify authorization_checked flag was set.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'yes', $order->get_meta( '_paypal_authorization_checked', true ) );
+		$this->assertEquals( 'yes', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, true ) );
 	}

 	/**
@@ -1248,7 +1248,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_invalid_update_time(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		add_filter(
@@ -1303,7 +1303,7 @@ class RequestTest extends \WC_Unit_Test_Case {

 		// Verify the valid authorization was used.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'AUTH_VALID', $order->get_meta( '_paypal_authorization_id', true ) );
+		$this->assertEquals( 'AUTH_VALID', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, true ) );
 	}

 	/**
@@ -1313,7 +1313,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_missing_purchase_units(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
 		$order->save();

 		add_filter(
@@ -1350,7 +1350,7 @@ class RequestTest extends \WC_Unit_Test_Case {

 		// Verify authorization_checked flag was set.
 		$order = wc_get_order( $order->get_id() );
-		$this->assertEquals( 'yes', $order->get_meta( '_paypal_authorization_checked', true ) );
+		$this->assertEquals( 'yes', $order->get_meta( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_CHECKED, true ) );
 	}

 	/**
@@ -1360,8 +1360,8 @@ class RequestTest extends \WC_Unit_Test_Case {
 	 */
 	public function test_capture_authorized_payment_handles_auth_already_captured_errors(): void {
 		$order = \WC_Helper_Order::create_order();
-		$order->update_meta_data( '_paypal_order_id', 'PAYPAL_ORDER_123' );
-		$order->update_meta_data( '_paypal_authorization_id', 'AUTH_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_ORDER_ID, 'PAYPAL_ORDER_123' );
+		$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_AUTHORIZATION_ID, 'AUTH_123' );
 		$order->save();

 		$capture_api_call_count = 0;
@@ -1407,7 +1407,7 @@ class RequestTest extends \WC_Unit_Test_Case {
 		$order = wc_get_order( $order->get_id() );
 		$this->assertEquals(
 			PayPalConstants::STATUS_CAPTURED,
-			$order->get_meta( '_paypal_status', true )
+			$order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true )
 		);
 	}

diff --git a/plugins/woocommerce/tests/php/src/Gateways/PayPal/WebhookHandlerTest.php b/plugins/woocommerce/tests/php/src/Gateways/PayPal/WebhookHandlerTest.php
index 33368ed439..576a7a9519 100644
--- a/plugins/woocommerce/tests/php/src/Gateways/PayPal/WebhookHandlerTest.php
+++ b/plugins/woocommerce/tests/php/src/Gateways/PayPal/WebhookHandlerTest.php
@@ -113,7 +113,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {

 		// Verify order was updated.
 		$test_order = wc_get_order( $test_order->get_id() );
-		$this->assertEquals( 'APPROVED', $test_order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( 'APPROVED', $test_order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );

 		// Clean up.
 		$test_order->delete( true );
@@ -127,7 +127,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {
 	public function test_process_checkout_order_approved_skips_already_processed(): void {
 		$test_order = \WC_Helper_Order::create_order();
 		$test_order->set_payment_method( 'paypal' );
-		$test_order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_COMPLETED );
+		$test_order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_COMPLETED );
 		$test_order->save();

 		$custom_id_data = array(
@@ -157,7 +157,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {

 		// Verify order was not updated.
 		$test_order = wc_get_order( $test_order->get_id() );
-		$this->assertEquals( 'COMPLETED', $test_order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( 'COMPLETED', $test_order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );

 		$test_order->delete( true );
 	}
@@ -194,7 +194,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {

 		// Verify order was updated.
 		$test_order = wc_get_order( $test_order->get_id() );
-		$this->assertEquals( 'COMPLETED', $test_order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( 'COMPLETED', $test_order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );

 		// Clean up.
 		$test_order->delete( true );
@@ -208,7 +208,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {
 	public function test_process_payment_capture_completed_skips_already_processed(): void {
 		$test_order = \WC_Helper_Order::create_order();
 		$test_order->set_payment_method( 'paypal' );
-		$test_order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_COMPLETED );
+		$test_order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_COMPLETED );
 		$test_order->save();

 		$custom_id_data = array(
@@ -233,7 +233,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {
 		$this->webhook_handler->process_webhook( $this->mock_request );

 		$test_order = wc_get_order( $test_order->get_id() );
-		$this->assertEquals( 'COMPLETED', $test_order->get_meta( '_paypal_status', true ) );
+		$this->assertEquals( 'COMPLETED', $test_order->get_meta( PayPalConstants::PAYPAL_ORDER_META_STATUS, true ) );
 		$this->assertEquals( $original_transaction_id, $test_order->get_transaction_id() );

 		$test_order->delete( true );
@@ -286,7 +286,7 @@ class WebhookHandlerTest extends \WC_Unit_Test_Case {
 	public function test_process_payment_authorization_created_skips_already_processed(): void {
 		$test_order = \WC_Helper_Order::create_order();
 		$test_order->set_payment_method( 'paypal' );
-		$test_order->update_meta_data( '_paypal_status', PayPalConstants::STATUS_COMPLETED );
+		$test_order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_STATUS, PayPalConstants::STATUS_COMPLETED );
 		$test_order->save();

 		$custom_id_data = array(