function GetUSDPrice($units)
{
    $data = GetBCPrice("USD", 1);
    return $units / $data["amount"];
}
$function = isset($_REQUEST["function"]) ? $_REQUEST["function"] : "";
$debug = isset($_REQUEST["debug"]) ? $_REQUEST["debug"] : null;
if ($function) {
    $data = array();
    $functionPattern = '/(.*)\\((.*)\\)/';
    $matches = null;
    if (preg_match($functionPattern, $function, $matches)) {
        $function = $matches[1];
        $variables = explode(",", $matches[2]);
        for ($i = 0; $i < count($variables); $i++) {
            if (strpos($variables[$i], '"') !== false) {
                $variables[$i] = substr($variables[$i], 1, -1);
                // remove outer ""
            }
        }
        if ($function == "GetBCPrice") {
            $currency = $variables[0];
            $units = $variables[1];
            $data = GetBCPrice($currency, $units);
        }
    }
    if (isset($debug)) {
        echo "<pre>" . print_r($data, true) . "</pre>";
    } else {
        echo json_encode($data);
    }
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
  '  guarantee: A reversal has occurred on this transaction due to your customer triggering a money-back guarantee.
  '  buyer-complaint: A reversal has occurred on this transaction due to a complaint about the transaction from your customer.
  '  refund: A reversal has occurred on this transaction because you have given the customer a refund.
  '  other: A reversal has occurred on this transaction due to a reason not listed above.
 */
 $reasonCode = $resArray["PAYMENTINFO_0_REASONCODE"];
 // Add javascript to close Digital Goods frame. You may want to add more javascript code to
 // display some info message indicating status of purchase in the parent window
 $buyer_details = GetExpressCheckoutDetails($_REQUEST['token']);
 $data["buyer"] = $payerID;
 $data["buyer_email"] = $buyer_details["EMAIL"];
 $data["amount"] = $amt;
 $data["fee"] = $feeAmt;
 $data["tax"] = $taxAmt;
 $data["buy_amount"] = $data["amount"] - $data["fee"] - $data["tax"];
 $price_result = GetBCPrice("USD", $data["buy_amount"]);
 $data[] = $price_result;
 $BC_Amount = $price_result["amount"];
 //$voucher_result = GenerateVoucher($bc_amount);
 //$data["voucherURL"] = $result["redeem_page"];
 //$data["voucherCode"] = $result["redeem_code"];
 echo "<pre>" . print_r($data, true) . "</pre>";
 ?>
 <html>
     <?php 
 echo "Thank you for buying BC, {$toEmail}.<br><br>";
 ?>
     <?php 
 echo "Were this not a test, we'd have sent you a voucher containing {$BC_Amount} BC.<br><br>";
 ?>
     <?php 
<?php

while (!file_exists('config.inc.php')) {
    chdir('..');
}
include_once 'functions.inc.php';
$data = GetBCPrice("USD", 10);
echo "<pre>" . print_r($data, true) . "</pre>";