Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/PAYONE-GmbH/magento-2
Browse files Browse the repository at this point in the history
  • Loading branch information
janteuber committed Apr 20, 2023
2 parents 0e0ae4e + 2e87f68 commit b0b78a7
Show file tree
Hide file tree
Showing 74 changed files with 1,608 additions and 254 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- 3306:3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, bcmath, ctype, curl, dom, hash, iconv, intl, openssl, simplexml, soap, xsl, zip
tools: composer:v1
tools: composer:v2.1
- name: Validate composer.json and composer.lock
run: composer validate

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_magento23.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- 3306:3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, bcmath, ctype, curl, dom, hash, iconv, intl, openssl, simplexml, soap, xsl, zip
tools: composer:v1
tools: composer:v1.8
- name: Validate composer.json and composer.lock
run: composer validate

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_magento244php81.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- 3306:3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, gd, bcmath, ctype, curl, dom, hash, iconv, intl, openssl, simplexml, soap, xsl, zip
tools: composer:v1
tools: composer:v2.1
- name: Validate composer.json and composer.lock
run: composer validate

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: gitleaks-action
uses: gitleaks/[email protected].0
uses: FatchipRobert/[email protected].1
44 changes: 44 additions & 0 deletions Api/Data/RatepayConfigResponseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* PAYONE Magento 2 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 Magento 2 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 Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 8
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2023 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api\Data;

interface RatepayConfigResponseInterface
{
/**
* Returns if editing the address was a success
*
* @return bool
*/
public function getSuccess();

/**
* Returns config json array
*
* @return string
*/
public function getConfig();
}
40 changes: 40 additions & 0 deletions Api/RatepayConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* PAYONE Magento 2 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 Magento 2 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 Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 8
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2023 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api;

interface RatepayConfigInterface
{
/**
* PAYONE editAddress script
* The full class-paths must be given here otherwise the Magento 2 WebApi
* cant handle this with its fake type system!
*
* @param string $cartId
* @return \Payone\Core\Service\V1\Data\RatepayConfigResponse
*/
public function getConfig($cartId);
}
16 changes: 15 additions & 1 deletion Block/Adminhtml/Config/Form/Field/RefreshRatepayProfiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ protected function _prepareLayout()
return $this;
}

/**
* Generates unique javascript function name for each payment method
*
* @param string $sPaymentMethod
* @return string
*/
protected function getJSFunctionName($sPaymentMethod)
{
$sPaymentMethod = ucwords($sPaymentMethod, "_");
$sPaymentMethod = str_replace("_", "", $sPaymentMethod);
return "updateProfileConfigs".$sPaymentMethod;
}

/**
* Unset some non-related element parameters
*
Expand All @@ -69,7 +82,8 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$sPaymentMethod = str_replace('payone_payment/', '', $originalData['path']);

$this->addData([
'ajax_url' => $this->_urlBuilder->getUrl('payone/config_ratepay/refresh', ['method' => $sPaymentMethod])
'ajax_url' => $this->_urlBuilder->getUrl('payone/config_ratepay/refresh', ['method' => $sPaymentMethod]),
'javascript_function_name' => $this->getJSFunctionName($sPaymentMethod),
]);

return $this->_toHtml();
Expand Down
10 changes: 5 additions & 5 deletions Block/BNPL/InstallmentPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public function formatPrice($dPrice)
*/
public function getSelectLinkText($aInstallment)
{
$sText = $this->formatPrice($aInstallment['monthly_amount_value']).' ';
$sText .= $aInstallment['monthly_amount_currency'].' ';
$sText .= __('per month').' - ';
$sText .= $aInstallment['number_of_payments'].' ';
$sText .= __('installments');
$sText = __('Payment in');
$sText .= ' '.$aInstallment['number_of_payments'].' ';
$sText .= __('installments of').' ';
$sText .= $this->formatPrice($aInstallment['monthly_amount_value']).' ';
$sText .= $aInstallment['monthly_amount_currency'];
return $sText;
}
}
188 changes: 188 additions & 0 deletions Block/Form/RatepayInvoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php

namespace Payone\Core\Block\Form;

use Payone\Core\Model\PayoneConfig;

