Skip to content

Commit

Permalink
Merge pull request #35 in DEV-MO/shopware5-module from release/5.3.0 …
Browse files Browse the repository at this point in the history
…to master

Release v5.3.0

* commit 'a609d8eb0785963a0c14df83c75a33abac36134c': (21 commits)
  [SHPWR-384] Add Changelog
  [SHPWR-368] Make payment status configurable
  [ETS-70] Fix getBillingCountry() Method
  WIP
  [ETS-54] catch errors in cronjob for bidirectionality
  [ETS-65] Change dob validation to regex
  [ETS-64] Remove change payment method button
  [ETS-65] Fix conflict
  Remove accountmode handling and improve dob validation on client side
  [ETS-65] Remove getAccountMode, cause its not company flag
  [ETS-65] Add french translation
  [ETS-65] Fix DOB validation problem
  [ETS-61] fix Credit/Debit in Shopware 5.5
  [* release/5.3.0] set versioning
  SHPWR-316 fix
  SHPWR-316 fix
  SHPWR-316 fix logging overview
  SHPWR-316 getting installment to work
  [SHWPR-360] don't set special order state for prepayment
  [SHWPR-360] add payment method prepayment
  ...
  • Loading branch information
eiriarte-mendez committed Nov 7, 2018
2 parents cd7157b + a609d8e commit eb78233
Show file tree
Hide file tree
Showing 39 changed files with 806 additions and 408 deletions.
30 changes: 28 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
.idea/
# General
.DS_Store
**.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

build/
33 changes: 26 additions & 7 deletions Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static function getPaymentMethods()
'rpayratepayrate',
'rpayratepaydebit',
'rpayratepayrate0',
'rpayratepayprepayment',
];
}

Expand Down Expand Up @@ -112,10 +113,19 @@ public function getCapabilities()
*/
public function install()
{
parent::install();

Logger::singleton()->info('INSTALL Plugin Bootstrap');
$this->subscribeEvent('Enlight_Controller_Front_StartDispatch', 'onRegisterSubscriber');
$this->str = 'Shopware_Console_Add_Command';
$this->subscribeEvent('' . $this->str . '', 'onRegisterSubscriber');

Logger::singleton()->info('RatePAY: event subscription');
$this->subscribeEvent(
'Enlight_Controller_Front_StartDispatch',
'onRegisterSubscriber'
);
$this->subscribeEvent(
'Shopware_Console_Add_Command',
'onRegisterSubscriber'
);

$queue = [
new \RpayRatePay\Bootstrapping\PaymentsSetup($this),
Expand All @@ -129,15 +139,21 @@ public function install()
new \RpayRatePay\Bootstrapping\AdditionalOrderAttributeSetup($this),
];

Logger::singleton()->info('RatePAY: bootstrap routines');
foreach ($queue as $bootstrapper) {
$bootstrapper->install();
Logger::singleton()->info('[OK] ' . get_class($bootstrapper));
}

$this->Plugin()->setActive(true);
Logger::singleton()->info('RatePAY: Successful module installation');

return [
'success' => true,
'invalidateCache' => ['frontend', 'backend']
'invalidateCache' => [
'frontend',
'backend'
]
];
}

