2016-08-14 3 views
2

すべての支払い取引をEUR通貨で転送したいと思います。私はすでにそれを行うために私の責任あるPHPファイルを変更しましたが、私はそれがリアルタイムの為替レートを使用するように苦労しています。現時点では、これは私がPayPalに送信するものであり、それは動作します:openexchangerates.orgを使用して、PayPal支払いをEUR通貨で転送してください。

if ($selected != 'EUR') { 
          $themex_final_payable_amount = ((3.672538)*($themex_final_payable_amount))/(66.809999); 
      } 

      $p->add_field('business', trim($busi)); 
      $p->add_field('currency_code','EUR'); 
      $p->add_field('return', $ themex_paypal_success_page); 
      $p->add_field('cancel_return', $cancel_url); 
      $p->add_field('notify_url', get_bloginfo('siteurl').'/?payment_response=paypal_response'); 
      $p->add_field('item_name', $page_title); 
      $p->add_field('custom', $order_id); 
      $p->add_field('amount', ($themex_final_payable_amount)); 
      $p->submit_paypal_post(); // submit the fields to paypal 

私は、自動一日一回更新され、このAPIの答えから、変数を使用する代わりに、3.672538と66.809999のたいと思います。

JSON - latest.json 

{ 
    disclaimer: "https://openexchangerates.org/terms/", 
    license: "https://openexchangerates.org/license/", 
    timestamp: 1449877801, 
    base: "USD", 
    rates: { 
     AED: 3.672538, 
     AFN: 66.809999, 
     ALL: 125.716501, 
     AMD: 484.902502, 
     ANG: 1.788575, 
     AOA: 135.295998, 
     ARS: 9.750101, 
     AUD: 1.390866, 
     /* ... */ 
    } 
} 

問題は、私はそれらを呼び出すために方法を見つけることができないということです - AEDとAFNの今日の値を使用するように...ここでは管理ページで使用されるコードの一部(他のPHPファイルであります私はそれがこのように動作するはずですが、それはだからここ

if ($selected != 'EUR') { 
       $ themex_final_payable_amount = (($themex_AED_currency)*($ themex_final_payable_amount))/($themex_AFN_currency); 
      } 
+0

私はこの質問は簡単ですが... – Kozuns

答えて

1

は私が必要なコードの一部ですしないと思った以上に基づいて

if(isset($_POST['themex_save5'])) 
    { 
    $json = get_option('exchange_rates'); 
    $exchangeRates = json_decode($json); 

    global $themex_currencies_array; 
    foreach ($themex_currencies_array as $themex_currency) { 
     if ($themex_currency != "USD") { 
     $exchangeRates->rates->$ themex_currency = $_POST['themex_' . $themex_currency . '_currency']; 
     } 
    } 

    $json = json_encode($exchangeRates); 
    update_option('exchange_rates', $json); 

    update_option('openexchangerates_appid', trim($_POST['openexchangerates_appid'])); 

    echo '<div class="updated fade"><p>'.__('Settings saved!',' themex').'</p></div>'; 
    } 

:)ここで、私は私のAPIキーを置きます。私はそれを働かせてくれました:)

   //-------------------------------------------------------------------------------- 

      if ($selected != 'EUR') { 

      $json = get_option('exchange_rates'); 
      $exchangeRates = json_decode($json); 

      global $themex_currencies_array; 
      foreach ($themex_currencies_array as $themex_currency) { 
       if ($themex_currency != "USD") { 
          switch($themex_currency) { 
          case "AFN": 
            $myAFN = $exchangeRates->rates->$themex_currency; ; 
          break; 
          case "AED": 
            $myAED = $exchangeRates->rates->$themex_currency; ; 
          break; 
          } 
       } 
      } 

      $themex_final_payable_amount = (($myAED)*($themex_final_payable_amount))/($myAFN); 
      } 


     $p->add_field('business', trim($busi)); 
     $p->add_field('currency_code','EUR'); 
     $p->add_field('return', $ themex_paypal_success_page); 
     $p->add_field('cancel_return', $cancel_url); 
     $p->add_field('notify_url', get_bloginfo('siteurl').'/?payment_response=paypal_response'); 
     $p->add_field('item_name', $page_title); 
     $p->add_field('custom', $order_id); 
     $p->add_field('amount', ($themex_final_payable_amount)); 
     $p->submit_paypal_post(); // submit the fields to paypal 
関連する問題