2016-11-25 42 views
4

我正在關注(https://docs.start.payfort.com/references/api/)文檔來實現Payfort支付Api,但我面臨的問題。任何人都可以幫我解決這些問題嗎?獲取問題在php中集成payfort api

我使用下面的代碼在API:

<?php 
require_once('lib/Start.php'); 

// Enter secret key here 
Start::setApiKey('test_sec_k_9d19ef5bd543507e333ba7b'); 

//Create a new token for customer 
$token = Start_Token::create(array(
    "number" => "4242424242424242", 
    "exp_month" => 06, 
    "exp_year" => 2018, 
    "cvc" => "123", 
    "name" => "Abdullah Mohammed" 
)); 

echo "<pre>"; print_r($token); exit; 

$result = Start_Charge::create(array(
    "amount" => 1000, 
    "currency" => "aed", 
    "metadata" => array(
    "reference_id" => "1234567890", 
    "tag" => "new" 
), 
    "card" => array(
    "name" => "Abdullah Ahmed", 
    "number" => "4242424242424242", 
    "exp_month" => 06, 
    "exp_year" => 2018, 
    "cvc" => "123" 
), 
    "description" => "Two widgets ([email protected])", 
    "email" => "[email protected]" 
)); 

try { 
    // Use Start's bindings... 
} catch(Start_Error_Banking $e) { 
    // Since it's a decline, Start_Error_Banking will be caught 
    print('Status is:' . $e->getHttpStatus() . "\n"); 
    print('Code is:' . $e->getErrorCode() . "\n"); 
    print('Message is:' . $e->getMessage() . "\n"); 

} catch (Start_Error_Request $e) { 
    // Invalid parameters were supplied to Start's API 

} catch (Start_Error_Authentication $e) { 
    // Invalid API key 

} catch (Start_Error_Processing $e) { 
    // Something wrong on Start's end 

} catch (Start_Error $e) { 
    // Display a very generic error to the user, and maybe send 
    // yourself an email 

} catch (Exception $e) { 
    // Something else happened, completely unrelated to Start 

} 
?> 

在上面的代碼中,我使用的print_r()和退出打印可變的細節,但我有錯誤,如:

<b>Fatal error</b>: Uncaught exception 'Start_Error_Authentication' with message 'Request can only be authenticated with an open API Key.' 

請幫我解決這個問題。 預先感謝您的關注。

回答

0

您需要使用開放的API鍵來完成您的身份驗證。

您應該在您的Payfort控制面板上找到它。

注意:您的帳戶可能不允許使用Payfort的Start API。