CyberSource / CyberSource/cybersource-rest-samples-php
Export compliance deserialization failed
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 31
- Forks
- 51
- Avg merge
- 36m
- Merged PRs (30d)
- 1
Description
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,
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vendor/cybersource/rest-client-php/lib/ObjectSerializer.php and the generated RiskV1ExportComplianceInquiriesPost201ResponseExportComplianceInformationWatchListMatches.php mapping, then reproduce the export compliance response shown in the issue. Done means addresses, aliases, and programs deserialize into the expected arrays without the foreach warning or empty values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100