0

我正在尝试使用 PayFort 支付网关添加支付,但失败并显示以下错误消息:

费用未处理 请求参数无效。

请查看我的代码并提供任何说明或建议:

$api_keys = array(
    "secret_key" => "test_sec_k_965cd1f7f333f998c907b",
    "open_key"   => "test_open_k_d6830e5f0f276ebb9046"
);

/* convert 10.00 AED to cents */
$amount_in_cents = 10.00 * 100;
$currency = "AED";
$customer_email = "myMailId@gmail.com";

Start::setApiKey($api_keys["secret_key"]);

try {
    $charge = Start_Charge::create(array(
        "amount"      => $amount_in_cents,
        "currency"    => $currency,
        "card"        => '4242424242424242',
        "email"       => 'myMailId2@gmail.com',
        "ip"          => $_SERVER["REMOTE_ADDR"],
        "description" => "Charge Description"
    ));

    echo "<h1>Successfully charged 10.00 AED</h1>";
    echo "<p>Charge ID: ".$charge["id"]."</p>";
    echo "<p>Charge State: ".$charge["state"]."</p>";
    die;
} catch (Start_Error $e) {
    $error_code = $e->getErrorCode();
    $error_message = $e->getMessage();

    if ($error_code === "card_declined") {
        echo "<h1>Charge was declined</h1>";
    } else {
        echo "<h1>Charge was not processed</h1>";
    }

    echo "<p>".$error_message."</p>";
    die;
}
4

1 回答 1

0

我找到了答案

 Start::setApiKey($sadad_detail["open_key"]); //Important

 $token = Start_Token::create(array(
         "number" => $this->input->post("card-number"),
         "exp_month" => $this->input->post("expiry-month"),
         "exp_year" => $this->input->post("expiry-year"),
         "cvc" => $this->input->post("card-cvv"),
         "name" => $this->input->post("card-holder-name")
     ));
     //echo "<pre>"; print_r($token); echo '</pre>';

Start::setApiKey($sadad_detail["secret_key"]); //Important

$currency = getCustomConfigItem('currency_code');

 $charge = Start_Charge::create(array(
   "amount"      => (int)200,  
   "currency"    => $currency,
   "card"        => $token['id'],
   "email"       => 'test@gmail.com',
   "ip"          => $_SERVER["REMOTE_ADDR"],
   "description" => "Charge Description"
));

首先使用“open_key”创建令牌并使用“secret_key”开始收费。它工作正常。谢谢大家。

于 2017-11-02T11:08:05.983 回答