简体   繁体   English

Klarna结账返回http_status_code 500内部服务器错误响应

[英]Klarna checkout returning http_status_code 500 Internal Server Error in response

I am trying to implement klarna checkout using the codes provided by them here. 我正在尝试使用他们在这里提供的代码实现klarna checkout

Implementing the process as is directed by this link -> https://docs.klarna.com/en/getting-started 按照此链接的指示实施流程 - > 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. 我正在使用docs / examples文件夹中的代码,我已经将库(src文件夹)放在正确的路径中,当我在这里创建一个测试帐户时,已经提供了klarna提供的商店ID和共享密码的eid和共享密钥

// 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, 我已经替换了所有文件中的所有eid和共享scret,并且还正确地更改了文件中的链接,

ie example.com to mywebsiteurl.com 即example.com到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. 正确设置所有内容后,当我单击docs / examples / checkout.php时,我会抛出异常,因为服务器正在响应错误代码。 The exception is thrown by BasicConnector.php by the code given below, BasicConnector.php通过下面给出的代码抛出异常,

 * 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 致命错误:未捕获的异常'Klarna_Checkout_ConnectorException',消息'{“http_status_code”:500,“http_status_message”:“内部服务器错误”,“internal_message”:“”}'在klarna / docs / examples / src / Klarna / Checkout / BasicConnector中.PHP:212

So my question is this, 所以我的问题是这个,

  1. Am I not sending a proper request, because I can see the request is created and no error is given there ? 我没有发送正确的请求,因为我可以看到请求已创建且没有给出错误?

  2. Can I do anything to get a correct response from the server? 我可以做任何事情来从服务器获得正确的响应吗?

  3. When does a server responds with an error code when cURL request is made ? 在发出cURL请求时,服务器何时响应错误代码?

Thank you for your time and help. 感谢您的时间和帮助。 I really appreciate it. 对此,我真的非常感激。

Well, the solution for such a big question was pretty simple. 那么,这个大问题的解决方案非常简单。

Setting the eid="200" and sharedsecret="test". 设置eid =“200”和sharedsecret =“test”。 Which are the test account credentials. 哪些是测试帐户凭据。

In my case I was using my original merchant account credentials. 就我而言,我使用的是原始商家帐户凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM