Closed ablears closed 10 years ago
open the file: wpsc-includes/currency_converter.inc.php
find the function convert in the class there (arrund line 47) and replace the whole function with the one below:
function convert($amt = NULL, $to = "", $from = ""){
$amount = urlencode(round($amt,2));
$from_Currency = urlencode($from);
$to_Currency = urlencode($to);
$url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";
$ch = curl_init();
$timeout = 20;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
$rawdata = curl_exec($ch);
curl_close($ch);
if(empty($rawdata)){
throw new Exception( __( 'unable to connect to currency conversion service', 'wpsc' ) );
}
$data = explode('bld>', $rawdata);
$data = explode($to_Currency, $data[1]);
return round($data[0], 2);
}
I think this is a previously solved issue, see Issue 1121 in Google Code.
This entire function probably needs to be rewritten. We don't use curl directly, it doesn't follow coding standards, and it's using Exceptions.
I just made a quick workarround for the no longer iGoogle. That issue on google code uses a service that is not free and that fix no longer works either.
They have a free plan but it requires each user to signup and more setting up of this function.
was just trying to be helpful :)
Yep, no worries. Good catch on a decent URL to use, as you're right, the current one in use is not viable, nor is the one on that GC ticket. Long-term, something like this would be neat to use.
Any takers / volunteers to merge this?
Sent from my iPhone
On 15/11/2013, at 12:34 PM, JustinSainton notifications@github.com wrote:
Yep, no worries. Good catch on a decent URL to use, as you're right, the current one in use is not viable, nor is the one on that GC ticket. Long-term, something like this would be neat to use.
— Reply to this email directly or view it on GitHub.
Looking at wpsc_get_exchange_rate() - we should actually be deprecating the CURRENCYCONVERTER class entirely in favor of this. CURRENCYCONVERTER should essentially wrap wpsc_convert_currency(). wpsc_get_exchange_rate() should be privatized, and indeed, that's where we should be making these API changes.
Patch forthcoming.
@misulicus @ablears If you guys could check out the latest (d8989288823688a8c67819fbde127a8e15c38112) and see if it fixes your issue, we can probably get this in 3.8.13, as the current implementation is completely broken.
Thanks Justin. Can you please check too Edward :))
Sent from my iPhone
On 15/11/2013, at 1:32 PM, JustinSainton notifications@github.com wrote:
@misulicus @ablears If you guys could check out the latest (d898928) and see if it fixes your issue, we can probably get this in 3.8.13, as the current implementation is completely broken.
— Reply to this email directly or view it on GitHub.
Thanks guys, this fixed the issue for me.
Hi,
I know this issue was closed sometime ago, but I'm working on a website: dvjvision.com, which uses wpecommerce and the gold cart plugin for a digital download store.
I'm working in staging to try to resolve: dvjvision.staging.wpengine.com
The client was having issues with PayPal not being able to process the request because the amount returned to be charged was zero. I cleared out the shopping cart, added my own credentials from PayPal and set the IPN to on with the return URL.
I then went to checkout with the new credentials and I'm getting a 502 error:
The www.paypal.com page isn’t working
www.paypal.com is currently unable to handle this request. HTTP ERROR 502
Can someone help?
I'm using 3.8.12.1 with DPS/Payment Express and PayPal Express Checkout 2.0 for a South African store (currency set to RAND, in WPSC's PayPal settings this is set to convert to USD). PE works fine. With PayPal Express I am getting this error:
SetExpressCheckout API call failed. Detailed Error Message: This transaction cannot be processed. The amount to be charged is zero. Short Error Message: Invalid Data Error Code: 10525 Error Severity Code: Error
In paypal-express.merchant.php I see this in the submit function: $paymentAmount = $this->cart_data['total_price']; This outputs the correct amount (eg 250)
$this->convert( $paymentAmount ) outputs 0
So the original amount is correct but converting it sets it to zero.