Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model\Api\V3::processPayment method is broken. Using array as object #549

Open
andrej22116 opened this issue Apr 5, 2024 · 0 comments
Open

Comments

@andrej22116
Copy link

The problem

I ran into the following problem: for some reason, the $response array is being used as an object.

    // CheckoutCom\Magento2\Model\Api\V3
    private function processPayment(): array
    {
           // ...

           // Get the payment
           $response = $this->getPaymentResponse($amount, $currency, $reference); // $response has an array type

           if ($this->api->isValidResponse($response)) {
                // Process the payment response
                $is3ds = property_exists($response, '_links')
                         && isset($response->_links['redirect'])
                         && isset($response->_links['redirect']['href']);

                // ...

                // Update the result
                $this->result['success'] = $response->isSuccessful();
           } else { 
                // ...
           }
    }

The method $this->api->isValidResponse expects an array and it get it, 'cause $this->getPaymentResponse return an array (or null).

// CheckoutCom\Magento2\Model\Service\ApiHandlerService
public function isValidResponse(array $response): bool
{
     // ...
}

The alleged reason

I found out that this use of $response was correct as long as the legacy checkout/checkout-sdk-php v1.0.0 was used.
I realized this by comparing the methods of the $response object used with the methods of the Model class.

Future

I do not know for what reason it turned out that this code still exists, but it causes errors that have to be fixed.
I hope that this will be fixed in future releases.

@andrej22116 andrej22116 changed the title Model/Api/V3::processPayment method is broken. Using array as object Model\Api\V3::processPayment method is broken. Using array as object Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant