WooCommerce Code Reference

Helper
in package

PayPal Helper Class

Helper methods for PayPal gateway operations including order validation, data redaction, and address updates.

Tags
since
10.5.0

Table of Contents

get_wc_order_from_paypal_custom_id()  : WC_Order|null
Get the WC order from the PayPal custom ID.
is_orders_v2_migration_eligible()  : bool
Check if the merchant is eligible for migration from WPS to PPCP.
is_paypal_gateway_available()  : bool
Check if the PayPal gateway is enabled.
mask_email()  : string
Mask email address before @ keeping the full domain.
redact_data()  : mixed
Remove PII (Personally Identifiable Information) from data for logging.
update_addresses_in_order()  : void
Update the addresses in the order.

Methods

get_wc_order_from_paypal_custom_id()

Get the WC order from the PayPal custom ID.

public static get_wc_order_from_paypal_custom_id(string $custom_id) : WC_Order|null
Parameters
$custom_id : string

The custom ID string from the PayPal order.

Return values
WC_Order|null

is_orders_v2_migration_eligible()

Check if the merchant is eligible for migration from WPS to PPCP.

public static is_orders_v2_migration_eligible() : bool
Return values
bool

is_paypal_gateway_available()

Check if the PayPal gateway is enabled.

public static is_paypal_gateway_available() : bool
Return values
bool

mask_email()

Mask email address before @ keeping the full domain.

public static mask_email(string $email) : string
Parameters
$email : string

The email address to mask.

Return values
stringThe masked email address or original input if invalid.

redact_data()

Remove PII (Personally Identifiable Information) from data for logging.

public static redact_data(mixed $data) : mixed

This function recursively traverses the data array and redacts sensitive information while preserving the structure for debugging purposes.

Parameters
$data : mixed

The data to remove PII from (array, string, or other types).

Return values
mixedThe data with PII redacted.

update_addresses_in_order()

Update the addresses in the order.

public static update_addresses_in_order(WC_Order|null $order, array<string|int, mixed> $paypal_order_details) : void
Parameters
$order : WC_Order|null

The order object.

$paypal_order_details : array<string|int, mixed>

The PayPal order details.

Return values
void