class\Gateway\Paypal.php error - FIXED IN V3.0

Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

class\Gateway\Paypal.php error - FIXED IN V3.0

Post by RWAP » Thu May 03, 2012 4:48 pm

There is an issue with the code for generating the HTML buttons for PayPal, in that they do not have buttons for all languages...

I would therefore suggest that the following code in class\Gateway\Paypal.php is amended:

Code: Select all

    public function getHTMLButton()
    {
        $this->url = ($this->serverType == self::MODE_SANDBOX) ? self::SANDBOX_URL :self::LIVE_URL;
        //checks
        if(is_array($this->fields)){
            $availableFields = array_keys($this->fields);
            if(in_array('business',$availableFields)  && in_array('return',$availableFields)
                    && in_array('currency_code',$availableFields) && in_array('item_name',$availableFields)
                    && in_array('amount',$availableFields)){


                $HTMLButton = '<form id="_xclick" action="'.$this->url.'" method="post"><fieldset>'."\n";
                foreach ($this->fields as $key=>$value){
                    $HTMLButton.='<input type="hidden" name="'.$key.'" value="'.$value.'" />'."\n";
                }
                $HTMLButton.='<input type="hidden" name="cmd" value="_xclick" />';
                $HTMLButton.='<input type="image" src="https://www.paypal.com/'.($this->language?$this->language:'en_US').'/i/btn/btn_xpressCheckout.gif" name="submit"/>';
                $HTMLButton.="</fieldset>\n</form>";

                return $HTMLButton;
            }
        }
        return NULL;
    }
Should read:

Code: Select all

    public function getHTMLButton()
    {
        $this->url = ($this->serverType == self::MODE_SANDBOX) ? self::SANDBOX_URL :self::LIVE_URL;
        //checks
        if(is_array($this->fields)){
            $availableFields = array_keys($this->fields);
            $availableLanguages=array('fr_FR','es_ES','en_US','de_DE','it_IT');
            if(in_array('business',$availableFields)  && in_array('return',$availableFields)
                    && in_array('currency_code',$availableFields) && in_array('item_name',$availableFields)
                    && in_array('amount',$availableFields)){


                $HTMLButton = '<form id="_xclick" action="'.$this->url.'" method="post"><fieldset>'."\n";
                foreach ($this->fields as $key=>$value){
                    $HTMLButton.='<input type="hidden" name="'.$key.'" value="'.$value.'" />'."\n";
                }
                $HTMLButton.='<input type="hidden" name="cmd" value="_xclick" />';
                $HTMLButton.='<input type="image" src="https://www.paypal.com/'.(in_array($this->language,$availableLanguages)?$this->language:'en_US').'/i/btn/btn_xpressCheckout.gif" name="submit"/>';
                $HTMLButton.="</fieldset>\n</form>";

                return $HTMLButton;
            }
        }
        return NULL;
    }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest