Skip to content

Commit

Permalink
Merge pull request #215 from phgoncalves/master
Browse files Browse the repository at this point in the history
hotfix capture payments
  • Loading branch information
Pedro Gonçalves authored Sep 18, 2019
2 parents 299178d + b9be528 commit 55b69bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
39 changes: 15 additions & 24 deletions src/MercadoPago/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,33 +316,24 @@ protected function _attributesToJson($entity, &$result)
}

protected function _arrayDiffRecursive($firstArray, $secondArray)
{
{
$difference = [];
foreach ($firstArray as $firstKey => $firstValue) {

if ($firstValue instanceof Entity){
$firstValue = $firstValue->toArray();

foreach (array_keys($secondArray) as $key) {
$secondArray[$key] = $secondArray[$key] instanceof MercadoPagoEntity ? $secondArray[$key]->toArray() : $secondArray[$key];
if (array_key_exists($key, $firstArray) && $firstArray[$key] instanceof MercadoPagoEntity){
$firstArray[$key] = $firstArray[$key]->toArray();
}

if (is_array($firstValue)) {
if (!array_key_exists($firstKey, $secondArray) || !is_array($secondArray[$firstKey])) {

} else {
$secondValue = $secondArray[$firstKey];
if ($secondValue instanceof Entity){
$secondValue = $secondValue->toArray();
}
$newDiff = $this->_arrayDiffRecursive($firstValue, $secondValue);
if (!empty($newDiff)) {
$difference[$firstKey] = $newDiff;
}
}
} else {
if (!array_key_exists($firstKey, $secondArray) || $secondArray[$firstKey] != $firstValue) {
if ($firstKey != "_last") {
$difference[$firstKey] = $secondArray[$firstKey];
}

if (!array_key_exists($key, $firstArray)){
$difference[$key] = $secondArray[$key];
}elseif (is_array($firstArray[$key]) && is_array($secondArray[$key])) {
$newDiff = $this->_arrayDiffRecursive($firstArray[$key], $secondArray[$key]);
if (!empty($newDiff)) {
$difference[$key] = $newDiff;
}
}elseif ($firstArray[$key] !== $secondArray[$key]){
$difference[$key] = $secondArray[$key];
}
}
return $difference;
Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
class Version
{
public static
$_VERSION = '1.4.0';
$_VERSION = '1.4.1';
}

0 comments on commit 55b69bc

Please sign in to comment.