/**
  * @param Payment $payment
  *
  * @return float
  */
 protected function sanitizeAmount(Payment $payment)
 {
     if ($payment->currency === 'USD') {
         return (double) $payment->amount;
     }
     try {
         $rate = CurrencyQuery::query($payment->currency);
         return $rate * $payment->amount;
     } catch (\InvalidArgumentException $e) {
         appendLog(sprintf('currency[%s] rate fail: %s', $payment->currency, $e->getMessage()));
     }
     return 0.0;
 }
Пример #2
0
<?php

/**
 * Created by PhpStorm.
 * User: Jiang Yu
 * Date: 2016/04/19
 * Time: 16:58.
 */
require __DIR__ . '/../../bootstrap.php';
spl_autoload_register(function ($className) {
    $classFile = str_replace('\\', '/', $className) . '.php';
    require $classFile;
});
$ret = \DataProvider\Currency\CurrencyQuery::query('TWD');
dump($ret);