diff --git a/application/helper/fcpobasehelper.php b/application/helper/fcpobasehelper.php
new file mode 100644
index 00000000..9c9ad438
--- /dev/null
+++ b/application/helper/fcpobasehelper.php
@@ -0,0 +1,23 @@
+_oHelper === null) {
+ $this->_oHelper = oxNew('fcpohelper');
+ }
+ return $this->_oHelper;
+ }
+}
\ No newline at end of file
diff --git a/application/helper/fcpopaymenthelper.php b/application/helper/fcpopaymenthelper.php
new file mode 100644
index 00000000..b83b7431
--- /dev/null
+++ b/application/helper/fcpopaymenthelper.php
@@ -0,0 +1,78 @@
+load($sPaymentId) === true) {
+ return $oPayment;
+ }
+ return false;
+ }
+
+ /**
+ * Returns if given payment method is active
+ *
+ * @param string $sPaymentId
+ * @return bool
+ */
+ public function isPaymentMethodActive($sPaymentId)
+ {
+ $blActive = false;
+
+ $oPayment = $this->loadPaymentMethod($sPaymentId);
+ if ($oPayment !== false && (bool)$oPayment->oxpayments__oxactive->value === true) {
+ $blActive = true;
+ }
+ return $blActive;
+ }
+
+ /**
+ * @param string $sPaymentId
+ * @return bool
+ */
+ public function isLiveMode($sPaymentId)
+ {
+ $blLiveMode = false;
+
+ $oPayment = $this->loadPaymentMethod($sPaymentId);
+ if ($oPayment !== false && (bool)$oPayment->oxpayments__fcpolivemode->value === true) {
+ $blLiveMode = true;
+ }
+ return $blLiveMode;
+ }
+}
\ No newline at end of file
diff --git a/application/helper/fcpopaypalhelper.php b/application/helper/fcpopaypalhelper.php
new file mode 100644
index 00000000..1c2291e7
--- /dev/null
+++ b/application/helper/fcpopaypalhelper.php
@@ -0,0 +1,162 @@
+getMainHelper()->fcpoGetConfig()->getConfigParam('blFCPOPayPalV2BNPL') === true) {
+ $blReturn = true;
+ }
+ return $blReturn;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getIntent()
+ {
+ return "authorize"; // authorize = preauthorize // capture = authorize but Payone said to always use authorize
+ }
+
+ /**
+ * @return string
+ */
+ protected function getCurrency()
+ {
+ return $this->getMainHelper()->fcpoGetSession()->getBasket()->getBasketCurrency()->name;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getMerchantId()
+ {
+ $sMerchantId = "3QK84QGGJE5HW"; // Default for testmode (fixed)
+ if (fcpopaymenthelper::getInstance()->isLiveMode(self::PPE_V2_EXPRESS)) {
+ $sMerchantId = $this->getMainHelper()->fcpoGetConfig()->getConfigParam('blFCPOPayPalV2MerchantID');
+ }
+ return $sMerchantId;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getClientId()
+ {
+ $sClientId = "AUn5n-4qxBUkdzQBv6f8yd8F4AWdEvV6nLzbAifDILhKGCjOS62qQLiKbUbpIKH_O2Z3OL8CvX7ucZfh"; // Default for testmode (fixed)
+ if (fcpopaymenthelper::getInstance()->isLiveMode(self::PPE_V2_EXPRESS)) {
+ $sClientId = "AVNBj3ypjSFZ8jE7shhaY2mVydsWsSrjmHk0qJxmgJoWgHESqyoG35jLOhH3GzgEPHmw7dMFnspH6vim"; // Livemode (fixed)
+ }
+ return $sClientId;
+ }
+
+ /**
+ * Check whether specified locale code is supported. Fallback to en_US
+ *
+ * @param string $sLocale
+ * @return string
+ */
+ protected function getSupportedLocaleCode($sLocale = null)
+ {
+ if (!$sLocale || !in_array($sLocale, $this->aSupportedLocales)) {
+ return 'en_US';
+ }
+ return $sLocale;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getLocale()
+ {
+ $sCurrentLocal = $this->getMainHelper()->fcpoGetLang()->translateString('FCPO_LOCALE', null, false);
+ return $this->getSupportedLocaleCode($sCurrentLocal);
+ }
+
+ /**
+ * @return string
+ */
+ public function getJavascriptUrl()
+ {
+ $sUrl = "https://www.paypal.com/sdk/js?client-id=".$this->getClientId()."&merchant-id=".$this->getMerchantId()."¤cy=".$this->getCurrency()."&intent=".$this->getIntent()."&locale=".$this->getLocale()."&commit=false&vault=false&disable-funding=card,sepa,bancontact";
+ if ($this->showBNPLButton() === true) {
+ $sUrl .= "&enable-funding=paylater";
+ }
+ return $sUrl;
+ }
+
+ /**
+ * @return string
+ */
+ public function getButtonColor()
+ {
+ return $this->getMainHelper()->fcpoGetConfig()->getConfigParam('blFCPOPayPalV2ButtonColor');
+ }
+
+ /**
+ * @return string
+ */
+ public function getButtonShape()
+ {
+ return $this->getMainHelper()->fcpoGetConfig()->getConfigParam('blFCPOPayPalV2ButtonShape');
+ }
+}
\ No newline at end of file
diff --git a/application/helper/fcporedirecthelper.php b/application/helper/fcporedirecthelper.php
new file mode 100644
index 00000000..297a807c
--- /dev/null
+++ b/application/helper/fcporedirecthelper.php
@@ -0,0 +1,135 @@
+getMainHelper()->fcpoGetConfig()->getCurrentShopUrl();
+ }
+
+ /**
+ * @return string
+ */
+ protected function getRToken()
+ {
+ $sRToken = '';
+ if ($this->getMainHelper()->fcpoGetIntShopVersion() >= 4310) {
+ $sRToken = '&rtoken='.$this->getMainHelper()->fcpoGetSession()->getRemoteAccessToken();
+ }
+ return $sRToken;
+ }
+
+ /**
+ * Returns cancel URL
+ *
+ * @param string $sAbortClass
+ * @return string
+ */
+ public function getCancelUrl($sAbortClass)
+ {
+ return $this->getShopUrl().'index.php?type=cancel&cl='.$sAbortClass.$this->getRToken();
+ }
+
+ /**
+ * Returns error URL
+ *
+ * @param string $sAbortClass
+ * @param bool $blAddAmazonLogoff
+ * @return string
+ */
+ public function getErrorUrl($sAbortClass, $blAddAmazonLogoff = false)
+ {
+ $sPaymentErrorParam = '&payerror=-20'; // see source/modules/fc/fcpayone/out/blocks/fcpo_payment_errors.tpl
+ $sPaymentErrorTextParam = "&payerrortext=".urlencode($this->getMainHelper()->fcpoGetLang()->translateString('FCPO_PAY_ERROR_REDIRECT', null, false));
+
+ $sAddParam = "";
+ if ($blAddAmazonLogoff === true) {
+ $sAddParam = "&fcpoamzaction=logoff";
+ }
+
+ return $this->getShopUrl().'index.php?type=error&cl='.$sAbortClass.$this->getRToken().$sPaymentErrorParam.$sPaymentErrorTextParam.$sAddParam;
+ }
+
+ /**
+ * Returns success URL
+ *
+ * @param string|false $sRefNr
+ * @param string|false $sRedirectFunction
+ * @param string|false $sToken
+ * @param string|false $sDeliveryMD5
+ * @return string
+ */
+ public function getSuccessUrl($sRefNr = false, $sRedirectFunction = false, $sToken = false, $sDeliveryMD5 = false)
+ {
+ $sSid = $this->getMainHelper()->fcpoGetSession()->sid(true);
+ if (!empty($sSid)) {
+ $sSid = '&' . $sSid;
+ }
+
+ $sAddParams = '';
+ if (!empty($sRefNr)) {
+ $sAddParams .= '&refnr=' . $sRefNr;
+ }
+
+ if (!empty($sRedirectFunction)) {
+ $sAddParams .= '&fnc='.$sRedirectFunction;
+ } else {
+ $sAddParams .= '&fnc=execute';
+ }
+
+
+ if (!empty($sDeliveryMD5)) {
+ $sAddParams .= '&sDeliveryAddressMD5=' . $sDeliveryMD5;
+ } elseif ($this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
+ $sAddParams .= '&sDeliveryAddressMD5=' . $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5');
+ }
+
+ $blDownloadableProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxdownloadableproductsagreement');
+ if ($blDownloadableProductsAgreement) {
+ $sAddParams .= '&fcdpa=1'; // rewrite for oxdownloadableproductsagreement-param because of length-restriction
+ }
+
+ $blServiceProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxserviceproductsagreement');
+ if ($blServiceProductsAgreement) {
+ $sAddParams .= '&fcspa=1'; // rewrite for oxserviceproductsagreement-param because of length-restriction
+ }
+
+ if (empty($sToken)) {
+ $sToken = $this->getMainHelper()->fcpoGetRequestParameter('stoken');
+ }
+
+ return $this->getShopUrl().'index.php?cl=order&fcposuccess=1&ord_agb=1&stoken='.$sToken.$sSid.$sAddParams.$this->getRToken();
+ }
+}
\ No newline at end of file
diff --git a/application/models/fcpayone_ajax.php b/application/models/fcpayone_ajax.php
index 2913653a..cadbb09f 100755
--- a/application/models/fcpayone_ajax.php
+++ b/application/models/fcpayone_ajax.php
@@ -198,6 +198,32 @@ public function fcpoGetAmazonReferenceId($sParamsJson)
$this->_fcpoHandleSetOrderReferenceDetails($sAmazonReferenceId, $sAmazonLoginAccessToken);
}
+ public function fcpoStartPayPalExpress()
+ {
+ $aJsonResponse = [
+ 'success' => false,
+ ];
+
+ /** @var fcpoRequest $oRequest */
+ $oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
+ $aResponse = $oRequest->sendRequestGenericPayment(fcpopaypalhelper::PPE_V2_EXPRESS);
+
+ if (isset($aResponse['status'], $aResponse['workorderid'], $aResponse['add_paydata[orderId]']) && $aResponse['status'] == 'REDIRECT') {
+ $aJsonResponse['success'] = true;
+ $aJsonResponse['order_id'] = $aResponse['add_paydata[orderId]'];
+
+ if (!empty($aResponse['workorderid'])) {
+ $this->_oFcpoHelper->fcpoSetSessionVariable('fcpoWorkorderId', $aResponse['workorderid']);
+ }
+ }
+
+ if (isset($aResponse['status'], $aResponse['customermessage']) && $aResponse['status'] == 'ERROR') {
+ $aJsonResponse['errormessage'] = $aResponse['customermessage'];
+ }
+
+ return json_encode($aJsonResponse);
+ }
+
/**
*
*
@@ -938,6 +964,9 @@ protected function _parseRatepayRateDetails($sPaymentMethod, $aInstallmentDetail
echo $oPayoneAjax->fcpoRatepayCalculation($sParamsJson);
}
+ if ($sAction == 'start_paypal_express' && $sPaymentId == fcpopaypalhelper::PPE_V2_EXPRESS) {
+ echo $oPayoneAjax->fcpoStartPayPalExpress();
+ }
$blConfirmAmazonOrder = (
$sAction == 'confirm_amazon_pay_order' &&
diff --git a/application/models/fcpoconfigexport.php b/application/models/fcpoconfigexport.php
index bb3e2e6e..a967ee96 100644
--- a/application/models/fcpoconfigexport.php
+++ b/application/models/fcpoconfigexport.php
@@ -487,6 +487,8 @@ protected function _getPaymentAbbreviation($sPaymentId)
'fcpoinvoice' => 'rec',
'fcpopaypal' => 'wlt',
'fcpopaypal_express' => 'wlt',
+ 'fcpopaypalv2' => 'wlt',
+ 'fcpopaypalv2_express' => 'wlt',
'fcpoklarna' => 'fnc',
'fcpoklarna_invoice' => 'fnc',
'fcpoklarna_directdebit' => 'fnc',
@@ -545,6 +547,8 @@ protected function _getPaymentSubtype($sPaymentId) {
'fcpoinvoice' => 'REC', // has no subtype use clearingtype instead
'fcpopaypal' => 'PPE',
'fcpopaypal_express' => 'PPE',
+ 'fcpopaypalv2' => 'PAL',
+ 'fcpopaypalv2_express' => 'PAL',
'fcpoklarna_invoice' => 'KIV',
'fcpoklarna' => 'KLV',
'fcpoklarna_directdebit' => 'KDD',
diff --git a/application/translations/de/fcPayOne_lang.php b/application/translations/de/fcPayOne_lang.php
index a68b4609..5412f5ce 100755
--- a/application/translations/de/fcPayOne_lang.php
+++ b/application/translations/de/fcPayOne_lang.php
@@ -24,6 +24,7 @@
// -------------------------------
$aLang = array(
'charset' => 'UTF-8',
+ 'FCPO_LOCALE' => 'de_DE',
'FCPO_IBAN_INVALID' => 'Bitte geben Sie eine korrekte IBAN ein.',
'FCPO_BIC_INVALID' => 'Bitte geben Sie eine korrekte BIC ein.',
'FCPO_BLZ_INVALID' => 'Bitte geben Sie eine korrekte Bankleitzahl ein.',
@@ -257,6 +258,8 @@
'PAYONE paydirekt' => 'PAYONE Giropay',
'PAYONE PayPal Express' => 'PAYONE PayPal Express',
'PAYONE PayPal' => 'PAYONE PayPal',
+ 'PAYONE PayPal Express V2' => 'PAYONE PayPal Express V2',
+ 'PAYONE PayPal V2' => 'PAYONE PayPal V2',
'PAYONE PostFinance Card' => 'PAYONE PostFinance Card',
'PAYONE PostFinance E-Finance' => 'PAYONE PostFinance E-Finance',
'PAYONE Przelewy24' => 'PAYONE Przelewy24',
diff --git a/application/translations/en/fcPayOne_lang.php b/application/translations/en/fcPayOne_lang.php
index 2ba7ad7a..8e42df59 100755
--- a/application/translations/en/fcPayOne_lang.php
+++ b/application/translations/en/fcPayOne_lang.php
@@ -24,6 +24,7 @@
// -------------------------------
$aLang = array(
'charset' => 'ISO-8859-15',
+'FCPO_LOCALE' => 'en_US',
'FCPO_IBAN_INVALID' => 'Please enter a valid IBAN.',
'FCPO_BIC_INVALID' => 'Please enter a valid BIC.',
'FCPO_BLZ_INVALID' => 'Please enter a valid bank identification number.',
@@ -268,6 +269,8 @@
'PAYONE paydirekt' => 'PAYONE Giropay',
'PAYONE PayPal Express' => 'PAYONE PayPal Express',
'PAYONE PayPal' => 'PAYONE PayPal',
+'PAYONE PayPal Express V2' => 'PAYONE PayPal Express V2',
+'PAYONE PayPal V2' => 'PAYONE PayPal V2',
'PAYONE PostFinance Card' => 'PAYONE PostFinance Card',
'PAYONE PostFinance E-Finance' => 'PAYONE PostFinance E-Finance',
'PAYONE Przelewy24' => 'PAYONE Przelewy24',
diff --git a/application/translations/nl/fcPayOne_lang.php b/application/translations/nl/fcPayOne_lang.php
index 6b7cf262..e1203605 100644
--- a/application/translations/nl/fcPayOne_lang.php
+++ b/application/translations/nl/fcPayOne_lang.php
@@ -24,6 +24,7 @@
// -------------------------------
$aLang = array(
'charset' => 'ISO-8859-15',
+ 'FCPO_LOCALE' => 'nl_NL',
'FCPO_IBAN_INVALID' => 'Please enter a valid IBAN.',
'FCPO_BIC_INVALID' => 'Please enter a valid BIC.',
'FCPO_BLZ_INVALID' => 'Please enter a valid bank identification number.',
diff --git a/application/views/admin/de/fcPayOne_lang.php b/application/views/admin/de/fcPayOne_lang.php
index 0f07fabb..ba7eb169 100755
--- a/application/views/admin/de/fcPayOne_lang.php
+++ b/application/views/admin/de/fcPayOne_lang.php
@@ -231,6 +231,24 @@
'FCPO_CONFIG_GROUP_PP_EXPRESS_LOGOS' => "PayPal",
'FCPO_CONFIG_ADD_PP_EXPRESS_LOGO' => "Weitere Sprache hinzufügen",
+ 'FCPO_CONFIG_GROUP_PAYPALV2' => "PayPal V2",
+ 'FCPO_PAYPALV2_BNPL' => "Später Bezahlen Express Button anzeigen",
+
+ 'FCPO_PAYPALV2_MERCHANT_ID' => "PayPal Merchant ID",
+ 'FCPO_HELP_PAYPALV2_MERCHANT_ID' => "Im Testmodus NICHT erforderlich. Da wird eine feste ID von Payone verwendet.",
+
+ 'FCPO_PAYPALV2_BUTTON_COLOR' => "Express Button Farbe",
+ 'FCPO_PAYPALV2_BUTTON_GOLD' => "Gold",
+ 'FCPO_PAYPALV2_BUTTON_BLUE' => "Blau",
+ 'FCPO_PAYPALV2_BUTTON_SILVER' => "Silber",
+ 'FCPO_PAYPALV2_BUTTON_WHITE' => "Weiß",
+ 'FCPO_PAYPALV2_BUTTON_BLACK' => "Schwarz",
+
+ 'FCPO_PAYPALV2_BUTTON_SHAPE' => "Express Button Form",
+ 'FCPO_PAYPALV2_BUTTON_RECT' => "Standard Button Form",
+ 'FCPO_PAYPALV2_BUTTON_PILL' => "Runde Ecken",
+ 'FCPO_PAYPALV2_BUTTON_SHARP' => "Spitze Ecken",
+
'FCPO_CONFIG_DEBIT_BANKDATA' => "Eingabe der Bankdaten",
'FCPO_CONFIG_DEBIT_MULTISELECT' => "Liste der unterstützten Kontolländer.
für Mehrfachmarkierung STRG-Taste gedrückt halten.",
'FCPO_CONFIG_DEBIT_GER' => "Nur bei Deutschen Konten",
@@ -470,6 +488,8 @@
'PAYONE paydirekt' => 'PAYONE Giropay',
'PAYONE PayPal Express' => 'PAYONE PayPal Express',
'PAYONE PayPal' => 'PAYONE PayPal',
+ 'PAYONE PayPal Express V2' => 'PAYONE PayPal Express V2',
+ 'PAYONE PayPal V2' => 'PAYONE PayPal V2',
'PAYONE PostFinance Card' => 'PAYONE PostFinance Card',
'PAYONE PostFinance E-Finance' => 'PAYONE PostFinance E-Finance',
'PAYONE Przelewy24' => 'PAYONE Przelewy24',
diff --git a/application/views/admin/en/fcPayOne_lang.php b/application/views/admin/en/fcPayOne_lang.php
index 94fe6011..202dc8b2 100644
--- a/application/views/admin/en/fcPayOne_lang.php
+++ b/application/views/admin/en/fcPayOne_lang.php
@@ -308,6 +308,24 @@
'FCPO_CONFIG_GROUP_PP_EXPRESS_LOGOS' => "PayPal",
'FCPO_CONFIG_ADD_PP_EXPRESS_LOGO' => "Add another language",
+ 'FCPO_CONFIG_GROUP_PAYPALV2' => "PayPal V2",
+ 'FCPO_PAYPALV2_BNPL' => "Show Buy Now Pay Later Button",
+
+ 'FCPO_PAYPALV2_MERCHANT_ID' => "PayPal Merchant ID",
+ 'FCPO_HELP_PAYPALV2_MERCHANT_ID' => "NOT needed in test mode. A predefined Payone Merchant ID is used in that case.",
+
+ 'FCPO_PAYPALV2_BUTTON_COLOR' => "Express Button Color",
+ 'FCPO_PAYPALV2_BUTTON_GOLD' => "Gold",
+ 'FCPO_PAYPALV2_BUTTON_BLUE' => "Blue",
+ 'FCPO_PAYPALV2_BUTTON_SILVER' => "Silver",
+ 'FCPO_PAYPALV2_BUTTON_WHITE' => "White",
+ 'FCPO_PAYPALV2_BUTTON_BLACK' => "Black",
+
+ 'FCPO_PAYPALV2_BUTTON_SHAPE' => "Express Button Shape",
+ 'FCPO_PAYPALV2_BUTTON_RECT' => "Default button shape",
+ 'FCPO_PAYPALV2_BUTTON_PILL' => "Rounded corners",
+ 'FCPO_PAYPALV2_BUTTON_SHARP' => "Sharp corners",
+
'FCPO_HELP_REFPREFIX' => "A unique referencenumber has to be transferred to PAYONE with every request. This is a consecutive number, normally starting at 1. When operating multiple shops ( e.g. live- and test-shop ) with the same PAYONE account-data there will be problems when the current referencenumber was already used. This can be avoided by using different prefixes on different shops.",
'FCPO_REFPREFIX' => "Referencenumber prefix ( optional )",
@@ -479,6 +497,8 @@
'PAYONE paydirekt' => 'PAYONE Giropay',
'PAYONE PayPal Express' => 'PAYONE PayPal Express',
'PAYONE PayPal' => 'PAYONE PayPal',
+ 'PAYONE PayPal Express V2' => 'PAYONE PayPal Express V2',
+ 'PAYONE PayPal V2' => 'PAYONE PayPal V2',
'PAYONE PostFinance Card' => 'PAYONE PostFinance Card',
'PAYONE PostFinance E-Finance' => 'PAYONE PostFinance E-Finance',
'PAYONE Przelewy24' => 'PAYONE Przelewy24',
diff --git a/application/views/admin/tpl/fcpayone_main.tpl b/application/views/admin/tpl/fcpayone_main.tpl
index c4db21b0..9f690231 100755
--- a/application/views/admin/tpl/fcpayone_main.tpl
+++ b/application/views/admin/tpl/fcpayone_main.tpl
@@ -469,9 +469,9 @@
-
+
-
fcpoIsLogoAdded()}] class="exp"[{/if}]>
+
+
+
+
+
fcpoIsLogoAdded()}] class="exp"[{/if}]>
+
[{oxmultilang ident="FCPO_CONFIG_GROUP_PAYPALV2"}]
+
+ -
+
+
+
+ -
+ [{oxmultilang ident="FCPO_PAYPALV2_BNPL"}]
+
+
+
+
+
+ -
+
+ [{oxinputhelp ident="FCPO_HELP_PAYPALV2_MERCHANT_ID"}]
+
+ -
+ [{oxmultilang ident="FCPO_PAYPALV2_MERCHANT_ID"}]
+
+
+
+
+
+ -
+
+
+ -
+ [{oxmultilang ident="FCPO_PAYPALV2_BUTTON_COLOR"}]
+
+
+
+
+
+ -
+
+
+ -
+ [{oxmultilang ident="FCPO_PAYPALV2_BUTTON_SHAPE"}]
+
+
+
diff --git a/application/views/frontend/tpl/fcpo_paypal_express_v2.tpl b/application/views/frontend/tpl/fcpo_paypal_express_v2.tpl
new file mode 100644
index 00000000..3faff21a
--- /dev/null
+++ b/application/views/frontend/tpl/fcpo_paypal_express_v2.tpl
@@ -0,0 +1,80 @@
+[{assign var="buttonId" value=$oViewConf->fcpoGetPayPalExpressV2GetButtonId($_payone_position)}]
+
+
+
+
\ No newline at end of file
diff --git a/core/fcpayone_events.php b/core/fcpayone_events.php
index 822dc551..ef339e14 100755
--- a/core/fcpayone_events.php
+++ b/core/fcpayone_events.php
@@ -403,6 +403,11 @@ class fcpayone_events
public static $sQueryAlterFcporequestlogRefnrIndex = "ALTER TABLE fcporequestlog ADD INDEX FCPO_REFNR (`FCPO_REFNR`)";
public static $sQueryAlterFcporequestlogRequesttypeIndex = "ALTER TABLE fcporequestlog ADD INDEX FCPO_REQUESTTYPE (`FCPO_REQUESTTYPE`)";
+ /**
+ * List of all Payone payment methods to add to the database
+ *
+ * @var string[]
+ */
public static $aPaymentMethods = array(
'fcpoinvoice' => 'PAYONE Rechnungskauf',
'fcpopayadvance' => 'PAYONE Vorkasse',
@@ -411,6 +416,8 @@ class fcpayone_events
'fcpocreditcard' => 'PAYONE Kreditkarte',
'fcpopaypal' => 'PAYONE PayPal',
'fcpopaypal_express' => 'PAYONE PayPal Express',
+ 'fcpopaypalv2' => 'PAYONE PayPal V2',
+ 'fcpopaypalv2_express' => 'PAYONE PayPal Express V2',
'fcpoklarna_invoice' => 'PAYONE Klarna Rechnung',
'fcpoklarna_installments' => 'PAYONE Klarna Ratenkauf',
'fcpoklarna_directdebit' => 'PAYONE Klarna Sofort bezahlen',
@@ -438,7 +445,6 @@ class fcpayone_events
'fcpopl_secinvoice' => 'PAYONE Gesicherter Rechnungskauf (neu)',
'fcpopl_secinstallment' => 'PAYONE Gesicherter Ratenkauf',
'fcpopl_secdebitnote' => 'PAYONE Gesicherte Lastschrift',
-
);
/**
diff --git a/extend/application/controllers/fcPayOneBasketView.php b/extend/application/controllers/fcPayOneBasketView.php
index 5d19e525..3a9abd2c 100755
--- a/extend/application/controllers/fcPayOneBasketView.php
+++ b/extend/application/controllers/fcPayOneBasketView.php
@@ -106,14 +106,24 @@ protected function _fcpoCheckForAmazonLogoff() {
/**
* Returns wether paypal express is active or not
- *
+ *
+ * @param void
+ * @return boolean
+ */
+ protected function _fcpoIsPayPalExpressActive()
+ {
+ return fcpopaymenthelper::getInstance()->isPaymentMethodActive(fcpopaypalhelper::PPE_EXPRESS);
+ }
+
+ /**
+ * Returns wether paypal express is active or not
+ *
* @param void
* @return boolean
*/
- protected function _fcpoIsPayPalExpressActive()
+ protected function _fcpoIsPayPalExpressV2Active()
{
- $oBasket = $this->_oFcpoHelper->getFactoryObject('oxBasket');
- return $oBasket->fcpoIsPayPalExpressActive();
+ return fcpopaymenthelper::getInstance()->isPaymentMethodActive(fcpopaypalhelper::PPE_V2_EXPRESS);
}
/**
@@ -126,14 +136,26 @@ public function fcpoGetPayPalExpressPic()
{
if ($this->_sPayPalExpressPic === null) {
$this->_sPayPalExpressPic = false;
- if ($this->_fcpoIsPayPalExpressActive()) {
+ if ($this->_fcpoIsPayPalExpressActive() === true && $this->_fcpoIsPayPalExpressV2Active() === false) {
$this->_sPayPalExpressPic = $this->_fcpoGetPayPalExpressPic();
}
}
return $this->_sPayPalExpressPic;
}
-
+
+ /**
+ * Loads paypal express pic from db
+ *
+ * @return string
+ */
+ protected function _fcpoGetPayPalExpressPicFromDb()
+ {
+ $iLangId = $this->_oFcpoHelper->fcpoGetLang()->getBaseLanguage();
+ $sQuery = "SELECT fcpo_logo FROM fcpopayoneexpresslogos WHERE fcpo_logo != '' AND fcpo_langid = '{$iLangId}' ORDER BY fcpo_default DESC";
+ return $this->_oFcpoHelper->fcpoGetDb()->GetOne($sQuery);
+ }
+
/**
* Finally fetches needed values and set attribute value
*
@@ -143,8 +165,8 @@ public function fcpoGetPayPalExpressPic()
protected function _fcpoGetPayPalExpressPic()
{
$sPayPalExpressPic = false;
- $oBasket = $this->_oFcpoHelper->getFactoryObject('oxBasket');
- $sPic = $oBasket->fcpoGetPayPalExpressPic();
+
+ $sPic = $this->_fcpoGetPayPalExpressPicFromDb();
$sPaypalExpressLogoPath = getShopBasePath() . $this->_sPayPalExpressLogoPath . $sPic;
$blLogoPathExists = $this->_oFcpoHelper->fcpoFileExists($sPaypalExpressLogoPath);
@@ -167,7 +189,7 @@ protected function _fcpoGetPayPalExpressPic()
public function fcpoUsePayPalExpress()
{
$oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
- $aOutput = $oRequest->sendRequestGenericPayment();
+ $aOutput = $oRequest->sendRequestGenericPayment(fcpopaypalhelper::PPE_EXPRESS);
if ($aOutput['status'] == 'ERROR') {
$this->_iLastErrorNo = $aOutput['errorcode'];
diff --git a/extend/application/controllers/fcPayOneOrderView.php b/extend/application/controllers/fcPayOneOrderView.php
index be460a80..c539ea1e 100755
--- a/extend/application/controllers/fcPayOneOrderView.php
+++ b/extend/application/controllers/fcPayOneOrderView.php
@@ -110,9 +110,19 @@ public function execute()
public function fcpoHandlePayPalExpress()
{
try {
- $this->_handlePayPalExpressCall();
- }
- catch (oxException $oExcp) {
+ $this->_handlePayPalExpressCall(fcpopaypalhelper::PPE_EXPRESS);
+ } catch (oxException $oExcp) {
+ $oUtilsView = $this->_oFcpoHelper->fcpoGetUtilsView();
+ $oUtilsView->addErrorToDisplay($oExcp);
+ return "basket";
+ }
+ }
+
+ public function fcpoHandlePayPalExpressV2()
+ {
+ try {
+ $this->_handlePayPalExpressCall(fcpopaypalhelper::PPE_V2_EXPRESS);
+ } catch (oxException $oExcp) {
$oUtilsView = $this->_oFcpoHelper->fcpoGetUtilsView();
$oUtilsView->addErrorToDisplay($oExcp);
return "basket";
@@ -128,21 +138,13 @@ public function fcpoHandlePayPalExpress()
protected function _fcpoDoesExpressUserAlreadyExist($sEmail) {
$sPaymentId = $this->_oFcpoHelper->fcpoGetSessionVariable('paymentid');
$oOrder = $this->_oFcpoHelper->getFactoryObject('oxOrder');
- $blReturn = $oOrder->fcpoDoesUserAlreadyExist($sEmail);
-
- $blIsExpressException = (
- $blReturn !== false &&
- (
- $sPaymentId == 'fcpopaypal_express'
- )
- );
- if ($blIsExpressException) {
+ $blReturn = $oOrder->fcpoDoesUserAlreadyExist($sEmail);
+ if ($blReturn !== false && in_array($sPaymentId, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS])) { // is express exception
// always using the address that has been
// sent by express service is mandatory
$blReturn = false;
}
-
return $blReturn;
}
@@ -156,14 +158,12 @@ protected function _fcpoDoesPaypalUserAlreadyExist($sEmail)
{
$sPaymentId = $this->_oFcpoHelper->fcpoGetSessionVariable('paymentid');
$oOrder = $this->_oFcpoHelper->getFactoryObject('oxOrder');
- $blReturn = $blReturn = $oOrder->fcpoDoesUserAlreadyExist($sEmail);
- $blIsPaypalExpressException = ($blReturn !== false && $sPaymentId == 'fcpopaypal_express');
- if ($blIsPaypalExpressException) {
+ $blReturn = $oOrder->fcpoDoesUserAlreadyExist($sEmail);
+ if ($blReturn !== false && in_array($sPaymentId, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS])) { // is paypal express exception
// always using the address that has been sent by paypal express is mandatory
$blReturn = false;
}
-
return $blReturn;
}
@@ -190,7 +190,7 @@ public function fcpoGetEditAddressTargetController() {
$sPaymentId = $this->_oFcpoHelper->fcpoGetSessionVariable('paymentid');
$aMap = array(
- 'fcpopaypal_express'=>'basket'
+ fcpopaypalhelper::PPE_EXPRESS => 'basket',
);
$sReturn = (isset($aMap[$sPaymentId])) ?
@@ -212,7 +212,7 @@ public function fcpoGetEditAddressTargetAction()
$sPaymentId = $this->_oFcpoHelper->fcpoGetSessionVariable('paymentid');
$aMap = array(
- 'fcpopaypal_express'=>'fcpoUsePayPalExpress'
+ fcpopaypalhelper::PPE_EXPRESS => 'fcpoUsePayPalExpress',
);
$sReturn = (isset($aMap[$sPaymentId])) ?
@@ -484,7 +484,8 @@ protected function _fcpoFetchStreetAndNumber($aResponse, $blShipping=false)
$sPaymentId = $this->_oFcpoHelper->fcpoGetSessionVariable('paymentid');
switch($sPaymentId) {
- case 'fcpopaypal_express':
+ case fcpopaypalhelper::PPE_EXPRESS:
+ case fcpopaypalhelper::PPE_V2_EXPRESS:
$aStreetAndNumber =
$this->_fcpoSplitAddress($aResponse['add_paydata[shipping_street]']);
break;
@@ -519,16 +520,16 @@ protected function _fcpoThrowException($sMessage)
* @param void
* @return void
*/
- protected function _handlePayPalExpressCall() {
+ protected function _handlePayPalExpressCall($sPaymentId) {
$sWorkorderId = $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoWorkorderId');
- if($sWorkorderId) {
- $oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
- $aOutput = $oRequest->sendRequestGenericPayment($sWorkorderId);
- $this->_oFcpoHelper->fcpoSetSessionVariable('paymentid', "fcpopaypal_express");
+ if ($sWorkorderId) {
+ $oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
+ $aOutput = $oRequest->sendRequestGenericPayment($sPaymentId, $sWorkorderId);
+ $this->_oFcpoHelper->fcpoSetSessionVariable('paymentid', $sPaymentId);
$oUser = $this->_fcpoHandleExpressUser($aOutput);
- if($oUser) {
- $this->_fcpoUpdateUserOfExpressBasket($oUser, "fcpopaypal_express");
+ if ($oUser) {
+ $this->_fcpoUpdateUserOfExpressBasket($oUser, $sPaymentId);
}
}
}
diff --git a/extend/application/controllers/fcPayOnePaymentView.php b/extend/application/controllers/fcPayOnePaymentView.php
index 8a6d4ccf..f827afde 100755
--- a/extend/application/controllers/fcPayOnePaymentView.php
+++ b/extend/application/controllers/fcPayOnePaymentView.php
@@ -507,9 +507,7 @@ public function getChecktype()
*/
public function fcpoPaymentActive($sPaymentId)
{
- $oPayment = $this->_oFcpoHelper->getFactoryObject('oxPayment');
- $oPayment->load($sPaymentId);
- return (bool) ($oPayment->oxpayments__oxactive->value);
+ return fcpopaymenthelper::getInstance()->isPaymentMethodActive($sPaymentId);
}
/**
@@ -1500,7 +1498,8 @@ protected function _getOperationModeELV()
*/
protected function _fcpoCheckPaypalExpressRemoval()
{
- $this->_fcpoRemovePaymentFromFrontend('fcpopaypal_express');
+ $this->_fcpoRemovePaymentFromFrontend(fcpopaypalhelper::PPE_EXPRESS);
+ $this->_fcpoRemovePaymentFromFrontend(fcpopaypalhelper::PPE_V2_EXPRESS);
//&& !$this->_oFcpoHelper->fcpoGetSessionVariable('fcpoWorkorderId')
}
diff --git a/extend/application/models/fcPayOneBasket.php b/extend/application/models/fcPayOneBasket.php
index 0bba0daf..ce4313fb 100644
--- a/extend/application/models/fcPayOneBasket.php
+++ b/extend/application/models/fcPayOneBasket.php
@@ -21,14 +21,12 @@
class fcPayOneBasket extends fcPayOneBasket_parent
{
-
/**
* Helper object for dealing with different shop versions
*
* @var object
*/
protected $_oFcpoHelper = null;
-
/**
* init object construction
@@ -40,37 +38,6 @@ public function __construct()
parent::__construct();
$this->_oFcpoHelper = oxNew('fcpohelper');
}
-
-
- /**
- * Returns wether paypal express is active or not
- *
- * @return bool
- */
- public function fcpoIsPayPalExpressActive()
- {
- $oDb = $this->_oFcpoHelper->fcpoGetDb();
- $sQuery = "SELECT oxactive FROM oxpayments WHERE oxid = 'fcpopaypal_express'";
- return (bool)$oDb->GetOne($sQuery);
- }
-
-
- /**
- * Returns pic that is configured in database
- *
- * @param void
- * @return string
- */
- public function fcpoGetPayPalExpressPic()
- {
- $oDb = $this->_oFcpoHelper->fcpoGetDb();
- $oLang = $this->_oFcpoHelper->fcpoGetLang();
- $iLangId = $oLang->getBaseLanguage();
- $sQuery = "SELECT fcpo_logo FROM fcpopayoneexpresslogos WHERE fcpo_logo != '' AND fcpo_langid = '{$iLangId}' ORDER BY fcpo_default DESC";
- $sPic = $oDb->GetOne($sQuery);
-
- return $sPic;
- }
/**
* Iterates through basket items and calculates its delivery costs
@@ -112,5 +79,4 @@ public function fcpoCalcDeliveryCost()
return $oDeliveryPrice;
}
-
}
diff --git a/extend/application/models/fcPayOneOrder.php b/extend/application/models/fcPayOneOrder.php
index c676413b..b63152db 100755
--- a/extend/application/models/fcPayOneOrder.php
+++ b/extend/application/models/fcPayOneOrder.php
@@ -1246,30 +1246,26 @@ public function debitNeedsBankData()
*/
public function isDetailedProductInfoNeeded()
{
- $blForcedByPaymentMethod = in_array(
- $this->oxorder__oxpaymenttype->value,
- array(
- 'fcpobillsafe',
- 'fcpoklarna',
- 'fcpoklarna_invoice',
- 'fcpoklarna_installments',
- 'fcpoklarna_directdebit',
- 'fcpo_secinvoice',
- 'fcporp_bill',
- 'fcporp_debitnote',
- 'fcporp_installment',
- 'fcpopl_secinvoice',
- 'fcpopl_secinstallment',
- 'fcpopl_secdebitnote',
- )
- );
-
- if ($blForcedByPaymentMethod) return true;
-
- $oConfig = $this->_oFcpoHelper->fcpoGetConfig();
- $blSendArticleList = $oConfig->getConfigParam('blFCPOSendArticlelist');
-
- return $blSendArticleList;
+ if ((bool)$this->_oFcpoHelper->fcpoGetConfig()->getConfigParam('blFCPOSendArticlelist') === true ||
+ in_array($this->oxorder__oxpaymenttype->value, [
+ 'fcpobillsafe',
+ 'fcpoklarna',
+ 'fcpoklarna_invoice',
+ 'fcpoklarna_installments',
+ 'fcpoklarna_directdebit',
+ 'fcpo_secinvoice',
+ 'fcporp_bill',
+ 'fcporp_debitnote',
+ 'fcporp_installment',
+ 'fcpopl_secinvoice',
+ 'fcpopl_secinstallment',
+ 'fcpopl_secdebitnote',
+ 'fcpopl_secdebitnote',
+ fcpopaypalhelper::PPE_V2_EXPRESS,
+ ])) {
+ return true;
+ }
+ return false;
}
public function isCancellationReasonNeeded()
@@ -1667,7 +1663,12 @@ public function getAuthorizationMethod()
public function fcIsPayPalOrder()
{
$blReturn = false;
- if ($this->oxorder__oxpaymenttype->value == 'fcpopaypal' || $this->oxorder__oxpaymenttype->value == 'fcpopaypal_express') {
+ if (in_array($this->oxorder__oxpaymenttype->value, [
+ 'fcpopaypal',
+ 'fcpopaypalv2',
+ fcpopaypalhelper::PPE_EXPRESS,
+ fcpopaypalhelper::PPE_V2_EXPRESS,
+ ])) {
$blReturn = true;
}
return $blReturn;
diff --git a/extend/application/models/fcPayOnePayment.php b/extend/application/models/fcPayOnePayment.php
index a5cc013c..9f064992 100755
--- a/extend/application/models/fcPayOnePayment.php
+++ b/extend/application/models/fcPayOnePayment.php
@@ -48,6 +48,8 @@ class fcPayOnePayment extends fcPayOnePayment_parent
'fcpocreditcard',
'fcpopaypal',
'fcpopaypal_express',
+ 'fcpopaypalv2',
+ 'fcpopaypalv2_express',
'fcpoklarna',
'fcpoklarna_invoice',
'fcpoklarna_installments',
@@ -82,6 +84,8 @@ class fcPayOnePayment extends fcPayOnePayment_parent
protected static $_aRedirectPayments = array(
'fcpopaypal',
'fcpopaypal_express',
+ 'fcpopaypalv2',
+ 'fcpopaypalv2_express',
'fcpoklarna',
'fcpoklarna_invoice',
'fcpoklarna_installments',
diff --git a/extend/core/fcPayOneViewConf.php b/extend/core/fcPayOneViewConf.php
index fc6e2aa6..775d8a1b 100755
--- a/extend/core/fcPayOneViewConf.php
+++ b/extend/core/fcPayOneViewConf.php
@@ -310,29 +310,73 @@ public function fcpoIsKlarnaPaynow()
/**
* Returns if amazonpay is active and though button can be displayed
*
- * @param void
* @return bool
*/
public function fcpoCanDisplayAmazonPayButton()
{
- $blIsActive = $this->_fcpoPaymentIsActive('fcpoamazonpay');
-
- return $blIsActive;
+ return fcpopaymenthelper::getInstance()->isPaymentMethodActive('fcpoamazonpay');
}
/**
- * Checks is given payment is active
+ * Returns if paypal is active and therefor button can be displayed
*
- * @param $sPaymentId
* @return bool
*/
- protected function _fcpoPaymentIsActive($sPaymentId)
+ public function fcpoCanDisplayPayPalExpressV2Button()
{
- $oPayment = $this->_oFcpoHelper->getFactoryObject('oxpayment');
- $oPayment->load($sPaymentId);
- $blIsActive = (bool) $oPayment->oxpayments__oxactive->value;
+ return fcpopaymenthelper::getInstance()->isPaymentMethodActive(fcpopaypalhelper::PPE_V2_EXPRESS);
+ }
+
+ /**
+ * Returns PayPal V2 Express Button ID
+ *
+ * @return string
+ */
+ public function fcpoGetPayPalExpressV2GetButtonId($sPosition)
+ {
+ $sButtonId = "fcpoPayPalExpressV2";
+ if (fcpopaypalhelper::getInstance()->showBNPLButton() === true) {
+ $sButtonId .= "PayLater";
+ }
+ return $sButtonId.$sPosition;
+ }
- return $blIsActive;
+ /**
+ * Returns PayPal V2 Express Button Javascript URL
+ *
+ * @return string
+ */
+ public function fcpoGetPayPalExpressV2JavascriptUrl()
+ {
+ return fcpopaypalhelper::getInstance()->getJavascriptUrl();
+ }
+
+ /**
+ * Returns PayPal V2 Express Button color
+ *
+ * @return string
+ */
+ public function fcpoGetPayPalExpressButtonColor()
+ {
+ return fcpopaypalhelper::getInstance()->getButtonColor();
+ }
+
+ /**
+ * Returns PayPal V2 Express Button shape
+ *
+ * @return string
+ */
+ public function fcpoGetPayPalExpressButtonShape()
+ {
+ return fcpopaypalhelper::getInstance()->getButtonShape();
+ }
+
+ /**
+ * @return string
+ */
+ public function fcpoGetPayPalExpressSuccessUrl()
+ {
+ return fcporedirecthelper::getInstance()->getSuccessUrl(false, 'fcpoHandlePayPalExpressV2');
}
/**
@@ -340,12 +384,8 @@ protected function _fcpoPaymentIsActive($sPaymentId)
*/
public function fcpoGetAmazonWidgetsUrl()
{
- $oPayment = $this->_oFcpoHelper->getFactoryObject('oxpayment');
- $oPayment->load('fcpoamazonpay');
- $blIsLive = $oPayment->oxpayments__fcpolivemode->value;
-
$sAmazonWidgetsUrl = 'https://static-eu.payments-amazon.com/OffAmazonPayments/eur/sandbox/lpa/js/Widgets.js';
- if ($blIsLive) {
+ if (fcpopaymenthelper::getInstance()->isLiveMode('fcpoamazonpay') === true) {
$sAmazonWidgetsUrl = 'https://static-eu.payments-amazon.com/OffAmazonPayments/eur/lpa/js/Widgets.js';
}
@@ -852,13 +892,17 @@ public function fcpoGetBNPLDeviceToken($sPaylaPartnerId,$sPartnerMerchantId)
return $sPaylaPartnerId . "_" . $sPartnerMerchantId . "_" . $sUUIDv4;
}
+ /**
+ * @param string $sPaymentId
+ * @return string
+ */
public function fcpoGetPayoneSecureEnvironment($sPaymentId)
{
- $oPayment = $this->_oFcpoHelper->getFactoryObject('oxpayment');
- $oPayment->load($sPaymentId);
- $blIsLive = $oPayment->oxpayments__fcpolivemode->value;
-
- return $blIsLive ? 'p' : 't';
+ $sEnvironment = 't'; // test
+ if (fcpopaymenthelper::getInstance()->isLiveMode($sPaymentId) === true) {
+ $sEnvironment = 'p'; // production/live
+ }
+ return $sEnvironment;
}
public function fcpoGetMerchantId()
diff --git a/lib/fcporequest.php b/lib/fcporequest.php
index 99a3c55e..37c5d6eb 100755
--- a/lib/fcporequest.php
+++ b/lib/fcporequest.php
@@ -398,11 +398,18 @@ protected function _setPaymentParamsDebitNote($aDynvalue)
*/
protected function _setPaymentParamsPayPal($oOrder, $sRefNr)
{
+ $sWalletType = 'PAL';
+ if (in_array($oOrder->oxorder__oxpaymenttype->value, ['fcpopaypal', fcpopaypalhelper::PPE_EXPRESS]) === true) {
+ $sWalletType = 'PPE';
+
+ // dont send narrative text param for PayPal V2 - it makes the request fail
+ $this->addParameter('narrative_text', 'Ihre Bestellung Nr. ' . $sRefNr . ' bei ' . $this->_oFcpoHelper->fcpoGetShopName());
+ }
+
$this->addParameter('clearingtype', 'wlt'); //Payment method
- $this->addParameter('wallettype', 'PPE');
- $this->addParameter('narrative_text', 'Ihre Bestellung Nr. ' . $sRefNr . ' bei ' . $this->_oFcpoHelper->fcpoGetShopName());
+ $this->addParameter('wallettype', $sWalletType);
- if ($oOrder->oxorder__oxpaymenttype->value == 'fcpopaypal_express') {
+ if (in_array($oOrder->oxorder__oxpaymenttype->value, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS]) === true) {
$this->addParameter('workorderid', $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoWorkorderId'));
}
@@ -521,7 +528,9 @@ protected function setPaymentParameters($oOrder, $aDynvalue, $sRefNr, $blIsPreau
$blAddRedirectUrls = true;
break;
case 'fcpopaypal':
- case 'fcpopaypal_express':
+ case 'fcpopaypalv2':
+ case fcpopaypalhelper::PPE_EXPRESS:
+ case fcpopaypalhelper::PPE_V2_EXPRESS:
$blAddRedirectUrls = $this->_setPaymentParamsPayPal($oOrder, $sRefNr);
break;
case 'fcpoklarna':
@@ -785,77 +794,19 @@ protected function fcpoAddParametersOnlineTrustly($oOrder, $aDynvalue)
/**
* Adding redirect urls
*
- * @param $sAbortClass
- * @param bool $sRefNr
- * @param mixed $mRedirectFunction
- * @param bool $sToken
- * @param bool $sDeliveryMD5
+ * @param string $sAbortClass
+ * @param string|false $sRefNr
+ * @param string|false $sRedirectFunction
+ * @param string|false $sToken
+ * @param string|false $sDeliveryMD5
* @param bool $blAddAmazonLogoff
* @return void
*/
- protected function _addRedirectUrls($sAbortClass, $sRefNr = false, $mRedirectFunction = false, $sToken = false, $sDeliveryMD5 = false, $blAddAmazonLogoff = false)
+ protected function _addRedirectUrls($sAbortClass, $sRefNr = false, $sRedirectFunction = false, $sToken = false, $sDeliveryMD5 = false, $blAddAmazonLogoff = false)
{
- $oConfig = $this->getConfig();
- $oSession = $this->_oFcpoHelper->fcpoGetSession();
- $sShopURL = $oConfig->getCurrentShopUrl();
-
- $sRToken = '';
- if ($this->_oFcpoHelper->fcpoGetIntShopVersion() >= 4310) {
- $sRToken = '&rtoken=' . $oSession->getRemoteAccessToken();
- }
-
- $sSid = $oSession->sid(true);
- if ($sSid != '') {
- $sSid = '&' . $sSid;
- }
-
- $sAddParams = '';
-
- if ($sRefNr) {
- $sAddParams .= '&refnr=' . $sRefNr;
- }
-
- if (is_string($mRedirectFunction)) {
- $sAddParams .= '&fnc='.$mRedirectFunction;
- } else {
- $sAddParams .= '&fnc=execute';
- }
-
-
- if ($sDeliveryMD5) {
- $sAddParams .= '&sDeliveryAddressMD5=' . $sDeliveryMD5;
- } elseif ($this->_oFcpoHelper->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
- $sAddParams .= '&sDeliveryAddressMD5=' . $this->_oFcpoHelper->fcpoGetRequestParameter('sDeliveryAddressMD5');
- }
-
- $blDownloadableProductsAgreement = $this->_oFcpoHelper->fcpoGetRequestParameter('oxdownloadableproductsagreement');
- if ($blDownloadableProductsAgreement) {
- $sAddParams .= '&fcdpa=1'; // rewrite for oxdownloadableproductsagreement-param because of length-restriction
- }
-
- $blServiceProductsAgreement = $this->_oFcpoHelper->fcpoGetRequestParameter('oxserviceproductsagreement');
- if ($blServiceProductsAgreement) {
- $sAddParams .= '&fcspa=1'; // rewrite for oxserviceproductsagreement-param because of length-restriction
- }
-
- if (!$sToken) {
- $sToken = $this->_oFcpoHelper->fcpoGetRequestParameter('stoken');
- }
-
- $oLang = $this->_oFcpoHelper->fcpoGetLang();
- $sPaymentErrorTextParam = "&payerrortext=".urlencode($oLang->translateString('FCPO_PAY_ERROR_REDIRECT', null, false));
- $sPaymentErrorParam = '&payerror=-20'; // see source/modules/fc/fcpayone/out/blocks/fcpo_payment_errors.tpl
- $sSuccessUrl = $sShopURL . 'index.php?cl=order&fcposuccess=1&ord_agb=1&stoken=' . $sToken . $sSid . $sAddParams . $sRToken;
- $sErrorUrl = $sShopURL . 'index.php?type=error&cl=' . $sAbortClass . $sRToken . $sPaymentErrorParam . $sPaymentErrorTextParam;
- $sBackUrl = $sShopURL . 'index.php?type=cancel&cl=' . $sAbortClass . $sRToken;
-
- if ($blAddAmazonLogoff) {
- $sErrorUrl .= "&fcpoamzaction=logoff";
- }
-
- $this->addParameter('successurl', $sSuccessUrl);
- $this->addParameter('errorurl', $sErrorUrl);
- $this->addParameter('backurl', $sBackUrl);
+ $this->addParameter('successurl', fcporedirecthelper::getInstance()->getSuccessUrl($sRefNr, $sRedirectFunction, $sToken, $sDeliveryMD5));
+ $this->addParameter('backurl', fcporedirecthelper::getInstance()->getCancelUrl($sAbortClass));
+ $this->addParameter('errorurl', fcporedirecthelper::getInstance()->getErrorUrl($sAbortClass, $blAddAmazonLogoff));
}
/**
@@ -1005,6 +956,18 @@ protected function addParametersOnlineTransaction($oOrder, $aDynvalue)
}
+ # protected function addInvoicePosition($sId, $dPrice, $sItemType, $iAmount, $sDesc, $dVat, $sCategoryUrl = false)
+
+ protected function addInvoicePosition($iIndex, $sId, $dPrice, $sItemType, $dItemAmount, $sDesc, $dVat)
+ {
+ $this->addParameter('id[' . $iIndex . ']', $sId);
+ #$this->addParameter('pr[' . $iIndex . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($dPrice));
+ $this->addParameter('it[' . $iIndex . ']', $sItemType);
+ $this->addParameter('no[' . $iIndex . ']', $dItemAmount);
+ $this->addParameter('de[' . $iIndex . ']', $sDesc);
+ $this->addParameter('va[' . $iIndex . ']', number_format($dVat * 100, 0, '.', ''));
+ }
/**
* Add product information for module invoicing
@@ -1026,25 +989,15 @@ public function addProductInfo($oOrder, $aPositions = false, $blDebit = false)
/** @var oxorderarticle $oOrderarticle */
foreach ($aOrderArticleListe->getArray() as $oOrderarticle) {
if ($aPositions === false || array_key_exists($oOrderarticle->getId(), $aPositions) !== false) {
+ $dItemAmount = $oOrderarticle->oxorderarticles__oxamount->value;
if ($aPositions !== false && array_key_exists($oOrderarticle->getId(), $aPositions) !== false) {
$dItemAmount = $aPositions[$oOrderarticle->getId()]['amount'];
- } else {
- $dItemAmount = $oOrderarticle->oxorderarticles__oxamount->value;
}
- $dPrice = $this->fcpoGetPosPr(
- $oOrderarticle->oxorderarticles__oxbprice->value,
- $oOrder->oxorder__oxpaymenttype->value,
- $blDebit
- );
+ $dPrice = $this->fcpoGetPosPr($oOrderarticle->oxorderarticles__oxbprice->value, $oOrder->oxorder__oxpaymenttype->value, $blDebit);
- $this->addParameter('id[' . $i . ']', $oOrderarticle->oxorderarticles__oxartnum->value);
- $this->addParameter('pr[' . $i . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addInvoicePosition($i, $oOrderarticle->oxorderarticles__oxartnum->value, $dPrice, 'goods', $dItemAmount, $oOrderarticle->oxorderarticles__oxtitle->value, $oOrderarticle->oxorderarticles__oxvat->value);
$dAmount += $oOrderarticle->oxorderarticles__oxbprice->value * $dItemAmount;
- $this->addParameter('it[' . $i . ']', 'goods');
- $this->addParameter('no[' . $i . ']', $dItemAmount);
- $this->addParameter('de[' . $i . ']', $oOrderarticle->oxorderarticles__oxtitle->value);
- $this->addParameter('va[' . $i . ']', number_format($oOrderarticle->oxorderarticles__oxvat->value * 100, 0, '.', ''));
$i++;
}
}
@@ -1054,119 +1007,71 @@ public function addProductInfo($oOrder, $aPositions = false, $blDebit = false)
if ($aPositions === false || $blFirstCapture === true || $blDebit === true) {
$oLang = $this->_oFcpoHelper->fcpoGetLang();
+
+ // Delivery costs
if ($oOrder->oxorder__oxdelcost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxdelcost', $aPositions) !== false))) {
- $sDelDesc = '';
+ $sDelDesc = $oLang->translateString('FCPO_DEDUCTION', null, false);
if ($oOrder->oxorder__oxdelcost->value > 0) {
- $sDelDesc .= $oLang->translateString('FCPO_SURCHARGE', null, false);
- } else {
- $sDelDesc .= $oLang->translateString('FCPO_DEDUCTION', null, false);
+ $sDelDesc = $oLang->translateString('FCPO_SURCHARGE', null, false);
}
$sDelDesc .= ' ' . str_replace(':', '', $oLang->translateString('FCPO_SHIPPINGCOST', null, false));
- $dPrice = $this->fcpoGetPosPr(
- $oOrder->oxorder__oxdelcost->value,
- $oOrder->oxorder__oxpaymenttype->value,
- $blDebit
- );
+ $dPrice = $this->fcpoGetPosPr($oOrder->oxorder__oxdelcost->value, $oOrder->oxorder__oxpaymenttype->value, $blDebit);
- $this->addParameter('id[' . $i . ']', 'delivery');
- $this->addParameter('pr[' . $i . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addInvoicePosition($i, 'delivery', $dPrice, 'shipment', 1, $sDelDesc, $oOrder->oxorder__oxdelvat->value);
$dAmount += $oOrder->oxorder__oxdelcost->value;
- $this->addParameter('it[' . $i . ']', 'shipment');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $sDelDesc);
- $this->addParameter('va[' . $i . ']', number_format($oOrder->oxorder__oxdelvat->value * 100, 0, '.', ''));
$i++;
}
+
+ // Payment costs
if ($oOrder->oxorder__oxpaycost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxpaycost', $aPositions) !== false))) {
- $sPayDesc = '';
+ $sPayDesc = $oLang->translateString('FCPO_DEDUCTION', null, false);
if ($oOrder->oxorder__oxpaycost->value > 0) {
$sPayDesc .= $oLang->translateString('FCPO_SURCHARGE', null, false);
- } else {
- $sPayDesc .= $oLang->translateString('FCPO_DEDUCTION', null, false);
}
$sPayDesc .= ' ' . str_replace(':', '', $oLang->translateString('FCPO_PAYMENTTYPE', null, false));
- $dPrice = $this->fcpoGetPosPr(
- $oOrder->oxorder__oxpaycost->value,
- $oOrder->oxorder__oxpaymenttype->value,
- $blDebit
- );
+ $dPrice = $this->fcpoGetPosPr($oOrder->oxorder__oxpaycost->value, $oOrder->oxorder__oxpaymenttype->value, $blDebit);
- $this->addParameter('id[' . $i . ']', 'payment');
- $this->addParameter('pr[' . $i . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addInvoicePosition($i, 'payment', $dPrice, 'handling', 1, $sPayDesc, $oOrder->oxorder__oxpayvat->value);
$dAmount += $oOrder->oxorder__oxpaycost->value;
- $this->addParameter('it[' . $i . ']', 'handling');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $sPayDesc);
- $this->addParameter('va[' . $i . ']', number_format($oOrder->oxorder__oxpayvat->value * 100, 0, '.', ''));
$i++;
}
- if ($oOrder->oxorder__oxwrapcost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxwrapcost', $aPositions) !== false))) {
- $dPrice = $this->fcpoGetPosPr(
- $oOrder->oxorder__oxwrapcost->value,
- $oOrder->oxorder__oxpaymenttype->value,
- $blDebit
- );
+ // Wrapping
+ if ($oOrder->oxorder__oxwrapcost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxwrapcost', $aPositions) !== false))) {
+ $dPrice = $this->fcpoGetPosPr($oOrder->oxorder__oxwrapcost->value, $oOrder->oxorder__oxpaymenttype->value, $blDebit);
- $this->addParameter('id[' . $i . ']', 'wrapping');
- $this->addParameter('pr[' . $i . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addInvoicePosition($i, 'wrapping', $dPrice, 'goods', 1, $oLang->translateString('FCPO_WRAPPING', null, false), 0); // Workaround for wrong vat: oxid saves 18.95... use 0 instead
$dAmount += $oOrder->oxorder__oxwrapcost->value;
- $this->addParameter('it[' . $i . ']', 'goods');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $oLang->translateString('FCPO_WRAPPING', null, false));
- // Workaround for wrong vat: oxid saves 18.95... use 0 instead
- $this->addParameter('va[' . $i . ']', '0');
$i++;
}
- if ($oOrder->oxorder__oxgiftcardcost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxgiftcardcost', $aPositions) !== false))) {
- $dPrice = $this->fcpoGetPosPr(
- $oOrder->oxorder__oxgiftcardcost->value,
- $oOrder->oxorder__oxpaymenttype->value,
- $blDebit
- );
+ // Giftcards
+ if ($oOrder->oxorder__oxgiftcardcost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxgiftcardcost', $aPositions) !== false))) {
+ $dPrice = $this->fcpoGetPosPr($oOrder->oxorder__oxgiftcardcost->value, $oOrder->oxorder__oxpaymenttype->value, $blDebit);
- $this->addParameter('id[' . $i . ']', 'giftcard');
- $this->addParameter('pr[' . $i . ']', number_format($dPrice, 2, '.', '') * 100);
+ $this->addInvoicePosition($i, 'giftcard', $dPrice, 'goods', 1, $oLang->translateString('FCPO_GIFTCARD', null, false), $oOrder->oxorder__oxgiftcardvat->value);
$dAmount += $oOrder->oxorder__oxgiftcardcost->value;
- $this->addParameter('it[' . $i . ']', 'goods');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $oLang->translateString('FCPO_GIFTCARD', null, false));
- $this->addParameter('va[' . $i . ']', number_format($oOrder->oxorder__oxgiftcardvat->value * 100, 0, '.', ''));
$i++;
}
+
$oSession = $this->getSession();
$oBasket = $oSession->getBasket();
if ($oBasket && count($oBasket->getVouchers()) > 0) {
foreach ($oBasket->getVouchers() AS $oVoucher) {
- $this->addParameter('it[' . $i . ']', 'voucher');
- $this->addParameter('id[' . $i . ']', $oVoucher->sVoucherNr);
- $this->addParameter('pr[' . $i . ']', $this->_fcpoGetCentPrice($oVoucher->dVoucherdiscount * -1));
- $this->addParameter('no[' . $i . ']', '1');
- $this->addParameter('de[' . $i . ']', $oLang->translateString('FCPO_VOUCHER', null, false));
- $this->addParameter('va[' . $i . ']', '0');
+ $this->addInvoicePosition($i, $oVoucher->sVoucherNr, ($oVoucher->dVoucherdiscount * -1), 'voucher', 1, $oLang->translateString('FCPO_VOUCHER', null, false), 0);
$i++;
}
} elseif ($oOrder->oxorder__oxvoucherdiscount->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxvoucherdiscount', $aPositions) !== false))) {
- $this->addParameter('id[' . $i . ']', 'voucher');
- $this->addParameter('pr[' . $i . ']', $oOrder->oxorder__oxvoucherdiscount->value * -100);
+ $this->addInvoicePosition($i, 'voucher', ($oOrder->oxorder__oxvoucherdiscount->value * -1), 'voucher', 1, $oLang->translateString('FCPO_VOUCHER', null, false), 0);
$dAmount += ($oOrder->oxorder__oxvoucherdiscount->value * -1);
- $this->addParameter('it[' . $i . ']', 'voucher');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $oLang->translateString('FCPO_VOUCHER', null, false));
- $this->addParameter('va[' . $i . ']', '0');
$i++;
}
+
if ($oOrder->oxorder__oxdiscount->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxdiscount', $aPositions) !== false))) {
- $this->addParameter('id[' . $i . ']', 'discount');
- $this->addParameter('pr[' . $i . ']', round($oOrder->oxorder__oxdiscount->value, 2) * -100);
+ $this->addInvoicePosition($i, 'discount', ($oOrder->oxorder__oxdiscount->value * -1), 'voucher', 1, $oLang->translateString('FCPO_DISCOUNT', null, false), 0);
$dAmount += (round($oOrder->oxorder__oxdiscount->value, 2) * -1);
- $this->addParameter('it[' . $i . ']', 'voucher');
- $this->addParameter('no[' . $i . ']', 1);
- $this->addParameter('de[' . $i . ']', $oLang->translateString('FCPO_DISCOUNT', null, false));
- $this->addParameter('va[' . $i . ']', '0');
}
}
return $dAmount;
@@ -1516,23 +1421,20 @@ protected function _fcpoAddRatePayParameters($oOrder, $aDynvalue)
* @return void
* @return object
*/
- protected function _fcpoAddBasketItemsFromSession($sDeliverySetId=false)
+ protected function _fcpoAddBasketItemsFromSession($sDeliverySetId = false)
{
+ $iIndex = 1;
+
+ $oLang = $this->_oFcpoHelper->fcpoGetLang();
$oSession = $this->getSession();
$oBasket = $oSession->getBasket();
- $iIndex = 1;
foreach ($oBasket->getContents() as $oBasketItem) {
$oArticle = $oBasketItem->getArticle();
- $sArticleIdent =
- ($oArticle->oxarticles__oxean->value) ?
- $oArticle->oxarticles__oxean->value :
- $oArticle->oxarticles__oxartnum->value;
- $this->addParameter('it[' . $iIndex . ']', 'goods');
- $this->addParameter('id[' . $iIndex . ']', $sArticleIdent);
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($oBasketItem));
- $this->addParameter('no[' . $iIndex . ']', $oBasketItem->getAmount());
- $this->addParameter('de[' . $iIndex . ']', $oBasketItem->getTitle());
- $this->addParameter('va[' . $iIndex . ']', $this->_fcpoGetCentPrice($oBasketItem->getPrice()->getVat()));
+ $sArticleIdent = $oArticle->oxarticles__oxartnum->value;
+ if (!empty($oArticle->oxarticles__oxean->value)) {
+ $sArticleIdent = $oArticle->oxarticles__oxean->value;
+ }
+ $this->addInvoicePosition($iIndex, $sArticleIdent, $oBasketItem, 'goods', $oBasketItem->getAmount(), $oBasketItem->getTitle(), $oBasketItem->getPrice()->getVat());
$iIndex++;
}
@@ -1542,81 +1444,48 @@ protected function _fcpoAddBasketItemsFromSession($sDeliverySetId=false)
$oBasket->setCost('oxdelivery', $oDeliveryCosts);
}
- $oLang = $this->_oFcpoHelper->fcpoGetLang();
-
$sDeliveryCosts = $this->_fcpoFetchCostsFromBasket($oBasket, 'oxdelivery');
$sDeliveryCosts = (double) str_replace(',', '.', $sDeliveryCosts);
if ($sDeliveryCosts > 0) {
- $this->addParameter('it[' . $iIndex . ']', 'shipment');
- $this->addParameter('id[' . $iIndex . ']', 'delivery');
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($sDeliveryCosts));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $oLang->translateString('FCPO_SHIPPINGCOST', null, false));
- $this->addParameter('va[' . $iIndex . ']', $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxdelivery'));
+ $this->addInvoicePosition($iIndex, 'delivery', $sDeliveryCosts, 'shipment', 1, $oLang->translateString('FCPO_SHIPPINGCOST', null, false), $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxdelivery'));
$iIndex++;
}
$sWrappingCosts = $this->_fcpoFetchCostsFromBasket($oBasket, 'oxwrapping');
$sWrappingCosts = (double) str_replace(',', '.', $sWrappingCosts);
if ($sWrappingCosts > 0) {
- $this->addParameter('it[' . $iIndex . ']', 'goods');
- $this->addParameter('id[' . $iIndex . ']', 'wrapping');
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($sWrappingCosts));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $oLang->translateString('FCPO_WRAPPING', null, false));
- $this->addParameter('va[' . $iIndex . ']', '0');
+ $this->addInvoicePosition($iIndex, 'wrapping', $sWrappingCosts, 'goods', 1, $oLang->translateString('FCPO_WRAPPING', null, false), 0);
$iIndex++;
}
- $sWrappingCosts = $this->_fcpoFetchCostsFromBasket($oBasket, 'oxgiftcard');
- $sWrappingCosts = (double) str_replace(',', '.', $sWrappingCosts);
- if ($sWrappingCosts > 0) {
- $this->addParameter('it[' . $iIndex . ']', 'goods');
- $this->addParameter('id[' . $iIndex . ']', 'giftcard');
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($sWrappingCosts));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $oLang->translateString('FCPO_GIFTCARD', null, false));
- $this->addParameter('va[' . $iIndex . ']', $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxgiftcard') * 100);
+ $sGiftcardCosts = $this->_fcpoFetchCostsFromBasket($oBasket, 'oxgiftcard');
+ $sGiftcardCosts = (double) str_replace(',', '.', $sGiftcardCosts);
+ if ($sGiftcardCosts > 0) {
+ $this->addInvoicePosition($iIndex, 'giftcard', $sGiftcardCosts, 'goods', 1, $oLang->translateString('FCPO_GIFTCARD', null, false), $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxgiftcard'));
$iIndex++;
}
$sPaymentCosts = $this->_fcpoFetchCostsFromBasket($oBasket, 'oxpayment');
$sPaymentCosts = (double) str_replace(',', '.', $sPaymentCosts);
if ($sPaymentCosts != 0) {
- $sPayDesc = '';
+ $sPayDesc = $oLang->translateString('FCPO_DEDUCTION', null, false);
if ($sPaymentCosts > 0) {
$sPayDesc .= $oLang->translateString('FCPO_SURCHARGE', null, false);
- } else {
- $sPayDesc .= $oLang->translateString('FCPO_DEDUCTION', null, false);
}
$sPayDesc .= ' ' . str_replace(':', '', $oLang->translateString('FCPO_PAYMENTTYPE', null, false));
- $this->addParameter('it[' . $iIndex . ']', 'handling');
- $this->addParameter('id[' . $iIndex . ']', 'payment');
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($sPaymentCosts));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $sPayDesc);
- $this->addParameter('va[' . $iIndex . ']', $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxpayment'));
+
+ $this->addInvoicePosition($iIndex, 'payment', $sPaymentCosts, 'handling', 1, $sPayDesc, $this->_fcpoFetchVatCostsFromBasket($oBasket, 'oxpayment'));
$iIndex++;
}
foreach ($oBasket->getVouchers() AS $oVoucher) {
- $this->addParameter('it[' . $iIndex . ']', 'voucher');
- $this->addParameter('id[' . $iIndex . ']', $oVoucher->sVoucherNr);
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($oVoucher->dVoucherdiscount * -1));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $oLang->translateString('FCPO_VOUCHER', null, false));
- $this->addParameter('va[' . $iIndex . ']', '0');
+ $this->addInvoicePosition($iIndex, $oVoucher->sVoucherNr, ($oVoucher->dVoucherdiscount * -1), 'voucher', 1, $oLang->translateString('FCPO_VOUCHER', null, false), 0);
$iIndex++;
}
// discounts
$aDiscounts = is_null($oBasket->getDiscounts()) ? [] : $oBasket->getDiscounts();
foreach ($aDiscounts AS $oDiscount) {
- $this->addParameter('it[' . $iIndex . ']', 'voucher');
- $this->addParameter('id[' . $iIndex . ']', 'discount');
- $this->addParameter('pr[' . $iIndex . ']', $this->_fcpoGetCentPrice($oDiscount->dDiscount * -1));
- $this->addParameter('no[' . $iIndex . ']', '1');
- $this->addParameter('de[' . $iIndex . ']', $oLang->translateString('FCPO_DISCOUNT', null, false));
- $this->addParameter('va[' . $iIndex . ']', '0');
+ $this->addInvoicePosition($iIndex, 'discount', ($oDiscount->dDiscount * -1), 'voucher', 1, $oLang->translateString('FCPO_DISCOUNT', null, false), 0);
$iIndex++;
}
@@ -1675,12 +1544,11 @@ protected function _fcpoGetCentPrice($mValue)
} else if (is_float($mValue)) {
$dBruttoPrice = round($mValue, 2);
}
- if (isset($dBruttoPrice)) {
- $oCur = $oConfig->getActShopCurrencyObject();
- $dFactor = (double) pow(10, $oCur->decimal);
- $dReturnPrice = $dBruttoPrice * $dFactor;
- }
+ $oCur = $oConfig->getActShopCurrencyObject();
+ $dFactor = (double)pow(10, $oCur->decimal);
+
+ $dReturnPrice = $dBruttoPrice * $dFactor;
return $this->_fcpoCutDecimalPlaces($dReturnPrice);
}
@@ -2140,7 +2008,7 @@ public function sendRequestRatePayProfile($aRatePayData, $sWorkorderId = false)
$sFinancingType = $this->_fcpoGetFinancingTypeByPaymentId($sPaymentId);
$this->addParameter('request', 'genericpayment'); //Request method
- $this->addParameter('mode', $this->getOperationMode('fcpopaypal_express')); //PayOne Portal Operation Mode (live or test)
+ $this->addParameter('mode', $this->getOperationMode('fcporp_debitnote')); //PayOne Portal Operation Mode (live or test)
$this->addParameter('aid', $oConfig->getConfigParam('sFCPOSubAccountID')); //ID of PayOne Sub-Account
$this->addParameter('clearingtype', 'fnc');
@@ -2484,17 +2352,22 @@ public function addDeliveryAddressParams($blFallbackBillAddress=false)
* make this a generic part of each generic call dor deduplication of code
* @return array
*/
- public function sendRequestGenericPayment($sWorkorderId = false)
+ public function sendRequestGenericPayment($sPaymentType, $sWorkorderId = false)
{
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$oSession = $this->_oFcpoHelper->fcpoGetSession();
$this->addParameter('request', 'genericpayment'); //Request method
- $this->addParameter('mode', $this->getOperationMode('fcpopaypal_express')); //PayOne Portal Operation Mode (live or test)
+ $this->addParameter('mode', $this->getOperationMode($sPaymentType)); //PayOne Portal Operation Mode (live or test)
$this->addParameter('aid', $oConfig->getConfigParam('sFCPOSubAccountID')); //ID of PayOne Sub-Account
$this->addParameter('clearingtype', 'wlt');
- $this->addParameter('wallettype', 'PPE');
+
+ $sWalletType = 'PPE';
+ if ($sPaymentType == fcpopaypalhelper::PPE_V2_EXPRESS) {
+ $sWalletType = 'PAL';
+ }
+ $this->addParameter('wallettype', $sWalletType);
$oBasket = $oSession->getBasket();
$oPrice = $oBasket->getPrice();
@@ -2512,6 +2385,18 @@ public function sendRequestGenericPayment($sWorkorderId = false)
$this->addParameter('add_paydata[action]', 'setexpresscheckout');
}
+ if ($sPaymentType == fcpopaypalhelper::PPE_V2_EXPRESS) {
+ $oPayment = oxNew('oxpayment');
+ $oPayment->load($sPaymentType);
+ $sPaymentAction = "Authorize";
+ if ($oPayment->oxpayments__fcpoauthmode->value == "authorization") {
+ $sPaymentAction = "Capture";
+ }
+ $this->addParameter('add_paydata[payment_action]', $sPaymentAction);
+
+ $this->_fcpoAddBasketItemsFromSession();
+ }
+
$this->_addRedirectUrls('basket', false, 'fcpoHandlePayPalExpress');
return $this->send();
diff --git a/metadata.php b/metadata.php
index 415c65c4..c512f9e4 100755
--- a/metadata.php
+++ b/metadata.php
@@ -98,10 +98,16 @@
'fcpoparamsparser' => 'fc/fcpayone/lib/fcpoparamsparser.php',
// core
'fcpayone_events' => 'fc/fcpayone/core/fcpayone_events.php',
+ // helpers
+ 'fcpobasehelper' => 'fc/fcpayone/application/helper/fcpobasehelper.php',
+ 'fcpopaymenthelper' => 'fc/fcpayone/application/helper/fcpopaymenthelper.php',
+ 'fcpopaypalhelper' => 'fc/fcpayone/application/helper/fcpopaypalhelper.php',
+ 'fcporedirecthelper' => 'fc/fcpayone/application/helper/fcporedirecthelper.php',
),
'templates' => array(
// frontend
'fcpayoneiframe.tpl' => 'fc/fcpayone/application/views/frontend/tpl/fcpayoneiframe.tpl',
+ 'fcpo_paypal_express_v2.tpl' => 'fc/fcpayone/application/views/frontend/tpl/fcpo_paypal_express_v2.tpl',
// admin
'fcpayone_popup_main.tpl' => 'fc/fcpayone/application/views/admin/tpl/popups/fcpayone_popup_main.tpl',
'fcpayone.tpl' => 'fc/fcpayone/application/views/admin/tpl/fcpayone.tpl',
diff --git a/out/blocks/fcpo_basket_btn_next.tpl b/out/blocks/fcpo_basket_btn_next.tpl
index 8dd26fb7..5df6c8dd 100755
--- a/out/blocks/fcpo_basket_btn_next.tpl
+++ b/out/blocks/fcpo_basket_btn_next.tpl
@@ -10,6 +10,11 @@
[{/if}]
+[{if $oViewConf->fcpoCanDisplayPayPalExpressV2Button()}]
+ [{oxstyle include=$oViewConf->fcpoGetModuleCssPath('fcpopaypalexpress.css')}]
+ [{oxid_include_dynamic file="fcpo_paypal_express_v2.tpl" type="payone" position="BasketTop" layout="horizontal"}]
+[{/if}]
+
[{if $oViewConf->fcpoCanDisplayAmazonPayButton()}]
[{assign var="sFcPoTemplatePathAmazon" value=$sFcPoTemplatePath|cat:'/fcpayone_amazon_paybutton.tpl'}]
[{include
@@ -18,4 +23,3 @@
sAmazonButtonClass='payone_basket_amazon_btn_flow'
}]
[{/if}]
-
diff --git a/out/blocks/fcpo_basket_btn_next_bottom.tpl b/out/blocks/fcpo_basket_btn_next_bottom.tpl
index 4eb230c9..86b12d3d 100755
--- a/out/blocks/fcpo_basket_btn_next_bottom.tpl
+++ b/out/blocks/fcpo_basket_btn_next_bottom.tpl
@@ -8,6 +8,11 @@
[{/if}]
+[{if $oViewConf->fcpoCanDisplayPayPalExpressV2Button()}]
+ [{oxstyle include=$oViewConf->fcpoGetModuleCssPath('fcpopaypalexpress.css')}]
+ [{oxid_include_dynamic file="fcpo_paypal_express_v2.tpl" type="payone" position="BasketBottom" layout="horizontal"}]
+[{/if}]
+
[{if $oViewConf->fcpoCanDisplayAmazonPayButton()}]
[{assign var="sFcPoTemplatePath" value=$oViewConf->fcpoGetActiveThemePath()}]
[{assign var="sFcPoTemplatePath" value=$sFcPoTemplatePath|cat:'/fcpayone_amazon_paybutton.tpl'}]
diff --git a/out/src/css/fcpopaypalexpress.css b/out/src/css/fcpopaypalexpress.css
new file mode 100644
index 00000000..474302b2
--- /dev/null
+++ b/out/src/css/fcpopaypalexpress.css
@@ -0,0 +1,11 @@
+#fcpoPayPalExpressV2BasketTop, #fcpoPayPalExpressV2BasketBottom {
+ width: 217px;
+ float: right;
+ padding-right: 12px;
+}
+
+#fcpoPayPalExpressV2PayLaterBasketTop, #fcpoPayPalExpressV2PayLaterBasketBottom {
+ width: 444px;
+ float: right;
+ padding-right: 4px;
+}
\ No newline at end of file
diff --git a/out/src/js/fcPayOne.js b/out/src/js/fcPayOne.js
index c08eb33b..1f8fb978 100755
--- a/out/src/js/fcPayOne.js
+++ b/out/src/js/fcPayOne.js
@@ -695,6 +695,20 @@ $('#fcpo_klarna_combined_agreed, #klarna_payment_selector').change(
}
);
+// >>> PayPal Express V2
+
+function fcpoStartPayPalExpress() {
+ return $.ajax({
+ url: payoneAjaxControllerUrl,
+ method: 'POST',
+ type: 'POST',
+ data: {
+ paymentid: 'fcpopaypalv2_express',
+ action: "start_paypal_express",
+ params: "{}"
+ }
+ });
+}
// >>> APPLE PAY