Erro ao finalizar transação
Prezados há dias consegui chegar no fim do projeto e, agora resta apenas corrigir o erro que ocorro no fim da transação. "Atualizar informações de pagamento. "
Eu tenho aqui a doc. Mas não seu exatamente o que alterar no código para corrigir isso. E preciso de ajuda,
https://www.userede.com.br/desenvolvedores/pt/produto/e-Rede#documentacao-3ds
function updatePaymentAPI($apikey, $secret, $callid, $currencyCode,$total, $subtal){
$time = time();
$query_string = "apikey=".$apikey;
$resource = "payment/info/".$callid;
$body = "{\"updateInfo\":[{\"payInfo\":{\"reason\":\"ProductionKey Test\",
\"avsResponseCode\":\"Y\",\"total\":".$total.",\"currencyCode\":\"".$currencyCode."\",
\"eventStatus\":\"Success\",\"eventType\":\"Authorize\"}},{\"orderInfo\":{\"currencyCode\":\"".$currencyCode."\",
\"discount\":0,\"eventType\":\"Confirm\",\"giftWrap\":0,\"misc\":0,
\"reason\":\"Order_placed\",\"shippingHandling\":0,\"subtotal\":".$subtal.",\"tax\":0,\"total\":".$total."}}]}";
$certificatePath = 'cert.pem';
$privateKey = 'key_9e082920-8ec4-441a-8cfa-588b0829d326.pem';
//Hash for x-pay-token
$token = $time.$resource.$query_string.$body;
$hashtoken = "xv2:".$time.":".hash_hmac('sha256', $token, $secret); //X-PAY-TOKEN String
//$url = "https://api.visa.com/wallet-services-web/".$resource."?".$query_string;
$url = "https://api.visa.com/wallet-services-web/".$resource."?".$query_string;
updatePaymentLog("=========================================\n\n");
updatePaymentLog("CallID : ".$callid."\n");
updatePaymentLog("URL : ".$url."\n\n");
updatePaymentLog("Update Payment Request Parameters : \n");
updatePaymentLog($body);
//Header
$header = (array("X-PAY-TOKEN: ".$hashtoken, "Accept: application/json", "Content-Type: application/json","X-FRAME-OPTIONS: SAMEORIGIN"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSLVERSION , 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_SSLCERT, $certificatePath);
//curl_setopt($ch, CURLOPT_SSLKEY, $privateKey);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
//getting response from server
$response = curl_exec($ch);
if(!$response) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json = "";
$ret = array(
'status' =>"",
'data' => ""
);
if($statusCode == 200) { //If success => empty Object.
$ret['status'] = 'success';
updatePaymentLog("\nUpdate Payment Info called Successfully...\n");
}else{ // Return Error Object
$ret['status'] = 'fail';
$ret['data'] = $response;
updatePaymentLog("\nSomething Went Wrong....\n");
$json = json_decode($response);
$json = json_encode($json, JSON_PRETTY_PRINT);
}
updatePaymentLog("\nStatus Code : " . $statusCode ."\n");
updatePaymentLog($json);
updatePaymentLog("\n");
echo json_encode($ret);
}
updatePaymentAPI($visaApiKey, $sharedSecret, $callid, $currencyCode, $total, $subtotal);
?>Discussão (0)
Carregando comentários...