lt;?php
ini_set('display_errors', '1');
$url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v11';
$data = array(
"gateway_id" => "xxxxxxx", //YOUR GATEWAY ID
"password" => "xxxxxxxx", // YOOUR GATEWAY PASSWORD
"transaction_type" => "00",
"amount" => "11",
"cardholder_name" => "Test",
"cc_number" => "4111111111111111",
"cc_expiry" => "0314"
);
$data_string= json_encode($data);
// Initializing curl
$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=UTF-8;','Accept: application/json' ));
// Getting results
$result = curl_exec($ch);
// Getting jSON result string
$data_string = json_decode($result);
if ($data_string) {
if ($data_string->bank_resp_code == '100') {
print('Approved!');
} else {
print($data_string->bank_message);
}
} else {
print($result);
}
?>
Html, JAVA,DOTNET,Javascript, PHP, and JQuery Scripts and its issues with solutions
Showing posts with label curl. Show all posts
Showing posts with label curl. Show all posts
Wednesday, 6 August 2014
Thursday, 3 July 2014
How to make Bitly Url using Google API
$GoogleApiKey = $appkey; $postData = array('longUrl' => $currenturl, 'key' =>$GoogleApiKey); $jsonData = json_encode($postData); $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url'); curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); //As the API is on https, set the value for CURLOPT_SSL_VERIFYPEER to false. This will stop cURL from verifying the SSL certificate. curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curlObj, CURLOPT_HEADER, 0); curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json')); curl_setopt($curlObj, CURLOPT_POST, 1); curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData); $response = curl_exec($curlObj); $json = json_decode($response); curl_close($curlObj); return $json->id;
Subscribe to:
Posts (Atom)