thephpleague / omnipay-multisafepay

MultiSafepay driver for the Omnipay PHP payment processing library
MIT License
19 stars 22 forks source link

[BUG] RestRefundRequest::sendData doesn't set response data as array #22

Closed Swahjak closed 7 years ago

Swahjak commented 7 years ago
/**
 * Send the request with specified data
 *
 * @param mixed $data
 * @return RestRefundResponse
 */
public function sendData($data)
{
    $httpResponse = $this->sendRequest(
        'POST',
        '/orders/' . $data['id'] . '/refunds',
        $data
    );

    $this->response = new RestRefundResponse(
        $this,
        $httpResponse
    );

    return $this->response;
}

All other Rest Requests seem to use $httpResponse->json(). This (RestRefundRequest) causes the following error when using RestAbstractResponse::isSuccessful since it expects an array as data if (! isset($this->data['success'])) {: PHP Fatal error: Uncaught Error: Cannot use object of type Guzzle\\Http\\Message\\Response as array in /var/www/vendor/omnipay/multisafepay/src/Message/RestAbstractResponse.php:25

Will submit a pull request asap.

Swahjak commented 7 years ago

Found another issue in the same method:

$httpResponse = $this->sendRequest(
        'POST',
        '/orders/' . $data['id'] . '/refunds',
        $data
    );

This should be

$httpResponse = $this->sendRequest(
            'POST',
            '/orders/' . $data['id'] . '/refunds',
            null,
            $data
        );

Since the endpoint expects JSON. Added this fix to the pull request as well.