Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OX6-164 - Added UnitTests to PPE V2 integration #286

Merged
9 changes: 9 additions & 0 deletions application/controllers/admin/fcpayone_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,4 +1155,13 @@ private function writeFile($filename, $content, $destinationPath)
}
}

public function isPayPalV2DelAddressActive()
{
$aConfBools = $this->fcpoGetConfBools();
$sConfigOptionName = "blFCPOPayPalV2DelAddress";
if (!isset($aConfBools[$sConfigOptionName]) || $aConfBools[$sConfigOptionName] === true) {
return true;
}
return false;
}
}
19 changes: 19 additions & 0 deletions application/helper/fcpobasehelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* PAYONE OXID Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE OXID Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE OXID Connector. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.payone.de
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/

abstract class fcpobasehelper
{
/**
Expand Down
19 changes: 19 additions & 0 deletions application/helper/fcpopaymenthelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* PAYONE OXID Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE OXID Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE OXID Connector. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.payone.de
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/

class fcpopaymenthelper extends fcpobasehelper
{
/**
Expand Down
21 changes: 20 additions & 1 deletion application/helper/fcpopaypalhelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* PAYONE OXID Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE OXID Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE OXID Connector. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.payone.de
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/

class fcpopaypalhelper extends fcpobasehelper
{
const PPE_EXPRESS = 'fcpopaypal_express';
Expand Down Expand Up @@ -118,7 +137,7 @@ protected function getClientId()
protected function getSupportedLocaleCode($sLocale = null)
{
if (!$sLocale || !in_array($sLocale, $this->aSupportedLocales)) {
return 'en_US';
$sLocale = 'en_US';
}
return $sLocale;
}
Expand Down
40 changes: 28 additions & 12 deletions application/helper/fcporedirecthelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/**
* PAYONE OXID Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE OXID Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE OXID Connector. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.payone.de
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/

class fcporedirecthelper extends fcpobasehelper
{
/**
Expand Down Expand Up @@ -103,26 +122,23 @@ public function getSuccessUrl($sRefNr = false, $sRedirectFunction = false, $sTok
$sAddParams .= '&refnr=' . $sRefNr;
}

if (!empty($sRedirectFunction)) {
$sAddParams .= '&fnc='.$sRedirectFunction;
} else {
$sAddParams .= '&fnc=execute';
if (empty($sRedirectFunction)) {
$sRedirectFunction = "execute";
}
$sAddParams .= '&fnc='.$sRedirectFunction;


if (empty($sDeliveryMD5) && $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
$sDeliveryMD5 = $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5');
}
if (!empty($sDeliveryMD5)) {
$sAddParams .= '&sDeliveryAddressMD5=' . $sDeliveryMD5;
} elseif ($this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
$sAddParams .= '&sDeliveryAddressMD5=' . $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5');
$sAddParams .= '&sDeliveryAddressMD5='.$sDeliveryMD5;
}

$blDownloadableProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxdownloadableproductsagreement');
if ($blDownloadableProductsAgreement) {
if ($this->getMainHelper()->fcpoGetRequestParameter('oxdownloadableproductsagreement')) {
$sAddParams .= '&fcdpa=1'; // rewrite for oxdownloadableproductsagreement-param because of length-restriction
}

$blServiceProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxserviceproductsagreement');
if ($blServiceProductsAgreement) {
if ($this->getMainHelper()->fcpoGetRequestParameter('oxserviceproductsagreement')) {
$sAddParams .= '&fcspa=1'; // rewrite for oxserviceproductsagreement-param because of length-restriction
}

Expand Down
2 changes: 2 additions & 0 deletions application/views/admin/de/fcPayOne_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@
'FCPO_EXPORT_CONFIG' => "Konfiguration exportieren",

'FCPO_PAYPAL_DELADDRESS' => 'Rechnungsadresse bei fehlender Lieferadresse als Lieferadresse &uuml;bergeben.',
'FCPO_PAYPALV2_DELADDRESS' => 'Rechnungsadresse bei fehlender Lieferadresse als Lieferadresse &uuml;bergeben.',
'FCPO_HELP_PAYPAL_DELADDRESS' => 'Wird f&uuml;r den PayPal Verk&auml;uferschutz ben&ouml;tigt.',
'FCPO_HELP_PAYPALV2_DELADDRESS' => 'Wird f&uuml;r den PayPal Verk&auml;uferschutz ben&ouml;tigt.',
'FCPO_PAYPAL_LOGOS' => 'Hier k&ouml;nnen Sie die verwendeten PayPal Express Logos hinterlegen.',
'FCPO_PAYPAL_LOGOS_ACTIVE' => 'Aktiv',
'FCPO_PAYPAL_LOGOS_LANG' => 'Sprache',
Expand Down
2 changes: 2 additions & 0 deletions application/views/admin/en/fcPayOne_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@
'FCPO_EXPORT_CONFIG' => "Export configuration",

'FCPO_PAYPAL_DELADDRESS' => 'Transmit the billing-address as delivery-address if delivery-address is missing.',
'FCPO_PAYPALV2_DELADDRESS' => 'Transmit the billing-address as delivery-address if delivery-address is missing.',
'FCPO_HELP_PAYPAL_DELADDRESS' => 'This is used for the PayPal seller protection.',
'FCPO_HELP_PAYPALV2_DELADDRESS' => 'This is used for the PayPal seller protection.',
'FCPO_PAYPAL_LOGOS' => 'You can upload the PayPal Express logos here.',
'FCPO_PAYPAL_LOGOS_ACTIVE' => 'active',
'FCPO_PAYPAL_LOGOS_LANG' => 'language',
Expand Down
11 changes: 11 additions & 0 deletions application/views/admin/tpl/fcpayone_main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@
<div class="groupExp">
<div [{if $oView->fcpoIsLogoAdded()}] class="exp"[{/if}]>
<a href="#" onclick="_groupExp(this);return false;" class="rc"><b>[{oxmultilang ident="FCPO_CONFIG_GROUP_PAYPALV2"}]</b></a>
<dl>
<dt>
<input type="hidden" name="confbools[blFCPOPayPalV2DelAddress]" value="false">
<input type="checkbox" name="confbools[blFCPOPayPalV2DelAddress]" value="true" [{if $oView->isPayPalV2DelAddressActive()}]checked[{/if}]>
[{oxinputhelp ident="FCPO_HELP_PAYPALV2_DELADDRESS"}]
</dt>
<dd>
[{oxmultilang ident="FCPO_PAYPALV2_DELADDRESS"}]
</dd>
<div class="spacer"></div>
</dl>
<dl>
<dt>
<input type="hidden" name="confbools[blFCPOPayPalV2BNPL]" value="false">
Expand Down
30 changes: 18 additions & 12 deletions extend/application/controllers/fcPayOneOrderView.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,15 @@ protected function _fcpoThrowException($sMessage)
* @param void
* @return void
*/
protected function _handlePayPalExpressCall($sPaymentId) {
protected function _handlePayPalExpressCall($sPaymentId)
{
if ($this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalExpressRetry') === true && !empty($this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalSuccessUrl'))) {
$this->_oFcpoHelper->fcpoDeleteSessionVariable('blFcpoPayonePayPalExpressRetry');
$sRedirectUrl = $this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalSuccessUrl');
$this->_oFcpoHelper->fcpoDeleteSessionVariable('blFcpoPayonePayPalSuccessUrl');
$this->_oFcpoHelper->fcpoGetUtils()->redirect($sRedirectUrl, false);
}

$sWorkorderId = $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoWorkorderId');
if ($sWorkorderId) {
$oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
Expand Down Expand Up @@ -704,24 +712,22 @@ protected function _validateTermsAndConditions()

/**
* Splits street and number from concatenated combofield
*
*
* @param string $sPayPalStreet
* @return array
*/
protected function _fcpoSplitAddress($sPayPalStreet)
protected function _fcpoSplitAddress($sStreetAndStreetNr)
{
$sStreetNr = '';
if(preg_match('/\s\d/', $sPayPalStreet, $match)) {
$iEndOfStreetPos = strpos($sPayPalStreet, $match[0]);
$iStartOfStreetNrPos = $iEndOfStreetPos +1; // skip space between street and street nr
$sStreetNr = substr($sPayPalStreet, $iStartOfStreetNrPos);
$sPayPalStreet = substr($sPayPalStreet, 0, $iEndOfStreetPos);
preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $sStreetAndStreetNr, $matches);
$sStreet = $sStreetAndStreetNr; // fallback for when splitting doesnt deliver results
$sStreetNr = "";
if (is_array($matches) && count($matches) >= 2) {
$sStreet = $matches[1];
$sStreetNr = $matches[2];
}

return array($sPayPalStreet, $sStreetNr);
return array($sStreet, $sStreetNr);
}


/**
* Searches an existing addressid by extracting response of payone
*
Expand Down
32 changes: 26 additions & 6 deletions extend/application/models/fcPayOneOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ protected function _fcpoFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder) {
$this->_blFinishingSave = true;
$this->save();

$this->_fcpoSaveAfterRedirect($blSaveAfterRedirect);

// deleting remark info only when order is finished
$this->_oFcpoHelper->fcpoDeleteSessionVariable('ordrem');
$this->_oFcpoHelper->fcpoDeleteSessionVariable('stsprotection');
Expand Down Expand Up @@ -526,6 +524,8 @@ protected function _fcpoFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder) {
oxNew(\OxidEsales\Eshop\Core\Counter::class)->update($this->_getCounterIdent(), $this->oxorder__oxordernr->value);
}

$this->_fcpoSaveAfterRedirect($blSaveAfterRedirect);

$this->_oFcpoHelper->fcpoDeleteSessionVariable('fcpoordernotchecked');
$this->_oFcpoHelper->fcpoDeleteSessionVariable('fcpoWorkorderId');

Expand Down Expand Up @@ -960,10 +960,10 @@ protected function _fcpoFinishOrder($blRecalculatingOrder, $oUser, $oBasket, $oU
* @param bool $blSaveAfterRedirect
* @return void
*/
protected function _fcpoSaveAfterRedirect($blSaveAfterRedirect)
protected function _fcpoSaveAfterRedirect($blSaveAfterRedirect)
{
if ($blSaveAfterRedirect === true) {
$sQuery = "UPDATE fcpotransactionstatus SET fcpo_ordernr = '{$this->oxorder__oxordernr->value}' WHERE fcpo_txid = '" . $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoTxid') . "'";
if ($blSaveAfterRedirect === true && !empty($this->oxorder__fcpotxid->value)) {
$sQuery = "UPDATE fcpotransactionstatus SET fcpo_ordernr = '{$this->oxorder__oxordernr->value}' WHERE fcpo_txid = '".$this->oxorder__fcpotxid->value."'";
$this->_oFcpoDb->Execute($sQuery);
}
}
Expand Down Expand Up @@ -1665,8 +1665,24 @@ public function fcIsPayPalOrder()
$blReturn = false;
if (in_array($this->oxorder__oxpaymenttype->value, [
'fcpopaypal',
'fcpopaypalv2',
fcpopaypalhelper::PPE_EXPRESS,
])) {
$blReturn = true;
}
return $blReturn;
}

/**
* Method checks via current paymenttype is of payone paypal V2 type
*
* @param void
* @return boolean
*/
public function fcIsPayPalV2Order()
{
$blReturn = false;
if (in_array($this->oxorder__oxpaymenttype->value, [
'fcpopaypalv2',
fcpopaypalhelper::PPE_V2_EXPRESS,
])) {
$blReturn = true;
Expand Down Expand Up @@ -1860,6 +1876,10 @@ protected function _fcpoFlagOrderPaymentAsRedirect($blFlaggedAsRedirect = true)
*/
protected function _fcpoHandleAuthorizationRedirect($aResponse, $sRefNr, $sAuthorizationType, $sMode, $blReturnRedirectUrl)
{
if ($aResponse['status'] == 'REDIRECT' && in_array($this->oxorder__oxpaymenttype->value, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS])) {
$this->_oFcpoHelper->fcpoSetSessionVariable('blFcpoPayonePayPalExpressRetry', true);
}

$this->_fcpoFlagOrderPaymentAsRedirect();
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$oUtils = $this->_oFcpoHelper->fcpoGetUtils();
Expand Down
Loading
Loading