2016-08-14 5 views
2

EUR 통화로 지불 거래를 전달하고 싶습니다. 나는 이미 책임 PHP 파일을 수정했지만 실시간 환율을 사용하는 데 어려움을 겪고 있습니다. 지금이 순간이 내가 페이팔에 보낼 것입니다 그리고 그것은 작동합니다openexchangerates.org를 사용하여 EUR 통화로 PayPal 지불금을 전달하십시오.

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 파일입니다) 내 API 키를 어디다 :

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>'; 
    } 

내가이 같은 일을해야한다고 생각 상기 내용을 토대로을하지만 그래서 여기

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

나는이 질문이 간단하지만 ... – Kozuns

답변

1

을하지 않는 내가 필요한 코드의 일부이다. 나는 그것을 작동시킬 수 있었다. :)

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

      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 
관련 문제