thephpleague / omnipay-mollie

Mollie driver for the Omnipay PHP payment processing library
MIT License
62 stars 38 forks source link

Transaction failed all the time after new update #51

Closed akki44 closed 6 years ago

akki44 commented 6 years ago

Hello, after new update I am getting 404 bad request all the time. What is the exact issue?

Smitsel commented 6 years ago

Hi @akki44, do you have some more details? What is inside the $response->getMessage()?

akki44 commented 6 years ago

The JSON request do not represent an object.

Smitsel commented 6 years ago

Can you comment the code you are using? Then i can probably help u. Make sure you remove your API key though.

nickurt commented 6 years ago

Hi @Smitsel,

While I was working on my fork (for support Mollie Connect) I hitted this problem aswell [for all GET requests], the problem is in the sendRequest [AbstractMollieRequest] method

protected function sendRequest($method, $endpoint, array $data = null)
{
    $response = $this->httpClient->request(
        $method,
        $this->baseUrl . $this->apiVersion . $endpoint,
        [
            'Authorization' => 'Bearer ' . $this->getApiKey()
        ],
        json_encode($data)
    );

    // fixed it with version below ...

    $response = $this->httpClient->request(
        $method,
        $this->baseUrl . $this->apiVersion . $endpoint,
        [
             'Authorization' => 'Bearer ' . $this->getApiKey()
        ],
        ($method == 'GET') ? null : json_encode($data)
    );
}
PHP7.2.8

league/omnipay (v3.0.1) - 1514469083290aa53102440bae19313b6c8d7900
omnipay/common (v3.0.2) - 66b7934abd2d54cde8b24c5d0b1a5e733339a7e9
omnipay/mollie (v5.0.1) - e50613b5111142ea379c95344b182c83dc48a0bf
guzzlehttp/guzzle (6.3.3) - 407b0cb880ace85c9b63c5f9551db498cb2d50ba
Smitsel commented 6 years ago

Thanks guys, i've created a PR for this.