我正在使用flutterwave支付网关,按照其文档http://docs.flutterwave.com/card-payments/#tokenize-and-charge上的说明进行操作 我有以下代码,显然应该返回一个令我可以向用户收费的令牌。
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" }
我在这里缺少什么?
答案 0 :(得分:1)
lordmaul
为什么不试试https://github.com/flutterwave/flutterwave-php提供的Flutterwave PHP库。
更容易看到您的有效负载是什么,也可以调试。
另外,请注意,PIN Auth模型不适用于VISA卡,如果您使用Visa卡进行测试,请使用BVN,VBVSECURECODE或RANDOM_DEBIT作为Auth模型。