php - 如何使用 PHP 在 flutterwave 中获取 token

标签 php flutterwave

我正在按照其文档中的说明使用 flutterwave 支付网关 http://docs.flutterwave.com/card-payments/#tokenize-and-charge 我有以下代码,显然应该返回一个 token ,我可以用它向用户收费。

 require_once("../../lib/functions.php");

    // The data to send to the API
    $merchantKey = "****";
    $apiKey = "*****";
    $card = [
        "amount"=> encrypt3Des("200", $apiKey),
        "authmodel"=> encrypt3Des("PIN", $apiKey),
        "cardno"=> encrypt3Des("***********", $apiKey),
        "currency"=> encrypt3Des("NGN", $apiKey),
        "custid"=> encrypt3Des("11232", $apiKey),   
        "cvv"=> encrypt3Des("***", $apiKey),
        "pin"=> encrypt3Des("***", $apiKey),//"(Optional:Only needed where authmodel is PIN) Encrypted PIN",
        //"bvn"=> "(Optional:Only needed where authmodel is BVN) Encrypted BVN",

        "expirymonth"=> encrypt3Des("**", $apiKey),//"Encrypted Expiry Month",
        "expiryyear"=> encrypt3Des("****", $apiKey), //"Encrypted Expiry Year",
        "merchantid"=> $merchantKey,//"Merchant Key",
        "narration"=> encrypt3Des("Payment for service", $apiKey),//"Encrypted Narration",
    ];

// Setup cURL
$ch = curl_init('http://staging1flutterwave.co:8080/pwc/rest/card/mvva/pay');
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HTTPHEADER => array(
        //'Authorization: '.$authToken,
        'Content-Type: application/json'
    ),
    CURLOPT_POSTFIELDS => json_encode($card)
));

// Send the request
$response = curl_exec($ch);

// Check for errors
if($response === FALSE){
    die(curl_error($ch));
}

// Decode the response
$responseData = json_decode($response, TRUE);
var_dump($responseData);
// Print the date from the response
//echo $responseData['published'];

但它响应如下

array(2) { ["data"]=> array(6) { ["responsecode"]=> string(5) "RR-R3" ["responsemessage"]=> string(50) "Sorry, you need to add 'CardToken' to your request" ["otptransactionidentifier"]=> NULL ["transactionreference"]=> string(4) "null" ["responsehtml"]=> NULL ["responsetoken"]=> NULL } ["status"]=> string(7) "success" }

我在这里错过了什么?

最佳答案

洛德莫尔

为什么不试试 Flutterwave PHP 库,网址为 https://github.com/flutterwave/flutterwave-php .

可以更轻松地查看您的有效负载并进行调试。

另请注意,PIN 验证模型不适用于 VISA 卡,如果您使用 Visa 卡进行测试,请使用 BVN、VBVSECURECODE 或 RANDOM_DEBIT 作为验证模型。

关于php - 如何使用 PHP 在 flutterwave 中获取 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39558374/

相关文章:

javascript - 阻止 url 直接访问 index.php,除非用户单击另一个特定 html 文件(例如 index.html)上的链接

php - Htaccess 和上传

php - 使用 PHP 从 Google Chrome 浏览器书签导出中提取数据

php - 在 Symfony 1.4 中的每个 Action 后执行代码

php - 使用php下载最新的wordpress zip文件?

android - Flutterwave live - 传递了无效的公钥

payment-gateway - Flutterwave Rave 内联结帐集成错误