Skip to content

Commit

Permalink
Merge pull request #90 from FatchipRobert/MAG2-14-Payolution
Browse files Browse the repository at this point in the history
MAG2-14 - Added Payolution invoice, debit and installments
  • Loading branch information
T-Kuchel authored Aug 2, 2017
2 parents 5d49cb0 + 87a3850 commit 5018ce9
Show file tree
Hide file tree
Showing 61 changed files with 4,724 additions and 86 deletions.
25 changes: 25 additions & 0 deletions Api/AddresscheckInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2016 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api;

interface AddresscheckInterface
Expand Down
24 changes: 24 additions & 0 deletions Api/Data/AddresscheckResponseInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2017 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api\Data;

interface AddresscheckResponseInterface
Expand Down
51 changes: 51 additions & 0 deletions Api/Data/InstallmentPlanResponseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2017 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api\Data;

interface InstallmentPlanResponseInterface
{
/**
* Returns if the installment plan request was a success
*
* @return bool
*/
public function getSuccess();

/**
* Returns errormessage
*
* @return string
*/
public function getErrormessage();

/**
* Return rendered installment plan
*
* @return string
*/
public function getInstallmentPlanHtml();
}
41 changes: 41 additions & 0 deletions Api/InstallmentPlanInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2017 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Api;

interface InstallmentPlanInterface
{
/**
* PAYONE addresscheck
* The full class-paths must be given here otherwise the Magento 2 WebApi
* cant handle this with its fake type system!
*
* @param string $birthday
* @param string $email
* @return \Payone\Core\Service\V1\Data\InstallmentPlanResponse
*/
public function getInstallmentPlan($birthday, $email = false);
}
64 changes: 64 additions & 0 deletions Block/Info/ClearingReference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2017 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Block\Info;

class ClearingReference extends Base
{
/**
* Prepare credit card related payment info
*
* @param \Magento\Framework\DataObject|array $transport
* @return \Magento\Framework\DataObject
*/
protected function _prepareSpecificInformation($transport = null)
{
if (null !== $this->_paymentSpecificInformation) {
return $this->_paymentSpecificInformation;
}
$transport = parent::_prepareSpecificInformation($transport);
$data = [];

$sTransId = $this->getInfo()->getLastTransId();
if ($sTransId == '') {
$data[(string)__('Payment has not been processed yet.')] = '';
} else {
$oStatus = $this->getAppointedStatus();
if ($oStatus->getClearingBankcode()) {
$data[(string)__('Please transfer the order amount to this bank account:')] = '';
$data[(string)__('Accountholder:')] = $oStatus->getClearingBankaccountholder();
$data[(string)__('Accountnumber:')] = $oStatus->getClearingBankaccount();
$data[(string)__('Bank code:')] = $oStatus->getClearingBankcode();
$data[(string)__('IBAN:')] = $oStatus->getClearingBankiban();
$data[(string)__('BIC:')] = $oStatus->getClearingBankbic();
$data[(string)__('Bank:')] = $oStatus->getClearingBankname();
}
$data[(string)__('Payone Transaction ID:')] = $sTransId;
$data[(string)__('Payment reference:')] = $this->getInfo()->getOrder()->getPayoneClearingReference();
}
return $transport->setData(array_merge($data, $transport->getData()));
}
}
103 changes: 103 additions & 0 deletions Block/Payolution/InstallmentPlan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?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 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2017 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Block\Payolution;

use Magento\Framework\View\Element\Template\Context;

/**
* Block-class for Payolution InstallmentPlan Ajax-call
*/
class InstallmentPlan extends \Magento\Framework\View\Element\Template
{
/**
* Constructor
*
* @param Context $context
* @param array $data
*/
public function __construct(Context $context, array $data = []) {
parent::__construct($context, $data);
$this->setTemplate('payolution/installment_plan.phtml');
}

/**
* Format price
*
* @param double $dPrice
* @return string
*/
public function formatPrice($dPrice)
{
return number_format($dPrice, 2, ',', '');
}

/**
* Generate installment selection text
*
* @param array $aInstallment
* @return string
*/
public function getSelectLinkText($aInstallment)
{
$sText = $this->formatPrice($aInstallment['installment']['1']['amount']).' ';
$sText .= $aInstallment['currency'].' ';
$sText .= __('per month').' - ';
$sText .= $aInstallment['duration'].' ';
$sText .= __('installments');
return $sText;
}

/**
* Generate payment info text
*
* @param string $sKey
* @param array $aInstallment
* @param array $aPayment
* @return string
*/
public function getPaymentInfoText($sKey, $aInstallment, $aPayment)
{
$sAmount = $this->formatPrice($aPayment['amount']);
$sDate = date('d.m.Y', strtotime($aPayment['due']));

$sText = $sKey.'. '.__('Installment').': ';
$sText .= $sAmount.' '.$aInstallment['currency'].' ';
$sText .= '('.__('due').' '.$sDate.')';
return $sText;
}

/**
* Return download link for installment draft contract
*
* @param int $iInstallments
* @return string
*/
public function getDraftDownloadLink($iInstallments)
{
return $this->getUrl('payone/payolution/draftDownload/duration/'.$iInstallments);
}
}
Loading

0 comments on commit 5018ce9

Please sign in to comment.