*/ protected function input_properties(): array { return array( 'id' => array( 'type' => 'integer', 'description' => __( 'Order id.', 'acrossai-abilities-manager' ) ), 'amount' => array( 'type' => 'string', 'description' => __( 'Amount to refund. Omit to refund everything not already refunded.', 'acrossai-abilities-manager' ) ), 'reason' => array( 'type' => 'string', 'description' => __( 'Reason, recorded on the refund.', 'acrossai-abilities-manager' ) ), 'restock_items' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Put the refunded items back into stock.', 'acrossai-abilities-manager' ) ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'refund_id' => array( 'type' => 'integer' ), 'amount' => array( 'type' => 'string' ), 'restocked' => array( 'type' => 'boolean' ), 'order' => array( 'type' => 'object', 'additionalProperties' => true ), 'note' => array( 'type' => 'string' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => false, ); } /** * @since 0.0.34 * @return bool */ protected function requires_confirmation(): bool { return true; } /** * @since 0.0.34 * @return string */ protected function confirmation_message(): string { return __( 'A refund is recorded permanently against the order and, if restocking is asked for, changes stock levels. It cannot be undone from here. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $fields = $input; unset( $fields['id'] ); return Order_Repository::refund( (int) $input['id'], $fields ); } }