{"id":8210685,"date":"2016-09-22T15:44:58","date_gmt":"2016-09-22T15:44:58","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/unsuported\/"},"modified":"2016-09-22T15:45:54","modified_gmt":"2016-09-22T15:45:54","slug":"unsuported","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/unsuported\/","title":{"rendered":"Unsuported Paypal Currency Conversion"},"content":{"rendered":"<p>I am trying to find out if EDD might have hooks and\/or a snippet that could enable the conversion of an unsupported Paypal currency to a supported one before it is sent to Paypal for processing.<\/p>\n<p>It is something that is available with Woocommerce for example:<\/p>\n<p>function woocommerce_paypal_args_for_inr($paypal_args){<br \/>\n    if ( $paypal_args[&#8216;currency_code&#8217;] == &#8216;INR&#8217;){<\/p>\n<p>        $convert_rate = getFromYahoo(); <\/p>\n<p>        $count = 1;<br \/>\n        while( isset($paypal_args[&#8216;amount_&#8217; . $count]) ){<br \/>\n            $paypal_args[&#8216;amount_&#8217; . $count] = round( $paypal_args[&#8216;amount_&#8217; . $count] \/ $convert_rate, 2);<br \/>\n            $count++;<br \/>\n        }<br \/>\n $paypal_args[&#8216;tax_cart&#8217;] = round( $paypal_args[&#8216;tax_cart&#8217;] \/ $convert_rate, 2);<br \/>\n    }<br \/>\n    return $paypal_args;<br \/>\n}<br \/>\nadd_filter(&#8216;woocommerce_paypal_args&#8217;, &#8216;woocommerce_paypal_args_for_inr&#8217;);<\/p>\n<p>function getFromYahoo()<br \/>\n{<br \/>\n $from   = &#8216;USD&#8217;; \/*change it to your required currencies *\/<br \/>\n $to     = &#8216;INR&#8217;;<br \/>\n $url = &#8216;http:\/\/finance.yahoo.com\/d\/quotes.csv?e=.csv&amp;f=sl1d1t1&amp;s=&#8217;. $from . $to .&#8217;=X&#8217;;<br \/>\n $handle = @fopen($url, &#8216;r&#8217;);<\/p>\n<p> if ($handle) {<br \/>\n $result = fgets($handle, 4096);<br \/>\n fclose($handle);<br \/>\n }<br \/>\n $allData = explode(&#8216;,&#8217;,$result); \/* Get all the contents to an array *\/<br \/>\n return $allData[1];<br \/>\n}<\/p>\n<p>Any help or suggestions would be greatly appreciated<\/p>\n<p>Thanks you<\/p>\n","protected":false},"template":"","class_list":["post-8210685","topic","type-topic","status-publish","hentry","topic-tag-paypal"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8210685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8210685\/revisions"}],"predecessor-version":[{"id":8210694,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8210685\/revisions\/8210694"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=8210685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}