Skip to content

Commit

Permalink
improved exchange rate calculation
Browse files Browse the repository at this point in the history
Exchange rates are now calculated using EITHER the Mt.Gox 24-hour
average OR the Mt.Gox last trade value... whichever is better for the
merchant.
  • Loading branch information
btcgear committed May 8, 2013
1 parent fba44ca commit 7f66ade
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions upload/catalog/controller/payment/bitcoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,16 @@ public function runUpdate() {
$btcdata = $dec;

$currency = "BTC";
$value = $btcdata['return']['avg']['value'];

if ((float)$value) {
$avg_value = $btcdata['return']['avg']['value'];
$last_value = $btcdata['return']['last']['value'];

if ((float)$avg_value && (float)$last_value) {
if($avg_value < $last_value) {
$value = $avg_value;
}
else {
$value = $last_value;
}
$value = 1/$value;
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
}
Expand Down

0 comments on commit 7f66ade

Please sign in to comment.