Expand All @@ -151,7 +167,6 @@ public function install()
*/
public function update($version)
{

Logger::singleton()->info('UPDATE Plugin Bootstrap ' . $version);
$queue = [
new \RpayRatePay\Bootstrapping\FormsSetup($this),
Expand All @@ -165,10 +180,13 @@ public function update($version)

$this->_dropOrderAdditionalAttributes();

Logger::singleton()->info('RatePAY: bootstrap routines');
foreach ($queue as $bootstrapper) {
$bootstrapper->update();
Logger::singleton()->info('[OK] ' . get_class($bootstrapper));
}

Logger::singleton()->info('RatePAY: Successful module update');
Logger::singleton()->addNotice('Successful module update');

return [
Expand All @@ -178,8 +196,8 @@ public function update($version)
}

/**
* drops additional attributes for ratepay orders in s_order_attributes
*/
* drops additional attributes for ratepay orders in s_order_attributes
*/
public function _dropOrderAdditionalAttributes()
{
$metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
Expand Down Expand Up @@ -247,6 +265,7 @@ public function onRegisterSubscriber()

foreach ($subscribers as $subscriber) {
Shopware()->Events()->addSubscriber($subscriber);
// Logger::singleton()->info('[OK] ' . get_class($subscriber));
}
}
}
7 changes: 7 additions & 0 deletions Bootstrapping/Database/CreateConfigTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protected function getQuery()
'`installment` int(2) NOT NULL, ' .
'`installment0` int(2) NOT NULL, ' .
'`installmentDebit` int(2) NOT NULL, ' .
'`prepayment` int(2) NOT NULL, ' .
'`device-fingerprint-status` varchar(3) NOT NULL, ' .
'`device-fingerprint-snippet-id` varchar(55) NULL, ' .
'`country-code-billing` varchar(30) NULL, ' .
Expand Down Expand Up @@ -49,6 +50,12 @@ public function __invoke($database)
$database->query($sql);
}

$hasColumnPrepayment = ShopwareUtil::tableHasColumn('rpay_ratepay_config', 'prepayment');
if (!$hasColumnPrepayment) {
$sql = 'ALTER TABLE rpay_ratepay_config ADD COLUMN prepayment int(2) NOT NULL';
$database->query($sql);
}

$sql = 'ALTER TABLE rpay_ratepay_config DROP PRIMARY KEY, ADD PRIMARY KEY (shopId, country, backend);';
$database->query($sql);
}
Expand Down
12 changes: 6 additions & 6 deletions Bootstrapping/Events/BackendOrderControllerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function beforeCreateOrderAction(\Enlight_Hook_HookArgs $hookArgs)
}

$paymentRequestData = $this->orderStructToPaymentRequestData($orderStruct, $paymentType, $customer);
$method = \RpayRatePay\Component\Service\ShopwareUtil::getPaymentMethod($paymentType->getName());

$netItemPrices = \RpayRatePay\Component\Service\ShopwareUtil::customerCreatesNetOrders($customer);
$paymentRequester = new \Shopware_Plugins_Frontend_RpayRatePay_Component_Mapper_ModelFactory(null, true, $netItemPrices);
Expand All @@ -84,7 +85,7 @@ public function beforeCreateOrderAction(\Enlight_Hook_HookArgs $hookArgs)

$orderId = $view->getAssign('orderId');

