Expose merchant information for 2CO shopping cart
Last updated
Was this helpful?
Was this helpful?
<?php
function callRPC($Request, $hostUrl, $Debug = false) {
$curl = curl_init($hostUrl);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSLVERSION, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, false);
curl_setopt($curl, CURLOPT_PROXY, '');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'X-Avangate-Authentication: type="private" ver="2" app="2co-shopping-cart" merchant="RDGM" date="2018-01-31T13:57:44+00:00" hash="0m3ULy6dZ2xUI8CFtU0ersCootdf6wz8Z1qxN28FdXI="'
));
curl_setopt($curl, CURLOPT_COOKIE, '');
$RequestString = json_encode($Request);
curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
if ($Debug) {
var_dump($RequestString);
}
$ResponseString = curl_exec($curl);
if ($Debug) {
var_dump($ResponseString);
}
if (!empty($ResponseString)) {
$Response = json_decode($ResponseString);
if (isset($Response->result)) {
return $Response->result;
}
if (!is_null($Response->error)) {
var_dump($Request->method, $Response->error);
}
} else {
return null;
}
return null;
}
$host = 'http://api.avangate.com/soap/5.0';
try {
$merchantInformation= $client->getMerchantInformation($sessionID);
}
catch (SoapFault $e) {
echo "MerchantInformation: " . $e->getMessage();
exit;
}
var_dump("merchantInformation", $merchantInformation);