WC_Gateway_Paypal_Response::get_paypal_order( string $raw_custom )
Get the order from the PayPal ‘Custom’ variable.
Description Description
Parameters Parameters
- $raw_custom
-
(Required) JSON Data passed back by PayPal.
Return Return
(bool|WC_Order) object
Source Source
File: includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php
protected function get_paypal_order( $raw_custom ) { // We have the data in the correct format, so get the order. $custom = json_decode( $raw_custom ); if ( $custom && is_object( $custom ) ) { $order_id = $custom->order_id; $order_key = $custom->order_key; } else { // Nothing was found. WC_Gateway_Paypal::log( 'Order ID and key were not found in "custom".', 'error' ); return false; } $order = wc_get_order( $order_id ); if ( ! $order ) { // We have an invalid $order_id, probably because invoice_prefix has changed. $order_id = wc_get_order_id_by_order_key( $order_key ); $order = wc_get_order( $order_id ); } if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) { WC_Gateway_Paypal::log( 'Order Keys do not match.', 'error' ); return false; } return $order; }