$this->doPostProcessing($orderId, $answer, $paymentRequestData);
$this->doPostProcessing($orderId, $answer, $paymentRequestData, $method);
} else {
$customerMessage = $answer->getCustomerMessage();
$this->fail($view, [$customerMessage]);
Expand All @@ -99,8 +100,8 @@ public function beforeCreateOrderAction(\Enlight_Hook_HookArgs $hookArgs)

private function orderStructToPaymentRequestData(
\SwagBackendOrder\Components\Order\Struct\OrderStruct $orderStruct,
\Shopware\Models\Payment\Payment $paymentType,
\Shopware\Models\Customer\Customer $customer
\Shopware\Models\Payment\Payment $paymentType,
\Shopware\Models\Customer\Customer $customer
) {
$method = \RpayRatePay\Component\Service\ShopwareUtil::getPaymentMethod(
$paymentType->getName()
Expand Down Expand Up @@ -174,7 +175,7 @@ private function runSwagValidations($orderStruct)
return $violations;
}

private function doPostProcessing($orderId, $answer, $paymentRequestData)
private function doPostProcessing($orderId, $answer, $paymentRequestData, $paymentMethod)
{
$order = Shopware()->Models()->find('Shopware\Models\Order\Order', $orderId);

Expand All @@ -199,8 +200,7 @@ private function doPostProcessing($orderId, $answer, $paymentRequestData)
//insert ratepay positions
$paymentProcessor->insertRatepayPositions($order);

//payment status closed
$paymentProcessor->setPaymentStatusPaid($order);
$paymentProcessor->setPaymentStatus($order);

//insert positions
if (\Shopware_Plugins_Frontend_RpayRatePay_Bootstrap::getPCConfig() == true) {
Expand Down
2 changes: 1 addition & 1 deletion Bootstrapping/Events/OrderOperationsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function beforeDeleteOrder(\Enlight_Hook_HookArgs $arguments)
$operationData['orderId'] = $order->getId();
$operationData['items'] = $items;
$operationData['subtype'] = 'cancellation';
$result = $modelFactory->callRequest('PaymentChange', $operationData);
$result = $modelFactory->callPaymentChange($operationData);

if ($result !== true) {
Logger::singleton()->warning('Bestellung könnte nicht gelöscht werden, da die Stornierung bei RatePAY fehlgeschlagen ist.');
Expand Down
7 changes: 6 additions & 1 deletion Bootstrapping/Events/PaymentFilterSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public function filterPayments(\Enlight_Event_EventArgs $arguments)
$setToDefaultPayment = $paymentModel->getName() === 'rpayratepayrate0' ?: $setToDefaultPayment;
continue;
}
if ($payment['name'] === 'rpayratepayprepayment' && !$show['prepayment']) {
Logger::singleton()->info('RatePAY: Filter RatePAY-Prepayment');
$setToDefaultPayment = $paymentModel->getName() === 'rpayratepayprepayment' ?: $setToDefaultPayment;
continue;
}
$payments[] = $payment;
}

Expand Down Expand Up @@ -180,7 +185,7 @@ private function getRatePayPluginConfigByCountry($shopId, $country, $backend = f
{
$configLoader = new ConfigLoader(Shopware()->Db());

$payments = ['installment', 'invoice', 'debit', 'installment0'];
$payments = ['installment', 'invoice', 'debit', 'installment0', 'prepayment'];
$paymentConfig = [];

foreach ($payments as $payment) {
Expand Down
35 changes: 18 additions & 17 deletions Bootstrapping/Events/UpdateTransactionsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace RpayRatePay\Bootstrapping\Events;

use Doctrine\ORM\Query\Expr;
use RpayRatePay\Component\Service\Logger;

class UpdateTransactionsSubscriber implements \Enlight\Event\SubscriberInterface
{
const JOB_NAME = 'Shopware_Cronjob_UpdateRatepayTransactions';

const MSG_NOTIFY_UPDATES_TO_RATEPAY = '[%d/%d] Processing order %d ...notify needed updates to RatePAY';

/**
* @var string
*/
Expand Down Expand Up @@ -49,12 +52,7 @@ public function updateRatepayTransactions(\Shopware_Components_Cron_CronJob $job
/* @var \Shopware\Models\Order\Order $order */
$order = Shopware()->Models()->find('Shopware\Models\Order\Order', $orderId);
Logger::singleton()->info(
sprintf(
'[%d/%d] Processing order %d ...notify needed updated to RatePAY',
($key + 1),
$totalOrders,
$orderId
)
sprintf(self::MSG_NOTIFY_UPDATES_TO_RATEPAY, ($key + 1), $totalOrders, $orderId)
);
$orderProcessor->informRatepayOfOrderStatusChange($order);
}
Expand All @@ -64,11 +62,13 @@ public function updateRatepayTransactions(\Shopware_Components_Cron_CronJob $job
);
return $e->getMessage();
}

return 'Success';
}

/**
* @return mixed
* @throws \Exception
*/
private function getLastUpdateDate()
{
Expand All @@ -92,21 +92,22 @@ private function getLastUpdateDate()
*/
private function findCandidateOrdersForUpdate($config)
{
$orderStatus = [
$config['RatePayFullDelivery'],
$config['RatePayFullCancellation'],
$config['RatePayFullReturn'],
$allowedOrderStates = [
$config->RatePayFullDelivery,
$config->RatePayFullCancellation,
$config->RatePayFullReturn,
];
$paymentMethods = $this->getAllowedPaymentMethods();
$changeDate = $this->getChangeDateLimit();

$query = 'SELECT o.id FROM s_order o
INNER JOIN s_order_history oh ON oh.orderID = o.id
LEFT JOIN s_core_paymentmeans cp ON cp.id = o.paymentID
WHERE cp.name in (' . join(',', $paymentMethods) . ')
AND o.status in (' . join(',', $orderStatus) . ')
AND oh.change_date >= :changeDate
GROUP BY o.id';
$query = Shopware()->Db()->select()
->from(['history' => 's_order_history'], null)
->joinLeft(['order' => 's_order'], 'history.orderID = order.id', ['id'])
->joinLeft(['payment' => 's_core_paymentmeans'], 'order.paymentID = payment.id', null)
->where('history.change_date >= :changeDate')
->where('order.status IN (' . join(', ', $allowedOrderStates) . ')')
->where('payment.name IN (' . join(', ', $paymentMethods) . ')')
->distinct(true);

$rows = Shopware()->Db()->fetchAll($query, [':changeDate' => $changeDate]);

Expand Down
62 changes: 61 additions & 1 deletion Bootstrapping/form_elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,65 @@
"value": false,
"scope":1
}
},
{
"type":"select",
"name":"RatePayPrepaidPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Vorkasse:",
"value": 17,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInvoicePaymentStatus",
"config":{
"label": "Status nach Zahlung mit Rechnung:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayDebitPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Lastschrift:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInstallmentPaymentStatus",
"config":{
"label": "Status nach Zahlung mit Rate:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
},
{
"type":"select",
"name":"RatePayInstallment0PaymentStatus",
"config":{
"label": "Status nach Zahlung mit Nullprozent-Finanzierung:",
"value": 12,
"store":"base.PaymentStatus",
"displayField":"description",
"valueField":"id",
"scope":1
}
}
]
]
2 changes: 1 addition & 1 deletion Bootstrapping/locale/backend/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"label": "<b>Zugangsdaten für die Schweiz</b>"
},
"button3": {
"label": "<b>Bidirectionalität RatePAY-Bestellungen</b>"
"label": "<b>Bidirektionalität RatePAY-Bestellungen</b>"
},
"button4": {
"label": "<b>Zugangsdaten für Belgien</b>"
Expand Down
1 change: 1 addition & 0 deletions Bootstrapping/locale/frontend/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dob_info": "Please enter a Date of Birth",
"dobtooyoung": "For the chosen payment method you have to be at least 18 years old.",
"invalidAge": "For the chosen payment method you have to be at least 18 years old.",
"dobnotvalid": "Please enter a valid date of birth",
"invaliddata": "Please check your data",
"phonenumbernotvalid": "Please enter a valid telephone number.",
"ratepayAgbMouseover": "Um RatePAY nutzen zu können müssen sie den AGBs von RatePAY zustimmen",
Expand Down
1 change: 1 addition & 0 deletions Bootstrapping/locale/frontend/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dob_info": "Date de naissance",
"dobtooyoung": "Veuillez vérifier les informations fournies. Pour utiliser le moyen de paiement sélectionné, vous devez être âgé de plus de 18 ans et la date de naissance doit être renseignée selon le format TT.MM.JJJJ.')",
"invalidAge": "Veuillez vérifier les informations fournies. Pour utiliser le moyen de paiement sélectionné, vous devez être âgé de plus de 18 ans et la date de naissance doit être renseignée selon le format TT.MM.JJJJ.",
"dobnotvalid": "Veuillez saisir votre date de naissance.",
"invaliddata": "Afin de procéder à l'achat, veuillez indiquer le moyen de paiement et fournir les informations suivantes :",
"ok": "ok",
"phonenumbernotvalid": "Veuillez fournir un numéro de téléphone valide pour le moyen de paiement choisi.",
Expand Down
Loading

0 comments on commit eb78233

Please sign in to comment.