Getting Problems to integrate payfort api in php

不羁的心 提交于 2019-12-12 11:53:06

问题


I am following (https://docs.start.payfort.com/references/api/) documentation to implement Payfort payment Api but I am facing issues.Can anyone help me to resolve these?

I am using below code in 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 (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

}
?>

In above code I used print_r() and exit to print variable details but I got error like:

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

Please help me to resolve this problem. Thanks in advance for your attention.


回答1:


Please refer following documentation which I think is official PayFort integration documentation.

https://docs.payfort.com/




回答2:


You need to use an Open API key to complete your authentication.

You should find it on your Payfort control panel.

Note: your account may not be allowed to use Start API from Payfort.




回答3:


You need to use an Open API key to complete token, and use secrete key for charge see link:

How to do payment using PayFort payment gateway?



来源:https://stackoverflow.com/questions/40802416/getting-problems-to-integrate-payfort-api-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!