WC_Connect_API_Client::send_shipping_label_refund_request PHP Method

send_shipping_label_refund_request() public method

Request a refund for a given shipping label
public send_shipping_label_refund_request ( $label_id ) : object | WP_Error
$label_id integer
return object | WP_Error
        public function send_shipping_label_refund_request($label_id)
        {
            return $this->request('POST', '/shipping/label/' . $label_id . '/refund');
        }

Usage Example

 public function update_items($request)
 {
     $response = $this->api_client->send_shipping_label_refund_request($request['label_id']);
     if (isset($response->error)) {
         $response = new WP_Error(property_exists($response->error, 'code') ? $response->error->code : 'refund_error', property_exists($response->error, 'message') ? $response->error->message : '');
     }
     if (is_wp_error($response)) {
         $response->add_data(array('message' => $response->get_error_message()), $response->get_error_code());
         $this->logger->log($response, __CLASS__);
         return $response;
     }
     // TODO: use $response->refund->amount ?
     $label_refund = (object) array('label_id' => (int) $response->label->id, 'refunded_time' => time() * 1000);
     $this->settings_store->update_label_order_meta_data($request['order_id'], $label_refund);
     return array('success' => true, 'label' => $label_refund);
 }