Description
Handling PayPal errors doesn't work because of wrong type hinting.
To Reproduce
How, and what happened?
When PayPal returns an error, it gets handled and cast as an object, where it expects an HttpResponse. Seeing the following error:
TypeError: craft\commerce\paypalcheckout\gateways\Gateway::getResponseModel(): Argument #1 ($data) must be of type PayPalHttp\HttpResponse, stdClass given, called in /app/vendor/craftcms/commerce-paypal-checkout/src/gateways/Gateway.php on line 484
File "/app/vendor/craftcms/commerce-paypal-checkout/src/gateways/Gateway.php", line 366, in craft\commerce\paypalcheckout\gateways\Gateway::getResponseModel
public function getResponseModel(HttpResponse $data): RequestResponseInterface
File "/app/vendor/craftcms/commerce-paypal-checkout/src/gateways/Gateway.php", line 484, in craft\commerce\paypalcheckout\gateways\Gateway::completePurchase
return $this->getResponseModel($data);
File "/app/vendor/craftcms/commerce/src/services/Payments.php", line 423, in craft\commerce\services\Payments::completePayment
$response = $gateway->completePurchase($transaction);
File "/app/vendor/craftcms/commerce/src/controllers/PaymentsController.php", line 480, in craft\commerce\controllers\PaymentsController::actionCompletePayment
$success = $plugin->getPayments()->completePayment($transaction, $error);
File "/app/vendor/yiisoft/yii2/base/InlineAction.php", line 57, in yii\base\InlineAction::runWithParams
return call_user_func_array([$this->controller, $this->actionMethod], $args);
...
Description Handling PayPal errors doesn't work because of wrong type hinting.
To Reproduce How, and what happened?
Expected behavior Error handling to work
Additional info
Additional context See this line where a stdClass is created instead of a HttpResponse: https://github.com/craftcms/commerce-paypal-checkout/blob/develop/src/gateways/Gateway.php#L474