class RatepayInvoice extends Base
{
/**
* @var \Magento\Sales\Model\AdminOrder\Create
*/
protected $orderCreate;

/**
* @var \Payone\Core\Helper\Ratepay
*/
protected $ratepayHelper;

/**
* @var array|null
*/
protected $ratepayConfig = null;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
* @param \Payone\Core\Helper\Ratepay $ratepayHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Sales\Model\AdminOrder\Create $orderCreate,
\Payone\Core\Helper\Ratepay $ratepayHelper,
array $data = []
) {
parent::__construct($context, $data);
$this->orderCreate = $orderCreate;
$this->ratepayHelper = $ratepayHelper;
}

/**
* Retrieve create order model object
*
* @return \Magento\Quote\Model\Quote
*/
public function getQuote()
{
return $this->orderCreate->getQuote();
}

/**
* Tries to determine a matching ratepay configuration
*
* @return array
*/
public function getRatepayConfig()
{
if ($this->ratepayConfig === null) {
$this->ratepayConfig = $this->ratepayHelper->getRatepaySingleConfig(PayoneConfig::METHOD_RATEPAY_INVOICE, $this->getQuote());
}
return $this->ratepayConfig;
}

/**
* Returns snippet id from config
*
* @return string
*/
public function getDevicefingerprintSnippetId()
{
return $this->ratepayHelper->getConfigParam('devicefingerprint_snippet_id', 'ratepay', 'payone_misc');
}

/**
* Returns token generated by Ratepay helper
*
* @return string
*/
public function getDevicefingerprintToken()
{
return $this->ratepayHelper->getRatepayDeviceFingerprintToken();
}

/**
* Returns if birthday has to be entered
*
* @return bool
*/
public function isBirthdayNeeded()
{
if ($this->isB2BMode() === true) {
return false;
}
return true;
}

/**
* Return if customer has entered a company name in his billing address
*
* @return bool
*/
public function isB2BMode()
{
$billingAddress = $this->getQuote()->getBillingAddress();
if ($billingAddress && !empty($billingAddress->getCompany())) {
return true;
}
return false;
}

/**
* Return if ratepay config allows B2B mode
*
* @return bool
*/
public function isB2BModeAllowed()
{
$aConfig = $this->getRatepayConfig();
if (isset($aConfig['b2bAllowed'])) {
return (bool)$aConfig['b2bAllowed'];
}
return false;
}

/**
* Return if ratepay config allows differing delivery addresses
*
* @return bool
*/
public function isDifferingDeliveryAddressAllowed()
{
$aConfig = $this->getRatepayConfig();
if (isset($aConfig['differentAddressAllowed'])) {
return (bool)$aConfig['differentAddressAllowed'];
}
return false;
}

/**
* Returns if billing address is different as shipping address
*
* @return true
*/
public function hasDifferingDeliveryAddress()
{
return !$this->getQuote()->getShippingAddress()->getSameAsBilling();
}

/**
* Returns the customers birthday if known
*
* @return string
*/
public function getBirthday()
{
return $this->getQuote()->getCustomer()->getDob();
}

/**
* Returns a part of the birthday (day, month or year)
*
* @param string $sPart
* @return string
*/
public function getBirthdayPart($sPart)
{
$sBirthday = $this->getBirthday();
if (!empty($sBirthday)) {
$timestamp = strtotime($sBirthday);
return date($sPart, $timestamp);
}
return '';
}

/**
* Returns if the telephone number has to be entered
*
* @return bool
*/
public function isTelephoneNeeded()
{
$billingAddress = $this->getQuote()->getBillingAddress();
if ($billingAddress && !empty($billingAddress->getTelephone())) {
return false;
}
return true;
}
}
1 change: 0 additions & 1 deletion Block/Onepage/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function __construct(
) {
$this->_salesConfig = $salesConfig;
parent::__construct($context, $customerSession, $checkoutSession, $salesConfig, $layoutProcessors, $data);
$this->_isScopePrivate = true;
$this->layoutProcessors = $layoutProcessors;
$this->baseHelper = $baseHelper;
}
Expand Down
6 changes: 3 additions & 3 deletions Block/RatepayDeviceFingerprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public function getDevicefingerprintToken()
*/
protected function isRatepayMethodActive()
{
if ($this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_INVOICE) === false ||
$this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_DEBIT) === false ||
$this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_INSTALLMENT) === false
if ($this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_INVOICE) === true ||
$this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_DEBIT) === true ||
$this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_RATEPAY_INSTALLMENT) === true
) {
return true;
}
Expand Down
Loading

0 comments on commit b0b78a7

Please sign in to comment.