【问题标题】:How to do payment using PayFort payment gateway?如何使用 PayFort 支付网关进行支付?
【发布时间】:2018-04-11 08:51:56
【问题描述】:

我正在尝试使用 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;
}

【问题讨论】:

    标签: php payfort


    【解决方案1】:

    我找到答案了

     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”开始收费。 它工作正常。谢谢大家。

    【讨论】:

    • 嗨,我们如何获得'open_key'和'secret_key'??
    • 这个包叫什么名字?谁能给我这个作曲家包的链接?我怎样才能安装这个包来使用这个代码?
    猜你喜欢
    • 2016-11-30
    • 2017-06-10
    • 2020-05-19
    • 2017-12-06
    • 2012-09-05
    • 2015-11-21
    • 1970-01-01
    • 2019-10-30
    • 2016-02-25
    相关资源
    最近更新 更多