Automattic\WooCommerce\Gateways\PayPal

Request::generate_shipping_callback_tokenprivateWC 1.0

Generate and store a shipping callback token for the order. The token is stored in the database cache and can be validated later.

Method of the class: Request{}

No Hooks.

Returns

String. The generated token.

Usage

// private - for code of main (parent) class only
$result = $this->generate_shipping_callback_token( $order ): string;
$order(WC_Order) (required)
The order object.

Request::generate_shipping_callback_token() code WC 10.7.0

private function generate_shipping_callback_token( WC_Order $order ): string {
	$token = bin2hex( random_bytes( 32 ) );

	// Store the token in order meta for validation.
	$order->update_meta_data( PayPalConstants::PAYPAL_ORDER_META_SHIPPING_CALLBACK_TOKEN, $token );
	$order->save();

	return $token;
}