Skip to content

Commit 29e3584

Browse files
authored
Merge pull request #588 from FatchipRobert/MAG2-342-SafeInvoice-clearing-information
MAG2-342 - Payla clearing information
2 parents bdf634e + 6d4a2fc commit 29e3584

File tree

9 files changed

+117
-6
lines changed

9 files changed

+117
-6
lines changed

Block/Info/BNPL.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
/**
4+
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* PHP version 5
18+
*
19+
* @category Payone
20+
* @package Payone_Magento2_Plugin
21+
* @author FATCHIP GmbH <support@fatchip.de>
22+
* @copyright 2003 - 2017 Payone GmbH
23+
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
24+
* @link http://www.payone.de
25+
*/
26+
27+
namespace Payone\Core\Block\Info;
28+
29+
class BNPL extends Base
30+
{
31+
/**
32+
* Prepare credit card related payment info
33+
*
34+
* @param \Magento\Framework\DataObject|array $transport
35+
* @return \Magento\Framework\DataObject
36+
*/
37+
protected function _prepareSpecificInformation($transport = null)
38+
{
39+
if (null !== $this->_paymentSpecificInformation) {
40+
return $this->_paymentSpecificInformation;
41+
}
42+
$transport = parent::_prepareSpecificInformation($transport);
43+
$data = [];
44+
45+
$sTransId = $this->getInfo()->getLastTransId();
46+
if ($sTransId == '') {
47+
$data[(string)__('Payment has not been processed yet.')] = '';
48+
} else {
49+
$oOrder = $this->getInfo()->getOrder();
50+
if ($oOrder && $oOrder->getPayoneClearingBankiban()) {
51+
$data[(string)__('Please transfer the order amount to this bank account')] = '';
52+
$data[(string)__('Accountholder')] = $oOrder->getPayoneClearingBankaccountholder();
53+
$data[(string)__('IBAN')] = $oOrder->getPayoneClearingBankiban();
54+
$data[(string)__('BIC')] = $oOrder->getPayoneClearingBankbic();
55+
if (!empty($oOrder->getPayoneClearingBankname())) {
56+
$data[(string)__('Bank')] = $oOrder->getPayoneClearingBankname();
57+
}
58+
if (!empty($oOrder->getPayoneClearingBankcountry())) {
59+
$data[(string)__('Bank country')] = $oOrder->getPayoneClearingBankcountry();
60+
}
61+
if (!empty($oOrder->getPayoneClearingBankcity())) {
62+
$data[(string)__('Bank city')] = $oOrder->getPayoneClearingBankcity();
63+
}
64+
if (!empty($oOrder->getPayoneClearingDuedate())) {
65+
$data[(string)__('Due date')] = date((string)__('Y-m-d'), strtotime($oOrder->getPayoneClearingDuedate()));
66+
}
67+
}
68+
$sPaymentReference = $oOrder->getPayoneTxid();
69+
if (!empty($oOrder->getPayoneClearingReference())) {
70+
$sPaymentReference = $oOrder->getPayoneClearingReference();
71+
}
72+
$data[(string)__('Payment reference')] = $sPaymentReference;
73+
}
74+
return $transport->setData(array_merge($data, $transport->getData()));
75+
}
76+
}

Helper/Api.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class Api extends Base
104104
'clearing_bankaccountholder' => 'payone_clearing_bankaccountholder',
105105
'clearing_bankcity' => 'payone_clearing_bankcity',
106106
'clearing_bankiban' => 'payone_clearing_bankiban',
107-
'clearing_bankbic' => 'payone_clearing_bankbic'
107+
'clearing_bankbic' => 'payone_clearing_bankbic',
108+
'clearing_duedate' => 'payone_clearing_duedate',
108109
];
109110

110111
/**

Helper/Payment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public function getAvailableCreditcardTypes()
137137

138138
$aCreditcardTypes = explode(',', $sCreditcardTypes);
139139
foreach ($aCreditcardTypes as $sTypeId) {
140+
if (!isset($aAllTypes[$sTypeId])) {
141+
continue;
142+
}
140143
$aReturn[] = [
141144
'id' => $aAllTypes[$sTypeId]['cardtype'],
142145
'title' => $aAllTypes[$sTypeId]['name'],

Model/Methods/BNPL/BNPLBase.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class BNPLBase extends PayoneMethod
103103
*
104104
* @var string
105105
*/
106-
protected $_infoBlockType = 'Payone\Core\Block\Info\ClearingReference';
106+
protected $_infoBlockType = 'Payone\Core\Block\Info\BNPL';
107107

