Helper
in package
PayPal Helper Class
Helper methods for PayPal gateway operations including order validation, data redaction, and address updates.
Tags
Table of Contents
- get_wc_order_from_paypal_custom_id() : WC_Order|null
- Get the WC order from the PayPal custom ID.
- is_country_supported_by_paypal() : bool
- Check if a country code is supported by PayPal.
- 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.
- complete_order_after_address_confirmation() : void
- Mark a captured order paid after its approved address is saved.
- normalize_address_field() : string
- Normalize harmless case and surrounding whitespace differences in addresses.
- validate_shipping_address() : bool
- Check the final destination against the address used to price this attempt.
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_country_supported_by_paypal()
Check if a country code is supported by PayPal.
public
static is_country_supported_by_paypal(string $country_code) : bool
Parameters
- $country_code : string
-
Country code.
Return values
bool — True if the country is supported by PayPal, false otherwise.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
string — The 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
mixed — The 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 —complete_order_after_address_confirmation()
Mark a captured order paid after its approved address is saved.
private
static complete_order_after_address_confirmation(WC_Order $order) : void
Parameters
- $order : WC_Order
-
The order object.
Return values
void —normalize_address_field()
Normalize harmless case and surrounding whitespace differences in addresses.
private
static normalize_address_field(mixed $value) : string
Parameters
- $value : mixed
-
Address field.
Return values
string — Normalized value.validate_shipping_address()
Check the final destination against the address used to price this attempt.
private
static validate_shipping_address(WC_Order $order, array<string|int, mixed> $details[, bool $confirmed = false ]) : bool
Parameters
- $order : WC_Order
-
The order object.
- $details : array<string|int, mixed>
-
The PayPal order details.
- $confirmed : bool = false
-
Whether an earlier approval already confirmed this attempt's addresses.
