Z3PPZ3PP MemberComments: 181 Received thanks: 18 Member since: May 2013 edited October 2015
Hallo Forums-und Fangemeinde,

ich möchte gerne einen unterschiedlichen prozentualen Länderaufschlag bei den Ländern im PayPal-Modul hinterlegen.

Wie bekommt man das eingerichtet, da das Wiki nur von einem absoluten (festen) Betrag spricht?

Der feste Betrag ist aber eher schlecht, da PayPal prozentual berechnet vom Zahlungsbetrag.

Vielen Dank schon mal,
Grüße,

Nachtrag:
Shopware 4.0.8
PayPal-Plugin: API-Version 93.0

Comments

  • Z3PPZ3PP MemberComments: 181 Received thanks: 18 Member since: May 2013
    Hallo noch mal,

    weiß dafür denn keiner so eine Lösung?

    Ich denke mal, dass das doch auch viele andere betrifft, die für internationale Geschäfte mit PayPal-Zahlung die Gebühren weitergeben möchten.

    Grüße,
  • mirifica-demirifica-de MemberComments: 3 Received thanks: 1 Member since: August 2014
    Die Lösung soll in SW schon gelöst worden sein. Das Problem kommt aus der Übersetzung: in der deutschen Sprache fehlt das %-Zeichen.

    Englisches Backend (SW 4.3.0):
    Configurations > Payment methods > PayPal
    > General > base % surcharge
    > Surcharge > country > supplemental % surcharge = "Surscharge (in %)"

    Deutsches Backend (SW 4.3.0):
    Einstellungen > Zahlungsarten > PayPal
    > Generell > base % surcharge = Aufschlag/Abschlag (in %)
    > Länder-Aufschlag > Land > Zusatz-%-Aufschlag = "Aufschlag" = es soll %-Aufschlag gemeint sein.
  • joxjox MemberComments: 678 Received thanks: 11 Member since: July 2013
    Die Lösung soll in SW schon gelöst worden sein. Das Problem kommt aus der Übersetzung: in der deutschen Sprache fehlt das %-Zeichen.

    Englisches Backend (SW 4.3.0):
    Configurations > Payment methods > PayPal
    > General > base % surcharge
    > Surcharge > country > supplemental % surcharge = "Surscharge (in %)"

    Deutsches Backend (SW 4.3.0):
    Einstellungen > Zahlungsarten > PayPal
    > Generell > base % surcharge = Aufschlag/Abschlag (in %)
    > Länder-Aufschlag > Land > Zusatz-%-Aufschlag = "Aufschlag" = es soll %-Aufschlag gemeint sein.
    Und wie mach ich es jetzt, dass es mir prozentual anzeigt?
  • fdr-tefdr-te MemberComments: 13 Received thanks: 0 Member since: September 2013
    jox wrote:
    Und wie mach ich es jetzt, dass es mir prozentual anzeigt?
    Hallo Jox, ich lese hier, dass du dein Problem mittlerweile schon gelöst hast. Ich antworte sowieso deine Frage für Shopware 4.2, falls andere Benutzer davon Gebrauch machen können.

    sAdmin.php

    A)
    The code line
    $cache[$payment]["country_surcharge"][$key] =$value;
    
    has been modified as
    $cache[$payment]["country_surcharge"][$key] = 0.0;
    
    to avoid the country dependent fixed surcharge. Otherwise the percentual values are also used as fixed values.

    $value (the country dependent value manualy inserted by the operator in the backend) could be used only for country dependent fixed surcharge (Shopware normal code) or country dependent percentage surcharge (Shopware "Hacked/modified" Code).
       /**
         * Get a specific payment
         * Used internally in sAdmin::sGetPremiumShippingcosts()
         *
         * @param int $payment Payment mean id or name
         * @return array|false Array with payment mean information, including area, or false if empty argument
         */
        public function sGetPaymentMean($payment)
        {
            static $cache = array();
            if (empty($payment)) {
                return false;
            }
            if (isset($cache[$payment])) {
                return $cache[$payment];
            }
            if (is_numeric($payment)) {
                $sql = $this->db->quoteInto('id = ?', $payment);
            } elseif (is_string($payment)) {
                $sql = $this->db->quoteInto('name = ?', $payment);
            } else {
                return false;
            }
            $sql = "
                SELECT * FROM s_core_paymentmeans
                WHERE $sql
            ";
            $cache[$payment] = $this->db->fetchRow($sql) ? : array();
            $cache[$payment]["country_surcharge"] = array();
            if (!empty($cache[$payment]["surchargestring"])) {
                foreach (explode(";", $cache[$payment]["surchargestring"]) as $countrySurcharge) {
                    list($key, $value) = explode(":", $countrySurcharge);
                    $value = floatval(str_replace(",", ".", $value));
                    if (!empty($value)) {
                        $cache[$payment]["country_surcharge"][$key] = 0.0; //$value; //Modified by Sergio Pavesi
                    }
                }
            }
            return $cache[$payment];
        }
    
    B)
    Adding the country dependent value where it is commented (//Percentage Surcharge) does not seem to work with latest versions of Shopware.
    With older version of Shopware, the code line
    $payment['debit_percent'] += $payment['country_surcharge'][$country['countryiso']];
    
    seems to work (but it does not work with latest Shopware version and the code has been grayed out using comment).

    C)
    The fixed value is sligthly wrong; the correct formula do not alter the numerical value very much.
    //$surcharge = round($payment['surcharge'], 2); //Original Code
    $surcharge = round(($payment['surcharge']*(1/0.981)), 2); //Modified Code
    
    The fixed surcharge is augmented by {1/[1-(percentual/100)]} in sAdmin.php. The percentual is hardcoded and it does not change with the country. To do otherwise is necessary to add a second "column" in the Shopware backend.
        /**
         * Helper method for sAdmin::sGetPremiumShippingcosts()
         * Calculates payment mean surcharge
         *
         * @param $country
         * @param $payment
         * @param $currencyFactor
         * @param $dispatch
         * @param $discount_tax
         */
        private function handlePaymentMeanSurcharge($country, $payment, $currencyFactor, $dispatch, $discount_tax)
        {
            $surcharge_name = $this->config->get('sPAYMENTSURCHARGEABSOLUTE', 'Zuschlag für Zahlungsart');
            $surcharge_ordernumber = $this->config->get('sPAYMENTSURCHARGEABSOLUTENUMBER', 'PAYMENTSURCHARGEABSOLUTENUMBER');
            $percent_ordernumber = $this->config->get('sPAYMENTSURCHARGENUMBER', "PAYMENTSURCHARGE");
            // Country surcharge
            //if (!empty($payment['country_surcharge'][$country['countryiso']])) {
            //	$payment['debit_percent'] += $payment['country_surcharge'][$country['countryiso']]; //$payment['surcharge'] += $payment['country_surcharge'][$country['countryiso']]; //Modified by Sergio Pavesi
            //}
            //$payment['surcharge'] = round($payment['surcharge'] * $currencyFactor, 2); //Modified by Sergio Pavesi
    	//echo var_dump($payment['debit_percent']);
            // Fixed surcharge
            if (!empty($payment['surcharge']) && (empty($dispatch) || $dispatch['surcharge_calculation'] == 3)) {
                //$surcharge = round($payment['surcharge'], 2); //modified by Sergio Pavesi. Temporary solution
                $surcharge = round(($payment['surcharge']*(1/0.981)), 2); //Inserted by Sergio Pavesi. Temporary solution. 
                //The fix value is augmented by {1/[1-(percentual/100)]}. Correct formula, the one of Shopware is wrong
                //The perctual vaule is augmented by {(percentual/100)/[1-(percentual/100)]} in sBasket.php. Corect formula, the one of Shopware is wrong.
                $payment['surcharge'] = 0;
                if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) {
                    $surcharge_net = $surcharge;
                    //$tax_rate = 0;
                } else {
                    $surcharge_net = round($surcharge / (100 + $discount_tax) * 100, 2);
                }
    		//echo var_dump($surcharge);
                $tax_rate = $discount_tax;
                $this->db->insert(
                    's_order_basket',
                    array(
                        'sessionID' => $this->session->offsetGet('sessionId'),
                        'articlename' => $surcharge_name,
                        'articleID' => 0,
                        'ordernumber' => $surcharge_ordernumber,
                        'quantity' => 1,
                        'price' => $surcharge,
                        'netprice' => $surcharge_net,
                        'tax_rate' => $tax_rate,
                        'datum' => new Zend_Date(),
                        'modus' => 4,
                        'currencyFactor' => $currencyFactor
                    )
                );
            }
            // Percentage surcharge
            //if (!empty($payment['debit_percent']) && (empty($dispatch) || $dispatch['surcharge_calculation'] != 2)) {
                $amount = $this->db->fetchOne(
                    'SELECT SUM(quantity*price) as amount
                    FROM s_order_basket
                    WHERE sessionID = ? GROUP BY sessionID',
                    array($this->session->offsetGet('sessionId'))
                );
            
                $percent = round($amount / 100 * $payment['debit_percent'], 2);
            
                if ($percent > 0) {
                    $percent_name = $this->config->get('sPAYMENTSURCHARGEADD');
                } else {
                    $percent_name = $this->config->get('sPAYMENTSURCHARGEDEV');
                }
            
                if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) {
                    $percent_net = $percent;
                } else {
                    $percent_net = round($percent/(100+$discount_tax)*100,2);
                }
            
    		//echo "percent_netADMIN";
    		//echo var_dump($percent_net);     //float(0)  
                $tax_rate = $discount_tax;
                $this->db->insert(
                    's_order_basket',
                   array(
                        'sessionID' => $this->session->offsetGet('sessionId'),
                        'articlename' => $percent_name,
                        'articleID' => 0,
                        'ordernumber' => $percent_ordernumber,
                        'quantity' => 1,
                        'price' => $percent,
                        'netprice' => $percent_net,
                        'tax_rate' => $tax_rate,
                        'datum' => new Zend_Date(),
                        'modus' => 4,
                        'currencyFactor' => $currencyFactor
                   )
                );
            //}
            return $payment;
        }
    
    sBasket.php

    A)
    The code line
    $cache[$payment]["country_surcharge"][$key] =$value;
    
    is modified as
    $cache[$payment]["country_surcharge"][$key] = 0.0;
    
    to avoid the country dependent fixed surcharge. Otherwise the percentual values are also used as fixed values.

    $value (the country dependent value manualy inserted by the operator in the backend) could be used only for country dependent fixed surcharge (Shopware normal code) or country dependent percentage surcharge (Shopware "Hacked/modified" Code).

    B)
    The following line
    $percent = $paymentInfo["debit_percent"] + 0.0;
    
    is used to force float conversion.
    The + 0.0 could be probably eliminated.

    C)
    If there is a currency exchange, the percentual value should be modified according PayPal rules: for Euro is about 4.4%.
    if ( ( (($this->sSYSTEM->sCurrency['factor'])>1.03) || (($this->sSYSTEM->sCurrency['factor'])<0.97) ) ) 
    			$percent+= 4.4;                                                                             
    
    D)
    The original code
    $surcharge = $amount["totalAmount"] / 100 * $percent; //Original
    
    is changed in the following code
    $surcharge_p = (($amount["totalAmount"] + $shipping_price["value"])/ 1.0 ) *(($percent/100)/(1-($percent/100))); //Modified
    
    The perctual vaule is augmented by {(percentual/100)/[1-(percentual/100)]} in sBasket.php.
    This is the correct formula, the one used by Shopware is wrong.
    The fixed surcharge is augmented by {1/[1-(percentual/100)]} in sAdmin.php. The percentual is hardcoded and it does not change with the country. To do otherwise is necessary to add a second "column" in the Shopware backend.
          /**
         * Get a specific payment
         * Used internally in sAdmin::sGetPremiumShippingcosts()
         *
         * @param int $payment Payment mean id or name
         * @return array|false Array with payment mean information, including area, or false if empty argument
         */
        public function sGetPaymentMean($payment)
        {
            static $cache = array();
            if (empty($payment)) {
                return false;
            }
            if (isset($cache[$payment])) {
                return $cache[$payment];
            }
            if (is_numeric($payment)) {
                $sql = $this->db->quoteInto('id = ?', $payment);
            } elseif (is_string($payment)) {
                $sql = $this->db->quoteInto('name = ?', $payment);
            } else {
                return false;
            }
            $sql = "
                SELECT * FROM s_core_paymentmeans
                WHERE $sql
            ";
            $cache[$payment] = $this->db->fetchRow($sql) ? : array();
            $cache[$payment]["country_surcharge"] = array();
            if (!empty($cache[$payment]["surchargestring"])) {
                foreach (explode(";", $cache[$payment]["surchargestring"]) as $countrySurcharge) {
                    list($key, $value) = explode(":", $countrySurcharge);
                    $value = floatval(str_replace(",", ".", $value));
                    if (!empty($value)) {
                        $cache[$payment]["country_surcharge"][$key] = 0.0; //$value; //Modified by Sergio Pavesi
                    }
                }
            }
            return $cache[$payment];
        }
    
            $name = $this->config->get('sPAYMENTSURCHARGENUMBER', 'PAYMENTSURCHARGE');
            // Depends on payment mean
            $percent = $paymentInfo["debit_percent"] + 0.0; //Modified by Sergio Pavesi, uncertain
            $this->db->query(
                'DELETE FROM s_order_basket WHERE sessionID = ? AND ordernumber = ?',
                array($this->session->get('sessionId'), $name)
            );
            if (!$this->sCountBasket()) {
                return false;
            }
            if (!empty($percent)) {
                $amount = $this->sGetAmount();
                if ($percent >= 0) {
                    $surchargeName = $this->config->get('sPAYMENTSURCHARGEADD');
                } else {
                    $surchargeName = $this->config->get('sPAYMENTSURCHARGEDEV');
                }
    	    if ( ( (($this->sSYSTEM->sCurrency['factor'])>1.03) || (($this->sSYSTEM->sCurrency['factor'])<0.97) ) ) //Inserted by Sergio Pavesi
    			$percent+= 4.4;                                                                             //Inserted by Sergio Pavesi
    	    //If there is a currency exchange the percentual value should be modified according PayPal rules: for Euro is about 4.4%. 
                //$surcharge = $amount["totalAmount"] / 100 * $percent; Modified by Sergio Pavesi
    	    $surcharge_p = (($amount["totalAmount"] + $shipping_price["value"])/ 1.0 ) *(($percent/100)/(1-($percent/100))); //Inserted by Sergio Pavesi
    	    //The fix value is augmented by {1/[1-(percentual/100)]} in sAdmin.php. Correct formula, the one of Shopware is wrong
                //The perctual vaule is augmented by {(percentual/100)/[1-(percentual/100)]} in sBasket.php. Corect formula, the one of Shopware is wrong.
    
                $taxAutoMode = $this->config->get('sTAXAUTOMODE');
                if (!empty($taxAutoMode)) {
                    $tax = $this->getMaxTax();
                } else {
                    $tax = $this->config->get('sDISCOUNTTAX');
                }
                if (!$tax) {
                    $tax = 119;
                }
                if ((!$this->sSYSTEM->sUSERGROUPDATA["tax"] && $this->sSYSTEM->sUSERGROUPDATA["id"])) {
                    $discountNet = $surcharge_p;
                } else {
                    $discountNet = round($surcharge_p / (100+$tax) * 100,3);
                }
    		// $tax_rate = $discount_tax;
                //$this->db->insert(
                //    's_order_basket',
                //   array(
                //        'sessionID' => $this->session->offsetGet('sessionId'),
                //        'articlename' => $percent_name,
                //        'articleID' => 0,
                //        'ordernumber' => $percent_ordernumber,
                //        'quantity' => 1,
                //        'price' => $percent,
                //        'netprice' => $percent_net,
                //        'tax_rate' => $tax_rate,
                //        'datum' => new Zend_Date(),
                //        'modus' => 4,
                //        'currencyFactor' => $currencyFactor
    
                $this->db->insert(
                    's_order_basket',
                    array(
                        'sessionID'      => $this->session->get('sessionId'),
                        'articlename'    => $surchargeName,
                        'articleID'      => 0,
                        'ordernumber'    => $name,
                        'quantity'       => 1,
                        'price'          => $surcharge_p,
                        'netprice'       => $discountNet,
                        'tax_rate'       => $tax,
                        'datum'          => new Zend_Date(),
                        'modus'          => 4,
                        'currencyFactor' => $this->sSYSTEM->sCurrency['factor']
                    )
                );
            }
        }
    
  • anhaefranhaefr MemberComments: 56 Received thanks: 1 Member since: April 2015
    Hi,

    es ist ja tatsächlich so, dass sich die Gebühren aus einem festen, länderunabhängigen Fixbetrag und einem änderspezifischen, prozentualen Aufschlag, basierend auf dem Rechnungswert, zusammen setzen. Bei Shopware ist das leider genau andersrum im Zahlungsmodul umgesetzt. Auf der "Generell" Reiter gibt es die Möglichkeit, Prozente und Fixbeträge einzugeben, unter "Länder Aufschlag" leider nur Fixbeträge, obwohl dort eigentlich ebenfalls Prozentwerte benötigt werden, damit man z.B. das Paypal oder Skrill Gebührenmodell nachbauen kann. Da das so moemntan nicht möglich ist wäre ich dankbar für eine Idee, wie man die Zahlungsartgebühren im Shop abbilden kann.

    Beispiel: deutscher Kunde bei Zahlung per Paypal 0,35 € +1,9% des Warenwerts,
    Schweizer Kunde 0,35 € + 3,8% des Warenwerts als Zuschlag.

    Viele Grüße
    Frank
  • anhaefranhaefr MemberComments: 56 Received thanks: 1 Member since: April 2015

    Gibt es hierzu schon eine Lösung?

  • Corrado_FreakCorrado_Freak MemberComments: 30 Received thanks: 2 Member since: June 2015

    würde mich auch interessieren

  • docgeardocgear MemberComments: 3 Received thanks: 0 Member since: September 2017

    gibt es inzwischen schon eine Lösung?

  • kanumakanuma MemberComments: 238 Received thanks: 52 Member since: May 2014

    Mittlerweile ist ein Aufschlag auf Zahlungsarten gesetzlich verboten...

    besten Gruß

Sign In or Register to comment.