Klarna checkout returning http_status_code 500 Internal Server Error in response

curl, httprequest, httpresponse, magento, php

Solution

Well, the solution for such a big question was pretty simple.

Setting the eid="200" and sharedsecret="test". Which are the test account credentials.

In my case I was using my original merchant account credentials.

Problem

I am trying to implement klarna checkout using the codes provided by them here. Implementing the process as is directed by this link -> https://docs.klarna.com/en/getting-started I am using the codes inside docs/examples folder, I have placed the library(src folder) in the proper path have provided the eid and shared secret with the store-ID and Shared secret provided by klarna when I created a test account here. ``` // Merchant ID $eid = 'eid'; // Shared secret $sharedSecret = 'sharedsecret'; ``` I have replaced all the eid and shared scret in all the files and also changed the links in the files properly, i.e. example.com to mywebsiteurl.com ``` $create['purchase_country'] = 'SE'; $create['purchase_currency'] = 'SEK'; $create['locale'] = 'sv-se'; $create['merchant']['id'] = $eid; $create['merchant']['terms_uri'] = 'http://example.com/terms.html'; $create['merchant']['checkout_uri'] = 'http://example.com/checkout.php'; $create['merchant']['confirmation_uri'] = 'http://example.com/confirmation.php' . '?sid=123&klarna_order={checkout.order.uri}'; // You can not receive push notification on non publicly available uri $create['merchant']['push_uri'] = 'http://example.com/push.php' . '?sid=123&klarna_order={checkout.order.uri}'; ``` After setting all things properly, when I click docs/examples/checkout.php I get an exception thrown because the server is responding with an error code. The exception is thrown by BasicConnector.php by the code given below, ``` * Throw an exception if the server responds with an error code. * * @param Klarna_Checkout_HTTP_Response $result HTTP Response object * * @throws Klarna_Checkout_HTTP_Status_Exception * @return void */ protected function verifyResponse(Klarna_Checkout_HTTP_Response $result) { // Error Status Code recieved. Throw an exception. if ($result->getStatus() >= 400 && $result->getStatus() <= 599) { throw new Klarna_Checkout_ConnectorException( $result->getData(), $result->getStatus() ); } } ``` The error received is Fatal error: Uncaught exception 'Klarna_Checkout_ConnectorException' with message '{"http_status_code":500,"http_status_message":"Internal Server Error","internal_message":""}' in klarna/docs/examples/src/Klarna/Checkout/BasicConnector.php:212 So my question is this, Am I not sending a proper request, because I can see the request is created and no error is given there ? Can I do anything to get a correct response from the server? When does a server responds with an error code when cURL request is made ? Thank you for your time and help. I really appreciate it.

Original source