WC_Gateway_Paypal_Helper::redact_data
Remove PII (Personally Identifiable Information) from data for logging.
This function recursively traverses the data array and redacts sensitive information while preserving the structure for debugging purposes.
Method of the class: WC_Gateway_Paypal_Helper{}
No Hooks.
Returns
Mixed. The data with PII redacted.
Usage
$result = WC_Gateway_Paypal_Helper::redact_data( $data );
- $data(mixed) (required)
- The data to remove PII from (array, string, or other types).
WC_Gateway_Paypal_Helper::redact_data() WC Gateway Paypal Helper::redact data code WC 10.4.3
public static function redact_data( $data ) {
if ( ! is_array( $data ) ) {
return $data;
}
$redacted_data = array();
foreach ( $data as $key => $value ) {
// Skip redacting the payee information as it belongs to the store merchant.
if ( 'payee' === $key ) {
$redacted_data[ $key ] = $value;
continue;
}
// Mask the email address.
if ( 'email_address' === $key || 'email' === $key ) {
$redacted_data[ $key ] = self::mask_email( $value );
continue;
}
if ( is_array( $value ) ) {
$redacted_data[ $key ] = self::redact_data( $value );
} elseif ( in_array( $key, WC_Gateway_Paypal_Constants::FIELDS_TO_REDACT, true ) ) {
$redacted_data[ $key ] = '[redacted]';
} else {
// Keep non-PII data as is.
$redacted_data[ $key ] = $value;
}
}
return $redacted_data;
}