Hi!,
I am currently building my online store in Mexico. I have all the prices in Mexican Pesos (MXN).
The problem is that PayPal accepts USD instead of MXN .
[SIZE=β4β]WISH:[/SIZE]
It would be great to implement into the CS-Cartβs PayPal processor an automatic currency converter, to see the payment in USD equivalent to MXN.
[SIZE=β4β]IMPLEMENTATION IDEAS:[/SIZE]
To have an accurate conversion, there is a free RSS feed at [URL=βhttp://currencysource.com/rss_currencyexchangerates.htmlβ]http://currencysource.com/rss_currencyexchangerates.html[/URL]
I made an automatic updater which gets the lastest currency conversions every 4 hours with a cron job :
(It uses MagpieRSS)
<?<br />
/* Include RSS Reader*/<br />
ini_set('include_path', ini_get('include_path').':./magpierss:'); <br />
require_once 'rss_fetch.inc';<br />
<br />
/* Configure RSS Reader */<br />
$url = 'http://currencysource.com/RSS/MXN.xml';<br />
$rss = fetch_rss($url);<br />
<br />
/* Open Database */<br />
$link = mysql_connect("localhost", "pista7_cscart", "thepassword") or die("Could not connect to database");<br />
mysql_select_db("pista7_cscart", $link);<br />
<br />
foreach ($rss->items as $item ) {<br />
$precio = ObtenerPrecio($item[title]);<br />
$clave = ObtenerClaveMonetaria($item[title]);<br />
$sql = "UPDATE cscart_currencies SET coefficient = $precio WHERE currency_code = \"$clave\"";<br />
mysql_query($sql, $link) or die("Query failed");<br />
echo "Precio = $precio, Clave = $clave<br>\n";<br />
}<br />
<br />
@mysql_close();<br />
<br />
<br />
/**********************************************/<br />
<br />
function ObtenerPrecio($s) {<br />
$inicio = strpos($s, '(');<br />
if ($inicio === false) {<br />
die("Error reading RSS");<br />
}<br />
$fin = strpos($s, ')');<br />
if ($fin === false) {<br />
die("Error reading RSS");<br />
}<br />
<br />
$precio = substr($s, $inicio + 1, $fin - $inicio - 1);<br />
return (1 / $precio);<br />
}<br />
<br />
function ObtenerClaveMonetaria($s) {<br />
$inicio = strpos($s, '=');<br />
if ($inicio === false) {<br />
die("Error reading RSS");<br />
}<br />
<br />
$fin = strpos($s, '(');<br />
if ($fin === false) {<br />
die("Error reading RSS");<br />
}<br />
<br />
$ret = substr($s, $inicio + 1, $fin - $inicio - 1);<br />
return trim($ret);<br />
}<br />
?>