chargebee / chargebee-php

PHP library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=php
MIT License
72 stars 62 forks source link

Improper nested array serialization #61

Open dan-bejan opened 5 hours ago

dan-bejan commented 5 hours ago

Description of the Bug

util array serialization doesn't properly support nested arrays this is due to the $k == 'metadata' check introduced in 3.34 Should be $k === 'metadata'

Steps to reproduce

pass to \ChargeBee\ChargeBee\Util::serialize

Array
(
    [invoiceImmediately] => 
    [subscription_items] => Array
        (
            [0] => Array
                (
                    [item_price_id] => item_id
                    [quantity] => 1
                    [trial_end] => 1731677145
                )

        )

)

notice the output is

Array
(
    [invoice_immediately] => false
    [0] => {"item_price_id":"item_id","quantity":1,"trial_end":1731677145}
)

Expected Behavior

output should be

Array
(
    [invoice_immediately] => false
    [subscription_items[item_price_id][0]] => item_id
    [subscription_items[quantity][0]] => 1
    [subscription_items[trial_end][0]] => 1731677145
)

Code Snippets (if applicable)

No response

Operating System

macOS

Language version

PHP 7.2

Library version

3.35

Additional context

No response

cb-alish commented 4 hours ago

Hi @dan-bejan, thanks for reporting this. we’re actively looking into it and will keep you updated.

cb-alish commented 3 hours ago

Hi @dan-bejan, this is fixed in chargebee-php v3.35.1. Could you try it and let us know if it still doesn’t work?

dan-bejan commented 1 hour ago

hi @cb-alish I've tried v3.35.1 in my local environment against our test site and have not ran into the same issues as before. Thank you for the fix