Automattic\WooCommerce\StoreApi\Schemas\V1

CheckoutSchema::prepare_payment_details_for_response()protectedWC 1.0

This prepares the payment details for the response so it's following the schema where it's an array of objects.

Method of the class: CheckoutSchema{}

No Hooks.

Return

Array. An array of objects where each object has the key and value as distinct properties.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_payment_details_for_response( $payment_details );
$payment_details(array) (required)
An array of payment details from the processed payment.

CheckoutSchema::prepare_payment_details_for_response() code WC 8.7.0

protected function prepare_payment_details_for_response( array $payment_details ) {
	return array_map(
		function( $key, $value ) {
			return (object) [
				'key'   => $key,
				'value' => $value,
			];
		},
		array_keys( $payment_details ),
		$payment_details
	);
}