Automatic currency converter for PayPal payment method

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 :frowning: .



[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 :cool: :

(It uses MagpieRSS)



```php /* Include RSS Reader*/
ini_set('include_path', ini_get('include_path').':./magpierss:');
require_once 'rss_fetch.inc';

/* Configure RSS Reader */
$url = 'http://currencysource.com/RSS/MXN.xml';
$rss = fetch_rss($url);

/* Open Database */
$link = mysql_connect("localhost", "pista7_cscart", "thepassword") or die("Could not connect to database");
mysql_select_db("pista7_cscart", $link);

foreach ($rss->items as $item ) {
$precio = ObtenerPrecio($item[title]);
$clave = ObtenerClaveMonetaria($item[title]);
$sql = "UPDATE cscart_currencies SET coefficient = $precio WHERE currency_code = \"$clave\"";
mysql_query($sql, $link) or die("Query failed");
echo "Precio = $precio, Clave = $clave
\n";
}

@mysql_close();


/**********************************************/

function ObtenerPrecio($s) {
$inicio = strpos($s, '(');
if ($inicio === false) {
die("Error reading RSS");
}
$fin = strpos($s, ')');
if ($fin === false) {
die("Error reading RSS");
}

$precio = substr($s, $inicio + 1, $fin - $inicio - 1);
return (1 / $precio);
}

function ObtenerClaveMonetaria($s) {
$inicio = strpos($s, '=');
if ($inicio === false) {
die("Error reading RSS");
}

$fin = strpos($s, '(');
if ($fin === false) {
die("Error reading RSS");
}

$ret = substr($s, $inicio + 1, $fin - $inicio - 1);
return trim($ret);
}
?> ```

Great idea! How do you implement the script? Do you create a new php file or add this to an existing file?