加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在php中集成payfort api的问题

发布时间:2020-12-13 22:27:20 所属栏目:PHP教程 来源:网络整理
导读:我正在关注( https://docs.start.payfort.com/references/api/)文件来实施Payfort付款Api但我面临的问题.任何人都可以帮我解决这些问题吗? 我在Api中使用以下代码: ?phprequire_once('lib/Start.php');// Enter secret key hereStart::setApiKey('test_sec
我正在关注( https://docs.start.payfort.com/references/api/)文件来实施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","cvc" => "123"
  ),"description" => "Two widgets (test@example.com)","email" => "abc@gmail.com"
));

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.'

请帮我解决这个问题.
提前感谢您的关注.

解决方法

请参阅我认为是官方PayFort集成文档的以下文档.

https://docs.payfort.com/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读