Automattic\WooCommerce\Internal\Admin\Agentic

AgenticWebhookPayloadBuilder::build_single_refund_dataprivateWC 1.0

Build data for a single refund.

Method of the class: AgenticWebhookPayloadBuilder{}

No Hooks.

Returns

Array. Refund data.

Usage

// private - for code of main (parent) class only
$result = $this->build_single_refund_data( $refund ): array;
$refund(WC_Order_Refund) (required)
Refund object.

AgenticWebhookPayloadBuilder::build_single_refund_data() code WC 10.7.0

private function build_single_refund_data( WC_Order_Refund $refund ): array {
	$refund_type = $this->determine_refund_type( $refund );
	$amount      = abs( (float) $refund->get_total() ); // Get absolute value as refunds are negative.

	// Convert amount to minor units using MoneyFormatter (respects store currency decimals).
	$amount_in_minor_units = (int) $this->money_formatter->format( $amount );

	return array(
		'type'   => $refund_type,
		'amount' => $amount_in_minor_units,
	);
}