108108
/**
109109
* @var \Payone\Core\Helper\Api
@@ -207,6 +207,28 @@ protected function getDeviceToken()
207207
return self::BNPL_PARTNER_ID.'_'.$sMid.'_'.$sUuid;
208208
}
209209

210+
/**
211+
* @param Order $oOrder
212+
* @return string|false
213+
*/
214+
protected function getBirthday(Order $oOrder)
215+
{
216+
$sDob = false;
217+
if (!empty($oOrder->getCustomerDob())) {
218+
$sDob = $oOrder->getCustomerDob();
219+
} elseif (!empty($this->getInfoInstance()->getAdditionalInformation('dateofbirth'))) {
220+
$sDob = $this->getInfoInstance()->getAdditionalInformation('dateofbirth');
221+
}
222+
223+
if (!empty($sDob)) {
224+
$iDobTime = strtotime($sDob);
225+
if ($iDobTime !== false) {
226+
$sDob = date('Ymd', $iDobTime);
227+
}
228+
}
229+
return $sDob;
230+
}
231+
210232
/**
211233
* Return parameters specific to this payment type
212234
*
@@ -226,7 +248,7 @@ public function getPaymentSpecificParameters(Order $oOrder)
226248
'financingtype' => $this->getSubType(),
227249
'add_paydata[device_token]' => $this->getDeviceToken(),
228250
'businessrelation' => $sBusinessrelation,
229-
'birthday' => $oInfoInstance->getAdditionalInformation('dateofbirth')
251+
'birthday' => $this->getBirthday($oOrder),
230252
];
231253

232254
$sTelephone = $oInfoInstance->getAdditionalInformation('telephone');

Model/PayoneConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
abstract class PayoneConfig
3333
{
3434
/* Module version */
35-
const MODULE_VERSION = '3.13.2';
35+
const MODULE_VERSION = '3.13.3';
3636

3737
/* Authorization request types */
3838
const REQUEST_TYPE_PREAUTHORIZATION = 'preauthorization';

Setup/UpgradeData.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
234234
['type' => 'varchar', 'length' => 64, 'default' => '']
235235
);
236236
}
237+
if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_duedate')) {
238+
$salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
239+
$salesInstaller->addAttribute(
240+
'order',
241+
'payone_clearing_duedate',
242+
['type' => 'varchar', 'length' => 32, 'default' => '']
243+
);
244+
}
237245

238246
$serializedRows = $this->getSerializedConfigRows($setup);
239247
if (!empty($serializedRows) && version_compare($this->shopHelper->getMagentoVersion(), '2.2.0', '>=')) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "payone-gmbh/magento-2",
33
"description": "PAYONE payment gateway for all German online and offline payment methods including PayPal, all major Credit Cards.",
44
"type": "magento2-module",
5-
"version": "3.13.2",
5+
"version": "3.13.3",
66
"license": [
77
"OSL-3.0",
88
"AFL-3.0"

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
-->
2727
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
28-
<module name="Payone_Core" setup_version="3.13.2">
28+
<module name="Payone_Core" setup_version="3.13.3">
2929
<sequence>
3030
<module name="Magento_Quote" />
3131
<module name="Magento_Sales" />

i18n/de_DE.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,3 +1185,4 @@
11851185
"Safe installment is not available for your current basket. Please choose another payment method.","Gesicherter Ratenkauf wird für Ihren aktuellen Warenkorb nicht unterstützt. Bitte wählen Sie eine andere Zahlart."
11861186
"Payment with differing billing- and shipping-address is not supported for this payment type","Die Zahlung bei abweichender Rechnungs- und Lieferadressen wird für diese Zahlart nicht unterstützt"
11871187
"Place Order","Jetzt kaufen"
1188+
"Y-m-d","d.m.Y"

0 commit comments

Comments
 (0)