This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// 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