Skip to content

Field meta_data cannot be cleared because empty array is not converted to {} #115

@vmary-fig

Description

@vmary-fig

Description of the Bug

When updating a customer, the meta_data field (a JSON object) cannot be cleared.
Passing an empty PHP array ([]) to meta_data causes the SDK to throw an exception instead of sending {} to the API.

This makes it impossible to delete existing metadata on a customer.

Steps to reproduce

$data['meta_data'] = [];
$this->client->customer()->update($customerId, $data)->customer;

Actual behavior

{
    "error": "Invalid request exception",
    "message": "meta_data : wrong format",
    "internal_code": 12
}

Expected Behavior

The SDK should serialize [] as {} for fields of type jsonobject using https://www.php.net/manual/en/json.constants.php#constant.json-force-object
The request should clear the metadata on the customer.

Code Snippets (if applicable)

Operating System

ubuntu

Language version

PHP 8.1

Library version

v4.10

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions