Skip to content

Instantly share code, notes, and snippets.

@elricstorm
Created June 11, 2011 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elricstorm/1020926 to your computer and use it in GitHub Desktop.
Save elricstorm/1020926 to your computer and use it in GitHub Desktop.
<?
// You can see the example lookup here:
// https://pay01.zong.com/zongpay/lookup.html
function getAvailablePricePoints($countries) {
//Get Price Look Up table per country in $countries
foreach ($countries as $countryCode) {
$requestXML = "<?xml version='1.0' encoding='UTF-8'?>
<requestMobilePaymentProcessEntrypoints xmlns='http://pay01.zong.com/zongpay' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://pay01.zong.com/zongpay/zongpay.xsd'>
<customerKey>$this->custKey</customerKey>
<countryCode>$countryCode</countryCode>
<items currency='USD' />
</requestMobilePaymentProcessEntrypoints>
";
//Prepare XML string to be sent as "request" POST parameter
$postVars = "request=$requestXML";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$this->priceLookUpUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$rawXml = curl_exec($ch); //TODO: check that response is correct
curl_close($ch);
//Cache Response. For demo only, flat files are used.
$filename = "zong" . $countryCode . ".txt";
$file = fopen($filename,'a') OR die ("Can't open file\n");
fwrite ($file, $rawXml);
fclose ($file);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment