Skip to content

Export compliance deserialization failed #52

@fgarnier-hublot

Description

@fgarnier-hublot

There is bad deserialization of the export compliance response for these fields from this class type:
CyberSource\Model\RiskV1ExportComplianceInquiriesPost201ResponseExportComplianceInformationWatchListMatches

addresses
The mapping is incorrect, we have address but there is addresses in the PHP mapping class : vendor/cybersource/rest-client-php/lib/Model/RiskV1ExportComplianceInquiriesPost201ResponseExportComplianceInformationWatchListMatches.php

aliases
programs
The deserialization failed with string[] type in the file vendor/cybersource/rest-client-php/lib/ObjectSerializer.php

After my workaround

} elseif (strcasecmp(substr($class, -2), '[]') === 0) {
            $subClass = substr($class, 0, -2);
            $values = [];

            if (!is_array($data)) {
                if (in_array($subClass, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
                    $values[] = self::deserialize($data, $subClass, null);
                }
            } else {
                foreach ($data as $key => $value) {
                    $values[] = self::deserialize($value, $subClass, null);
                }
            }

            return $values;
        }
            if (isset($data->address)) {
                $data->addresses = $data->address;
            }

I succeed with this type of response:

[0] => CyberSource\Model\RiskV1ExportComplianceInquiriesPost201ResponseExportComplianceInformationWatchListMatches Object
(
    [container:protected] => Array
        (
            [addresses] => Array
                (
                    [0] => [c/o COCINA DE TIJUANA, S. DE R.L. DE C.V.,Tijuana,Baja California,null,, c/o HACIENDA CIEN ANOS DE TIJUANA, S. DE R.L. DE C.V.,Tijuana,Baja California,null,, c/o MEXGLOBO, S.A. DE C.V.,Tijuana,Baja California,null,, c/o MULTISERVICIOS AGSA, S.A. DE C.V.,Tijuana,Baja California,null,, Calle Garita de Otay No. 1408, Colonia Mesa de Otay,Tijuana,Baja California,null,, Calle Gladiolas No. 28, Fraccionamiento Del Prado,Tijuana,Baja California,null,, Cll Gladiolas 11449, Lomas de Agua Caliente c de Las Torres c de S Fco,Tijuana,Baja California,null,22024, Priv del Cesar No. 7013, Fracc. Racial Agua Caliente,Tijuana,Baja California,null,]
                )

            [sanctionList] => Office of Foreign Assets Control
            [aliases] => Array
                (
                    [0] => [Claudia AGUIRRE SANCHEZ]
                )

            [programs] => Array
                (
                    [0] => [SDNTK]
                )

        )
)

Without my workaround, the native response:

PHP Warning:  Invalid argument supplied for foreach() in /home/ubuntu2004/Projects/cybersource-rest-samples-php/vendor/cybersource/rest-client-php/lib/ObjectSerializer.php on line 252
[0] => CyberSource\Model\RiskV1ExportComplianceInquiriesPost201ResponseExportComplianceInformationWatchListMatches Object
(
    [container:protected] => Array
        (
            [addresses] => 
            [sanctionList] => Office of Foreign Assets Control
            [aliases] => Array
                (
                )

            [programs] => Array
                (
                )

        )

)

Thanks,

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