2013-04-24 28 views
2

我想實現使用它們here.Klarna結賬響應

實施過程中提供的代碼klarna結賬如通過這個鏈接指向返回HTTP_STATUS_CODE 500內部服務器錯誤 - > https://docs.klarna.com/en/getting-started

我使用docs/examples文件夾中的代碼,我已經將庫(src文件夾)放在正確的路徑中,當我創建一個測試帳戶時,提供了由klarna提供的商店ID和共享密鑰的eid和共享密鑰here.

// Merchant ID 
$eid = 'eid'; 

// Shared secret 
$sharedSecret = 'sharedsecret'; 

我已經取代所有的EID和共享scret中的所有文件,也改變了正確的文件的鏈接,

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}'; 

正確設置所有的事情後,當我點擊文檔/例子/ checkout.php我得到了一個異常,因爲服務器正在響應一個錯誤代碼。唯一的例外是通過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() 
     ); 
    } 
} 

的錯誤是

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

所以我的問題是這樣的,

  1. 我不是發送正確的請求,因爲我可以看到創建的請求是 並且沒有給出錯誤?

  2. 我能做任何事情從服務器獲得正確的響應嗎?

  3. 當cURL請求爲 時,服務器何時響應錯誤代碼?

謝謝你的時間和幫助。對此,我真的非常感激。

回答

5

那麼,這樣一個大問題的解決方案非常簡單。

設置eid =「200」和sharedsecret =「test」。哪些是測試帳戶憑證。

在我的情況下,我使用我的原始商家帳戶憑證。

+2

我該怎麼知道? – 2013-07-04 21:36:17

+2

通過問Klarna的支持團隊:)真的這是一個恥辱。它被寫入否 - 在文檔中,我應該使用Klarna Checkout Testdrive的默認憑據集。 – Subrata 2013-07-05 09:12:09

+0

我浪費了一天多的時間!如果您需要實施先進的Klarna集成,並且您正在使用的技術沒有現成的API包裝,則他們的支持/文檔​​很多。我正在使用Ruby on Rails,並且他們完全不支持如何編寫API封裝器 - 我必須閱讀C#和PHP代碼並在Ruby中進行翻譯... – 2013-07-09 17:04:56