Post
Topic
Board Project Development
Re: Zen Cart Bitcoin Payment Module
by
F4C3
on 09/06/2011, 22:52:50 UTC
As I understand it, zencart requires a fixed point of reference and then you put in the currency conversion for all other currencies.  There may be a way to hack around this, but what I think you are suggesting is in zencart when you create or edit a product, you want a list of currencies and how much to charge for the item for each currency regardless of conversion equality?

Otherwise, I think you may just be mixed up, if BTC is set as the default, and you set a product at that BTC value, then you would be adjusting the USD equivalent with the rate update script, and vice versa for USD is the default (frame of reference).

Anywho, as promised, here is a short little script to take the mtgox ticker and break it down into an array.  I've included a curl function to make it even easier for you.

Code:


$data 
curl_grab_page('https://mtgox.com/code/data/ticker.php');

$data str_replace('{"ticker":','',$data);
$data str_replace('}}','}',$data);

$mtgox json_decode($data,true);

var_dump($mtgox);  //This is your mtgox data, use this to perform some math and update the currency table

function 
curl_grab_page($url,$ref_url,$data,$login,$proxy,$proxystatus){
    if(
$login == 'true') {
        
$fp fopen("cookie.txt""w");
        
fclose($fp);
    }
    
$ch curl_init();
    
curl_setopt($chCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($chCURLOPT_TIMEOUT40);
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'true') {
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);

    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_REFERER$ref_url);

    
curl_setopt($chCURLOPT_HEADERFALSE);
    
curl_setopt($chCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
    
curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($chCURLOPT_POSTTRUE);
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    
ob_start();
    
$output curl_exec ($ch);
    
ob_end_clean();
    
curl_close ($ch);
    unset(
$ch);
    return  
$output;// execute the curl command    
}



edit: realized i left a header() in there.  removed.