我正在按照其文档中的说明使用 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/